﻿//Get URL Variable
function getURLVar(urlVarName) {
//divide the URL in half at the '?' 
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
if(urlHalves[1]){
//load all the name/value pairs into an array 
var urlVars = urlHalves[1].split('&');
//loop over the list, and find the specified url variable 
for(i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
//load the name/value pair into an array 
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
//I found a variable that matches, load it's value into the return variable 
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;   
}
//////////////////////////////////////////////////////////////////
/// Industry Category
function SetIndustryCategoryID() {
var txtValues = document.getElementById('cscLeftNav_cscIndustryCategory_txtItemsSelected')
document.getElementById('cscLeftNav_txtIndustryCategoryID').value = txtValues.value

var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscIndustryCategory_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtIndustryCategory_DescriptionsSelected').value = txtDescriptionsSelected.value
}
//////////////////////////////////////////////////////////////////
/// Industry
//This function is called from the Industry Category list box only and
//can only modify down to job titles if the others are hidden.
function GetIndustry() {
    if (document.getElementById('cscLeftNav_pnlIndustry').style.display != 'none') {
        RS.Execute("RemoteMonitor.aspx","ReturnIndustries",document.getElementById('cscLeftNav_txtIndustryCategoryID').value, "cscLeftNav_cscIndustry", "", PopulateIndustries); 
    } else {            
        //Send a type at the end of the string.  Type = 0 if coming from Industry Category List
        //Type = 1 if coming from the Industry
        if (document.getElementById('cscLeftNav_cscJobTitleCategory').style.display != 'none') {
            RS.Execute("RemoteMonitor.aspx","ReturnJobTitleCategories",document.getElementById('cscLeftNav_txtIndustryCategoryID').value,"0", "cscLeftNav_cscJobTitleCategory","",PopulateJobTitleCategories);
        } else {
            //Send a type at the end of the string.  Type = 0 if coming from Industry Category List
            //Type = 1 if coming from the Industry, Type = 2 if coming from the Job Category
            if (document.getElementById('cscLeftNav_cscJobTitle').style.display != 'none') {
            RS.Execute("RemoteMonitor.aspx","ReturnJobTitles",document.getElementById('cscLeftNav_txtIndustryCategoryID').value,"0", "cscLeftNav_cscJobTitle", "", PopulateJobTitles); 
            }
          }
      }
}

function PopulateIndustries(Industries) {
    //need to clear out checked boxes if prior box was selected
    var Title = document.getElementById('cscLeftNav_cscIndustry_txtTitle').value 
    UnSelectAllCheckboxes("cscLeftNav_cscIndustry", "Select " + Title);
    
    document.getElementById('cscLeftNav_txtIndustryID').value = 0;
    document.getElementById('cscLeftNav_txtJobTitleCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtJobTitleID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyID').value = 0;  
    
    document.getElementById('cscLeftNav_txtIndustry_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtJobTitleCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtJobTitle_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialtyCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = '';  
    
    document.getElementById('cscLeftNav_cscIndustry_divData').innerHTML = Industries  
    document.getElementById('cscLeftNav_cscJobTitleCategory_txtSearchItem').value = "Select Above"    
    document.getElementById('cscLeftNav_cscJobTitle_txtSearchItem').value = "Select Above"
    document.getElementById('cscLeftNav_cscSpecialtyCategory_txtSearchItem').value = "Select Above"
    document.getElementById('cscLeftNav_cscSpecialty_txtSearchItem').value = "Select Above"
    
    
    var strURL = getURLVar('iid')
     if (strURL != '') {
        RememberMe(2)  
        }
}

function SetIndustryID() {
    var txtValues = document.getElementById('cscLeftNav_cscIndustry_txtItemsSelected')   
    document.getElementById('cscLeftNav_txtIndustryID').value = txtValues.value
    
    
var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscIndustry_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtIndustry_DescriptionsSelected').value = txtDescriptionsSelected.value
}

//////////////////////////////////////////////////////////////////
/// Job Title Category
//This function is called from the Industry list box only and
//can only modify down to job titles if the other are hidden.
function GetJobTitleCategories() {      
    //Send a type at the end of the string.  Type = 0 if coming from Industry Category List
    //Type = 1 if coming from the Industry        
    if (document.getElementById('cscLeftNav_pnlJobTitleCategory').style.display != 'none') {
         RS.Execute("RemoteMonitor.aspx","ReturnJobTitleCategories",document.getElementById('cscLeftNav_txtIndustryID').value,"1", "cscLeftNav_cscJobTitleCategory", "",PopulateJobTitleCategories);
    } else {
        //Send a type at the end of the string.  Type = 0 if coming from Industry Category List
        //Type = 1 if coming from the Industry, Type = 2 if coming from the Job Category
        if (document.getElementById('cscLeftNav_pnlJobTitle').style.display != 'none') {       
         RS.Execute("RemoteMonitor.aspx","ReturnJobTitles",document.getElementById('cscLeftNav_txtIndustryID').value,"1", "cscLeftNav_cscJobTitle", "", PopulateJobTitles); 
           // RS.Execute("RemoteMonitor.aspx","ReturnJobTitles",document.getElementById('cscLeftNav_txtIndustryID').value,"1",PopulateJobTitles);
//            RS.Execute("RemoteMonitor.aspx","ReturnJobTitles",document.getElementById('cscLeftNav_txtJobTitleCategoryID').value,"2",  true, "cscLeftNav_cscJobTitle", "Job Titles", document.getElementById('cscLeftNav_txtJobTitleID').value, PopulateJobTitles); 
        }
      }     
    }

function PopulateJobTitleCategories(JobTitleCategories) {
    //need to clear out checked boxes if prior box was selected
    var Title = document.getElementById('cscLeftNav_cscJobTitleCategory_txtTitle').value; 
    UnSelectAllCheckboxes("cscLeftNav_cscJobTitleCategory", "Select " + Title);
    
    document.getElementById('cscLeftNav_txtJobTitleCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtJobTitleID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyID').value = 0;
    
    document.getElementById('cscLeftNav_txtJobTitleCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtJobTitle_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialtyCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = ''; 
   
    document.getElementById('cscLeftNav_cscJobTitleCategory_divData').innerHTML = JobTitleCategories 
    document.getElementById('cscLeftNav_cscJobTitleCategory_txtSearchItem').value = "Select " + Title;    
         
    document.getElementById('cscLeftNav_cscJobTitle_txtSearchItem').value = "Select Above"
    document.getElementById('cscLeftNav_cscSpecialtyCategory_txtSearchItem').value = "Select Above"
    document.getElementById('cscLeftNav_cscSpecialty_txtSearchItem').value = "Select Above"
    
    var strURL = getURLVar('jcid')
     if (strURL != '') {
        RememberMe(3)  
        }
    }

function SetJobTitleCategoryID() {
var txtValues = document.getElementById('cscLeftNav_cscJobTitleCategory_txtItemsSelected')
document.getElementById('cscLeftNav_txtJobTitleCategoryID').value = txtValues.value

var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscJobTitleCategory_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtJobTitleCategory_DescriptionsSelected').value = txtDescriptionsSelected.value
}

//////////////////////////////////////////////////////////////////
/// Job Titles
//This function is called from the Job Category list box only and
//can only modify down to specialties if the others are hidden.
function GetJobTitles() {
    //Send a type at the end of the string.  Type = 0 if coming from Industry Category List
    //Type = 1 if coming from the Industry, Type = 2 if coming from the Job Category
    if (document.getElementById('cscLeftNav_pnlJobTitle').style.display != 'none') {
        RS.Execute("RemoteMonitor.aspx","ReturnJobTitles",document.getElementById('cscLeftNav_txtJobTitleCategoryID').value,"2", "cscLeftNav_cscJobTitle",  "", PopulateJobTitles); 
    } else {               
        //Send a type at the end of the string.  Type = 0 if coming from Job Category List
        //Type = 1 if coming from the Job Titles
        if (document.getElementById('cscLeftNav_pnlSpecialtyCategory').style.display != 'none') {
           RS.Execute("RemoteMonitor.aspx","ReturnSpecialtyCategories",document.getElementById('cscLeftNav_txtJobTitleCategoryID').value,"0", "cscLeftNav_cscSpecialtyCategory", "", PopulateSpecialtyCategories); 
        } else {
            //Send a type at the end of the string.  Type = 0 if coming from Job Category List
            //Type = 1 if coming from the Job Titles, Type = 2 if coming from the Specialty Category
            if (document.getElementById('cscLeftNav_pnlSpecialty').style.display != 'none') {
                //alert(document.getElementById('cscLeftNav_txtJobTitleCategoryID').value);
                RS.Execute("RemoteMonitor.aspx","ReturnSpecialties",document.getElementById('cscLeftNav_txtJobTitleCategoryID').value ,"0", "cscLeftNav_cscSpecialty", "", PopulateSpecialties);                            
            }
          }
      }
}

function PopulateJobTitles(JobTitles) {
    //need to clear out checked boxes if prior box was selected
    var Title = document.getElementById('cscLeftNav_cscJobTitle_txtTitle').value 
    UnSelectAllCheckboxes("cscLeftNav_cscJobTitle", "Select " + Title);
      
    document.getElementById('cscLeftNav_txtJobTitleID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyID').value = 0;
    
    document.getElementById('cscLeftNav_txtJobTitle_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialtyCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = ''; 
    
    document.getElementById('cscLeftNav_cscJobTitle_divData').innerHTML = JobTitles
    document.getElementById('cscLeftNav_cscJobTitle_txtSearchItem').value = "Select " + Title;
    
    document.getElementById('cscLeftNav_cscSpecialtyCategory_txtSearchItem').value = "Select Above"
    document.getElementById('cscLeftNav_cscSpecialty_txtSearchItem').value = "Select Above"
    var strURL = getURLVar('jtid')
     if (strURL != '') {
        RememberMe(4)  
        }      
      
}

function SetJobTitleID() {
var txtValues = document.getElementById('cscLeftNav_cscJobTitle_txtItemsSelected')
document.getElementById('cscLeftNav_txtJobTitleID').value = txtValues.value

var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscJobTitle_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtJobTitle_DescriptionsSelected').value = txtDescriptionsSelected.value
}

//////////////////////////////////////////////////////////////////
/// Specialty Category
//This function is called from the Job Title list box only and
//can only modify down to specialties if the others are hidden.
function GetSpecialtyCategories() {
     //Send a type at the end of the string.  Type = 0 if coming from Job Category List
        //Type = 1 if coming from the Job Titles
        if (document.getElementById('cscLeftNav_pnlSpecialtyCategory').style.display != 'none') {
            RS.Execute("RemoteMonitor.aspx","ReturnSpecialtyCategories",document.getElementById('cscLeftNav_txtJobTitleID').value,"1", "cscLeftNav_cscSpecialtyCategory", "", PopulateSpecialtyCategories); 
        } else {
            //Send a type at the end of the string.  Type = 0 if coming from Job Category List
            //Type = 1 if coming from the Job Titles, Type = 2 if coming from the Specialty Category
            if (document.getElementById('cscLeftNav_pnlSpecialty').style.display != 'none') {
              RS.Execute("RemoteMonitor.aspx","ReturnSpecialties",document.getElementById('cscLeftNav_txtJobTitleID').value,"1", "cscLeftNav_cscSpecialty", "", PopulateSpecialties); 
           }
          }
}

function PopulateSpecialtyCategories(SpecialtyCategories) {
//need to clear out checked boxes if prior box was selected
 var Title = document.getElementById('cscLeftNav_cscSpecialtyCategory_txtTitle').value 
    UnSelectAllCheckboxes("cscLeftNav_cscSpecialtyCategory", "Select " + Title);
   
    document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value = 0;
    document.getElementById('cscLeftNav_txtSpecialtyID').value = 0;
   
    document.getElementById('cscLeftNav_txtSpecialtyCategory_DescriptionsSelected').value = '';
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = ''; 
    
    document.getElementById('cscLeftNav_cscSpecialtyCategory_divData').innerHTML = SpecialtyCategories
    document.getElementById('cscLeftNav_cscSpecialtyCategory_txtSearchItem').value = "Select " + Title;
     
    document.getElementById('cscLeftNav_cscSpecialty_txtSearchItem').value = "Select Above"
   
    var strURL = getURLVar('scid')
    if (strURL != '') {
        RememberMe(5)  
        }
}

function SetSpecialtyCategoryID() {
var txtValues = document.getElementById('cscLeftNav_cscSpecialtyCategory_txtItemsSelected')
document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value = txtValues.value

var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscSpecialtyCategory_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtSpecialtyCategory_DescriptionsSelected').value = txtDescriptionsSelected.value
}


//////////////////////////////////////////////////////////////////
/// Specialties
//This function is called from the Specialty Category list box only
function GetSpecialties() {   
    //Send a type at the end of the string.  Type = 0 if coming from Job Category List
    //Type = 1 if coming from the Job Titles, Type = 2 if coming from the Specialty Category
    if (document.getElementById('cscLeftNav_pnlSpecialty').style.display != 'none') {
        RS.Execute("RemoteMonitor.aspx","ReturnSpecialties",document.getElementById('cscLeftNav_txtSpecialtyCategoryID').value,"2", "cscLeftNav_cscSpecialty", "", PopulateSpecialties); 
    }
}

function PopulateSpecialties(Specialties) {
 var Title = document.getElementById('cscLeftNav_cscSpecialty_txtTitle').value 
    UnSelectAllCheckboxes("cscLeftNav_cscSpecialty", "Select " + Title);

    document.getElementById('cscLeftNav_txtSpecialtyID').value = 0;    
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = ''; 

    document.getElementById('cscLeftNav_cscSpecialty_divData').innerHTML = Specialties
    document.getElementById('cscLeftNav_cscSpecialty_txtSearchItem').value = "Select " + Title;
    
    var strURL = getURLVar('sid')
     if (strURL != '') {
        RememberMe(6)  
        }
}

function SetSpecialtyID() {
    var txtValues = document.getElementById('cscLeftNav_cscSpecialty_txtItemsSelected')
    document.getElementById('cscLeftNav_txtSpecialtyID').value = txtValues.value
    
    var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscSpecialty_txtDescriptionsSelected')
    document.getElementById('cscLeftNav_txtSpecialty_DescriptionsSelected').value = txtDescriptionsSelected.value
}

function SetStateID() {
var txtValues = document.getElementById('cscLeftNav_cscState_txtItemsSelected')
document.getElementById('cscLeftNav_txtStateID').value = txtValues.value

var txtDescriptionsSelected = document.getElementById('cscLeftNav_cscState_txtDescriptionsSelected')
document.getElementById('cscLeftNav_txtState_DescriptionsSelected').value = txtDescriptionsSelected.value
}


//////////////////////////////////////////////////////////////////
/// Rollover

if(document.images)
	{
		p1 =  new Image();
		p2 =  new Image();
		p3 =  new Image();
		p4 =  new Image();
		p5 =  new Image();	
		p6 =  new Image();	
		p7 =  new Image();
		
		
		p1.src = "graphics/job_seekers_over.gif";		
		p2.src = "graphics/employers_over.gif";
		p3.src = "graphics/careercenter_over.gif";	
		p4.src = "graphics/about_clinical_over.gif";	
		p5.src = "graphics/contactus_over.gif";	
		p6.src = "graphics/btn_searchJobsMarron_over.jpg";	
		p7.src = "graphics/register_icon_blue_over.jpg";	

	}

function SwapImage(o, NewImage){
    o.src = NewImage;
}
//Function to bring over URL values in text boxes
function RememberMe(type) {
switch(type)
{
case 1:
  GetIndustry();
  SetIndustryCategoryID();
  break;    
case 2:
  GetJobTitleCategories();
  SetIndustryID();
  break;
case 3:
  GetJobTitles();
  SetJobTitleCategoryID();
  break;
case 4:
  GetSpecialtyCategories();
  SetJobTitleID();
  break;
case 5:
  GetSpecialties();
  SetSpecialtyCategoryID();
  break;
case 6:
  SetSpecialtyID();
  break;
case 7:
  SetStateID();
  break;
default:
  
} 

}
//Keyword Textbox Clear/Populate calls
function ClearValue(field, strCheck)
	{
		if(field.value == strCheck)
		field.value = "";				
	}
function Repopulate(field, strCheck)
	{
		if(field.value == "")
		field.value = strCheck;
	}	

//Show the appropriate panel in the left navigation menu.
function ShowNavPanel(ControlName) {
if (document.getElementById(ControlName).style.display == 'inline') {
HideAllNavPanels("pnlDropDownItems");
} else {
HideAllNavPanels("pnlDropDownItems");
document.getElementById(ControlName).style.display = 'inline';
}
//document.getElementById(ControlName).focus();
}

//Hide the appropriate panel in the left navigation menu.
function HideNavPanel(ControlName) {
  document.getElementById(ControlName).style.display = 'none';
}

//Hide all panels in the left navigation menu.
function HideAllNavPanels() {
    if (document.getElementById('cscLeftNav_cscIndustryCategory_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscIndustryCategory_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscIndustry_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscIndustry_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscJobTitleCategory_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscJobTitleCategory_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscJobTitle_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscJobTitle_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscSpecialtyCategory_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscSpecialtyCategory_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscSpecialty_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscSpecialty_pnlDropDownItems').style.display = 'none'
    }
    if (document.getElementById('cscLeftNav_cscState_pnlDropDownItems') != null) {
       document.getElementById('cscLeftNav_cscState_pnlDropDownItems').style.display = 'none'
    }
}

function getElementsByName_iefix(tag, id) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("id");
          if(att == id) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

//Change the view to either Brief or detail
function ChangeView(Type) {
    var TotalRecords = document.getElementById('txtTotalRecords').value;
    var i = 1;
    for (var i = 1; i <= TotalRecords; i++) {
        if (document.getElementById('divDescription_' + i) != null) {    
            if (Type == 0) {                  
                document.getElementById('divDescription_' + i).style.display = 'none';  
                } else
                {
                document.getElementById('divDescription_' + i).style.display = 'inline';  
                }
            }
    } 
    
    //Assign checked-selected     
    if (Type == 0) {                  
       document.getElementById('rbViewBrief').checked = true
       document.getElementById('rbViewDetailed').checked = false
       } else
       {
       document.getElementById('rbViewBrief').checked = false
       document.getElementById('rbViewDetailed').checked = true
       }
}

////////////////////////////////////////////////////////
/// Validation Calls


function RemoveDateMask(o) {
    if (o.value == 'mm/dd/yyyy') {
        o.value = '';
        o.className = '';
    }
}

function RemoveTimeMask(o) {
    if (o.value == 'hh:mm') {
        o.value = '';
        o.className = '';
    }
}

function RemovePhoneMask(o) {
    if (o.value == '(###) ###-####') {
        o.value = '';
        o.className = '';
    }
}

function RemoveSSNMask(o) {
    if (o.value == '###-##-####') {
        o.value = '';
        o.className = '';
    }
}

function RemoveEINMask(o) {
    if (o.value == '##-#######') {
        o.value = '';
        o.className = '';
    }
}

function RemoveMask(o,IDType) {
    if (IDType == 1 && o.value == 'Address Line 1') {
        o.value = '';
    } else if (IDType == 2 && o.value == 'Address Line 2') {
        o.value = '';
    } else if (IDType == 3 && o.value == 'Address Line 3') {
        o.value = '';
    } else if (IDType == 4 && o.value == 'City') {
        o.value = '';
    } else if (IDType == 5 && o.value == 'ST') {
        o.value = '';
    } else if (IDType == 6 && o.value == 'Zip') {
        o.value = '';
    }
    
    o.className = 'StandardText';
}

function ValidateAddress(o,IDType) {
    if (o.value == '') {
        if (IDType == 1) {
            o.value = 'Address Line 1'
        } else if (IDType == 2) {
            o.value = 'Address Line 2'
        } else if (IDType == 3) {
            o.value = 'Address Line 3'
        } else if (IDType == 4) {
            o.value = 'City'
        } else if (IDType == 5) {
            o.value = 'ST'
        } else if (IDType == 6) {
            o.value = 'Zip'
        }
        o.className = 'Information';
        return;
    }
    o.className = 'StandardText'    
}

function ValidatePhoneNumber(o) {
    if (o.value == '') {
        o.value = '(###) ###-####';
        o.className = 'Information';
        return;
    }
    
    var r = '';
    var s = o.value;
    var numCount = 0;  
    
    for (i = 0;i<s.length;i++) {        
        
        if (IsNumericStrict(s.charAt(i))) {
            if (numCount == 0) {
                r = '('            
            } else if (numCount == 3) {
                r += ') '
            } else if (numCount == 6) {
                r += '-'
            }
            r += s.charAt(i);            
            numCount += 1;
        }
        
    }
    
    if (numCount != 10) {        
        document.getElementById(o.id).className = 'ErrorBox';
    } else if (o.className == 'BadData') {        
    
    } else {
        o.className = 'StandardText';
    }
        
    o.value = r;
    
}

function ValidateSSNumber(o) {
    if (o.value == '') {
        o.value = '###-##-####';
        o.className = 'Information';
        return;
    }
    
    var r = '';
    var s = o.value;
    var numCount = 0;  
    
    for (i = 0;i<s.length;i++) {        
        
        if (IsNumericStrict(s.charAt(i))) {
            if (numCount == 3) {
                r += '-' 
            } else if (numCount == 5) {
                r += '-'
            }
            r += s.charAt(i);            
            numCount += 1;
        }
        
    }
    
    if (numCount != 9) {        
        document.getElementById(o.id).className = 'ErrorBox';
    } else {        
        document.getElementById(o.id).className = '';
    }
        
    o.value = r;
    
}

function ValidateEINumber(o) {
    if (o.value == '') {
        o.value = '##-#######';
        o.className = 'Information';
        return;
    }
    
    var r = '';
    var s = o.value;
    var numCount = 0;  
    
    for (i = 0;i<s.length;i++) {        
        
        if (IsNumericStrict(s.charAt(i))) {
            if (numCount == 2) {
                r += '-' 
            } 
            r += s.charAt(i);            
            numCount += 1;
        }
        
    }
    
    if (numCount != 9) {        
        document.getElementById(o.id).className = 'ErrorBox';
    } else {        
        document.getElementById(o.id).className = '';
    }
        
    o.value = r;
    
}

function ValidateTime(o) {
    if (o.value == '') {
        o.value = 'hh:mm';
        o.className = 'Information';
        return;
    }
    
    var r = '';
    var s = o.value;
    var numCount = 0;  
    
        
    if (s.length == 3) {
        s = '0' + s;
    }
    
    for (i = 0;i<s.length;i++) {        
        
        if (IsNumericStrict(s.charAt(i))) {
            if (numCount == 2) {
                r += ':' 
            } 
            r += s.charAt(i);            
            numCount += 1;
        }
        
    }
    
    
    
    if (numCount != 4) {        
        document.getElementById(o.id).className = 'ErrorBox';
    } else {        
        document.getElementById(o.id).className = '';
    }
        
    o.value = r;
    
}

function ValidateDate(o) {
    if (o.value == '') {
        o.value = 'mm/dd/yyyy';
        o.className = 'Information';
        return;
    }
       
    
    var r = '';
    var s = o.value;
    var numCount = 0;  
    var aError = false;
    var cols = s.split('/');
    
    if (cols.length == 1) {
        cols = s.split('-');
        if (cols.length == 1) {
            cols = s.split('.');
        }
    }
    
    if (cols.length > 1) {
        for (i=0;i<cols.length;i++) {
            if (i < 2) {
                if (cols[i].length == 1) {
                     r += '0' + cols[i] + '/';
                } else {
                    r += cols[i] + '/';
                }
            } else {
                if (cols[i].length == 2) {
                     r += '20' + cols[i];
                } else {
                    r += cols[i];
                }
            }
        }
    }
    
    if (r != '') {
        s = r;
    }
    r = '';
    
        
    for (i = 0;i<s.length;i++) {        
        
        if (IsNumericStrict(s.charAt(i))) {
            if (numCount == 2) {
                r += '/'            
            } else if (numCount == 4) {
                r += '/'
            }
            r += s.charAt(i);            
            numCount += 1;
        }
        
    }
    
    if (numCount != 8) {
        aError = true;
    }
    
    var month = Mid(r,0,2)
    var day = Mid(r,3,2)
    var year = Mid(r,6,4)
    
    if (month > 12) {
        aError = true;
    }
    
    if (month == '01' || month == '03' || month == '05' || month == '07' || month == '08' || month == '10' || month == '12') {
        if (day > 31) aError = true;                
    } else if (month == '04' || month == '06' || month == '09' || month == '11') {
        if (day > 30) aError = true;                
    } else if (month == '02') {
        if (day > 29) aError = true;                
    }
      
       
    
    if (aError) { 
        document.getElementById(o.id).className = 'ErrorBox';
    } else {
        document.getElementById(o.id).className = '';
    }
        
    o.value = r;
    
}


function Mid(str, start, len) {
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen) {
          iEnd = iLen;
    } else {
          iEnd = start + len;
    }
    return String(str).substring(start,iEnd);
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function IsNumericStrict(s) {    
    var IsNumber=false;
    var Char;
    
    switch (s) {
        case '0':
            IsNumber = true;
            break;
        case '1':
            IsNumber = true;
            break;
        case '2':
            IsNumber = true;
            break;
        case '3':
            IsNumber = true;
            break;
        case '4':
            IsNumber = true;
            break;
        case '5':
            IsNumber = true;
            break;
        case '6':
            IsNumber = true;
            break;
        case '7':
            IsNumber = true;
            break;
        case '8':
            IsNumber = true;
            break;
        case '9':
            IsNumber = true;
            break;    
    }
        
    return IsNumber;
}

function IsNumeric(s) {    
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
 
    for (i = 0; i < s.length && IsNumber == true; i++) { 
        Char = s.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
         }
    }
    return IsNumber;
}


function SelectItem(o,id) {
    for (var i=0;i<o.length;i++) {
        if (o[i].value == id) {
            o.selectedIndex = i;
            return;
        }
    }
}

function ReturnListText(o,id) {
    for (var i=0;i<o.length;i++) {
        if (o[i].value == id) {
            return o[i].text;
        }
    }
}

function findPos(obj) {
	var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return [curleft,curtop];
}


function FormatCurrency(str) {
    str = str.toString();
    if (str == 'NaN') {
        return '';
    }
    var cols = str.split('.');
    var num = '';
    var count = 0;
        
    cols[0] = cols[0].replace('-','');
    
    for (var i=cols[0].length;i>=0;i--) {
        if (IsNumericStrict(cols[0].charAt(i))) {
            num = cols[0].charAt(i) + num;
            count += 1;
            if (count == 3 && i > 0) {
                num = ',' + num;
                count = 0;
            }
        }
    }
    
    
    if (cols[1] == null) {
        num += ".00";
    } else if (cols[1].length == 0) {
        num += ".00";
    } else if (cols[1].length == 1) {
        num += "." + cols[1] + "0";
    } else if (cols[1].length == 2) {
        num += "." + Mid(cols[1],0,2);
    } else {
        if (parseFloat(cols[1].charAt(2)) >= 5) {
            if ((parseFloat(cols[1].charAt(1)) + 1) == 10) {
                num += "." + (parseFloat(Mid(cols[1],0,1)) + 1) + '0'
            } else {
                num += "." + Mid(cols[1],0,1) + (parseFloat(cols[1].charAt(1)) + 1);
            }
        } else {
            num += "." + Mid(cols[1],0,2);
        }
    }
    
    if (parseFloat(str) < 0) {
        num = '-' + num;
    }
       
    return num   

}

function replaceAll(text, strA, strB) {
    return text.replace( new RegExp(strA,"g"), strB);
}

function ViewSaveSearch() {
    document.getElementById('pnlSaveSearch').style.display = 'inline'
}

function SetError(id) {
    document.getElementById(id).style.backgroundColor ="#f4cbce";
    document.getElementById(id).style.border = 'solid 1px #990000';
}
function ResetError(id) {
    if (document.getElementById(id) == null) {
        return;
    }
    document.getElementById(id).style.backgroundColor ="#ffffff";
    document.getElementById(id).style.border = 'solid 1px #cdcdcd';
}