// Function to "activate" images.
function imgAct(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "on.src");
    }
}
// Function to "deactivate" images.
function imgInact(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "off.src");
    }
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




// ******************** Script Validation Functions ********************** //


 // Function: Tests if the object text is a valid date format(mm/dd/yyyy)
 // Return: True - Text has valid date format
 //         False - Text does not have valid date format
 function CheckDate(THISINPUT, FieldName) 
 {
    datevalue=(THISINPUT.value);
    re = /^([1-9]|0[1-9]|1[012])\/([1-9]|3[01]|0[1-9]|[12]\d)\/((1[89]\d{2})|([2-9]\d{3}))$/;
    checkDate = re.test(datevalue);
    if (checkDate == false)
    {
      alert (FieldName  + " is not a valid Date (or) Date is out of range [1800 - 9999]. Please try again.") ;
      THISINPUT.focus();
      THISINPUT.select();
    }
    return checkDate;
 }

 // Function: Tests if the object text is a valid time format(hh:nn)
 // Return: True - Text has valid time format
 //         False - Text does not have valid time format
 function CheckTime(THISINPUT, FieldName) 
 {
    timevalue=(THISINPUT.value);
    re = /^(\d|2[0-3]|[01]\d)[:]([012345]\d)/;
    checkTime = re.test(timevalue);
    if (checkDate == false)
    {
      alert (FieldName  + " is not a valid Time. Please try again.") ;
      THISINPUT.focus();
      THISINPUT.select();
    }
    return checkTime;
 }

 // Function: Tests if the object text is a valid number
 // Return: True - Text is a valid number
 //         False - Text is not a valid number
 function CheckNumber(THISINPUT, FieldName) 
 {
      numbervalue=(THISINPUT.value);
      checkNumber = isNaN(numbervalue);
      if (checkNumber == true)
      {
        alert (FieldName  + " is not a valid Number. Please try again.") ;
        THISINPUT.focus();
      }
      checkNumber = !checkNumber ;
      return checkNumber;
 }

 // Function: Tests if the object text is not blank
 // Return: True - Text is not blank
 //         False - Text is blank
 function CheckBlank(THISINPUT, FieldName) 
 {
      checkBlank = true;
      if (THISINPUT.value.length == 0)
      {
	 alert (FieldName  + " cannot be a blank. Please enter a value.") ;
         checkBlank = false;
         THISINPUT.focus();
      }
      return checkBlank;
 }

 // Function: Tests if the object (listbox) has any value selected
 function CheckBlankList(THISINPUT, FieldName) 
 {
      checkBlank = true ;
      if (THISINPUT.value.length == 0)
      {
	 alert (FieldName  + " cannot be a blank. Please select a value.") ;
         checkBlank = false ;
         THISINPUT.focus();
      }
      return checkBlank;
 }

 // Function: Tests if the object text is less that the maximum limit allows
 // Return: True - Text does not exceed the limit
 //         False - Text exceeds the limit
 function CheckLength(THISINPUT, fieldLen, FieldName) 
 {
    checkLength = true ;
    if (THISINPUT.value.length > fieldLen)
    {
      alert (FieldName  + " length cannot be greater than " + fieldLen + ". Please re-enter.") ;
      checkLength = false ;
      THISINPUT.focus();
    }
    return checkLength;
 }

 // Function: Tests if the object text is less that the maximum limit allows
 //  For html area
 // Return: True - Text does not exceed the limit
 //         False - Text exceeds the limit
 function CheckLengthHtmlArea(THISINPUT, fieldLen, fieldName) 
 {
    checkLength = true ;
    if (THISINPUT.value.length > fieldLen)
    {
      alert (fieldName + " field length cannot be greater than " + fieldLen + ". Please re-enter.") ;
      checkLength = false ;
      // THISINPUT.focus();
      // THISINPUT.select();
    }
    return checkLength;
 }

 // Function: Tests if the object text is a valid telephone number format
 // (nnnnnnnnnn / nnn-nnn-nnnn /           XXXXX(nnn)nnn-nnnn)
 // Return: True - Text has valid phone format
 //         False - Text does not have valid phone format
 function CheckPhone(THISINPUT, FieldName) 
 {
    phonevalue=(THISINPUT.value);
    //re = /^(\()?\d{3}((\))?|(-)?)\d{3}((-)?)\d{4}$/; // ----- (nnn)nnn-nnnn
    re = /^\d{3}(-)?\d{3}(-)?\d{4}$/;
    checkPhone = true;
    if (phonevalue.length > 0 && re.test(phonevalue) == false)
    {
      alert (FieldName  + " is not a valid telephone number. Please try again.") ;
      checkPhone = false;
      THISINPUT.focus();
    }
    return checkPhone;
 }
