function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
function openSiteSearch (url, name, chrome)
  {
  window.open(url, name, chrome)
  }

function goToCellPulldown (form)
{
self.location = form.options[form.selectedIndex].value;
}

function MM_findObj(n, d) {  
  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); return x;
}



/*************************************************************************
** these functions validate the string or form object passed in,
** and return true or false based on whether the test succeeds or fails
** a single field can have multiple validations - EX:
** 'RisEmail' means that it has to have email in proper format
**
** validate existence of input
**   isText - verifies text input or textarea is not empty
**   isSelect - verifies item from a select menu is chosen
**   isRadio - verifies one of a group of radio buttons is chosen
**   isCheck - verifies at least one of a group of checkboxes is checked
**   isNum - verifies text input is a number [option inRangeXX:YY]
**   isLen:XX - verifies text input is > XX characters
**   R - required field 
**       [not to be used with isSelect, isRadio or isCheck - required is implied]
** validate text in text input or textarea matches pattern
**   isEmail - verifies email address (contains "@" and ".")
**   isState - verifies U.S. State Code
**   isZipCode - verifies zip code in form of xxxxx or xxxxx-xxxx
**   isPhoneNum - verifies phone number in form of xxx-xxx-xxxx
**   isDate - verifies date in form of mm/dd/yyyy
*************************************************************************/

// version 1.0 3-5-2000 [isRadio and isCheck are non existent]
function MM_validateForm() {  
  var i,p,q,nm,test,num,min,max,errors='',si,args=MM_validateForm.arguments; 
  for (i=0; i<(args.length-2); i+=3) { 
   test=args[i+2];  
  errfield=args[i+1];
  fieldname=args[i];
  val=MM_findObj(args[i]); 
  if (errfield == '') {
  errfield = val.name
  }
      if (val) { nm=errfield;  // alert(test+'/'+val.value+'/'+val.name+'/'+val.length+'/'+val.selectedIndex);
      if (test == 'isSelect') { si = val.selectedIndex;
			if (si == '0' ) errors+='- '+nm+' must have a selection.\n';
	  } else if (test == 'isRadio') { 
	  	radioChecked='unchecked';
	  	isRadio(val);
			if (radioChecked=='unchecked') errors+='- '+nm+' must have radio button chosen.\n';
	  } else if (test == 'isCheck') { 
	  	checkboxChecked='unchecked';
	  	isCheck(val);
			if (checkboxChecked=='unchecked') errors+='- '+nm+' must have a checkbox chosen.\n';
      } else if ((val=val.value)!='') {
	      if (test.indexOf('isLen')!=-1) { num = val.length; p=test.indexOf(':'); len=test.substring(p+1);
	        if (num<len) errors+='- '+nm+' must be at least '+len+' characters.\n';
	      } else if (test.indexOf('isDate')!=-1) {  p = isDate(val) ;
	        if (p == false) errors+='- '+nm+' must be in mm/dd/yyyy format.\n';  
	      } else if (test.indexOf('isEmail')!=-1) { p = isEmail(val) ;
	        if (p == false) errors+='- '+nm+' must contain a proper e-mail address.\n';
	      } else if (test.indexOf('isState')!=-1) { p = isState(val) ;
	        if (p == false) errors+='- '+nm+' must contain a valid state.\n';
	      } else if (test.indexOf('isPhoneNum')!=-1) { p = isPhoneNum(val) ;
	        if (p == false) errors+='- '+nm+' must be in ###-###-#### format\n';
	      } else if (test.indexOf('isZipCode')!=-1) { p = isZipCode(val) ;
	        if (p == false) errors+='- '+nm+' must contain a zip code.\n';
	      } else if (test.indexOf('isText')!=-1) { p = isText(val) ;
	        if (p == false) errors+='- '+nm+' must contain text.\n';
	      } else if (test.indexOf('isNum')!=-1) { num = parseFloat(val);  //'test !='R'
	        	if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
	      	    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
	            min=test.substring(8,p); max=test.substring(p+1);
	            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
  if (errors) alert('The following error(s) occurred:\n'+errors); 
  document.MM_returnValue = (errors == '');
}


function isDate(string) {
  if (string.length != 10) { return false }
  for (j=0; j<string.length; j++) {
    if ((j == 2) || (j == 5)) {
      if (string.charAt(j) != "/") { return false }
    } else {
      if ((string.charAt(j) < "0") || (string.charAt(j) > "9")) { return false }
    }
  }
  var month = string.charAt(0) == "0" ? parseInt(string.substring(1,2)) : parseInt(string.substring(0,2));
  var day = string.charAt(3) == "0" ? parseInt(string.substring(4,5)) : parseInt(string.substring(3,5));
  var begin = string.charAt(6) == "0" ? (string.charAt(7) == "0" ? (string.charAt(8) == "0" ? 9 : 8) : 7) : 6;
  var year = parseInt(string.substring(begin, 10));
  if (day == 0) { return false }
  if (month == 0 || month > 12) { return false }
  if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
    if (day > 31) { return false }
  } else {
    if (month == 4 || month == 6 || month == 9 || month == 11) {
      if (day > 30) { return false }
    } else {
      if (year%4 != 0) {
        if (day > 28) { return false }
      } else {
        if (day > 29) { return false }
      }
    }
  }
  return true;
}

function isPhoneNum(string) {
  if (string.length != 12) { return false }
  for (j=0; j<string.length; j++) {
    if ((j == 3) || (j == 7)) {
      if (string.charAt(j) != "-") { return false }
    } else {
      if ((string.charAt(j) < "0") || (string.charAt(j) > "9")) { return false }
    }
  }
  return true;
}

function isEmail(string) {
	AtSym    = string.indexOf('@')
	Period   = string.lastIndexOf('.')
	Space    = string.indexOf(' ')
	Length   = string.length - 1
 if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      return false
   }
}

function isState(string) {
  string = string.toUpperCase();
  return ( (string == "AK") || (string == "AL") || (string == "AR") || (string == "AZ") || (string == "CA") || (string == "CO") || (string == "CT") || (string == "DC") || (string == "DE") || (string == "FL") || (string == "GA") || (string == "HI") || (string == "IA") || (string == "ID") || (string == "IL") || (string == "IN") || (string == "KS") || (string == "KY") || (string == "LA") || (string == "MA") || (string == "MD") || (string == "ME") || (string == "MI") || (string == "MN") || (string == "MO") || (string == "MS") || (string == "MT") || (string == "NB") || (string == "NC") || (string == "ND") || (string == "NH") || (string == "NJ") || (string == "NM") || (string == "NV") || (string == "NY") || (string == "OH") || (string == "OK") || (string == "OR") || (string == "PA") || (string == "RI") || (string == "SC") || (string == "SD") || (string == "TN") || (string == "TX") || (string == "UT") || (string == "VA") || (string == "VT") || (string == "WA") || (string == "WI") || (string == "WV") || (string == "WY") );
}

function isZipCode(string) {
  var l = string.length;
  if ((l != 5) && (l != 10)) { return false }
  for (j=0; j<l; j++) {
    if ((l == 10) && (j == 5)) {
      if (string.charAt(j) != "-") { return false }
    } else {
      if ((string.charAt(j) < "0") || (string.charAt(j) > "9")) { return false }
    }
  }
  return true;
}

function isText(string) {
  return (string != "");
}

// Get checked value from radio button.

function isRadio (radio)
{ 
	 	for (var i = 0; i < (radio.length); i++) {
		   if (radio[i].checked) { radioChecked='checked';break }
        }
		return radioChecked;
}

// Get checked value from Checkbox.

function isCheck (checkbox)
{ 
	 	for (var i = 0; i < (checkbox.length); i++) {
		   if (checkbox[i].checked) { checkboxChecked='checked';break }
        }
		return checkboxChecked;
}
