<!--

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

PosNumChars="1234567890.,";
AllNumChars="1234567890.,-";
MoneyChars="1234567890.,$";

function switchDiv(strDivName,bolVisible){

 //identify the element based on browser type
 if (isNS4) {
   objElement = document.layers[strDivName];
 } else if (isIE4) {
   objElement = document.all[strDivName];
 } else if (isIE5 || isNS6) {
   objElement = document.getElementById(strDivName);
 }
 
 if(isNS4){
     if(!bolVisible) {
       //objElement.style.visibility = "hidden";
       objElement.visibility ="hidden"
     } else {
       //objElement.style.visibility = "visible";
       objElement.visibility ="visible"
     }     
 }else{
     if(!bolVisible) {
       objElement.style.visibility = "hidden";
       //document.layers[strDivName].visibility ="hidden"
     } else {
       objElement.style.visibility = "visible";
       //document.layers[strDivName].visibility ="visible"
     }
 }
}
/*
function validateZIP(field) {
//alert(field.value);
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
//alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
//alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
//alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}
*/
function validateEmail(str) {
   return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function validateField( fld, valChars, valLength ) { 
//alert(valChars);
   var temp_value = fld; 
   if (valLength > 0 && (temp_value.length != valLength)) { 
     //fld.value = "$0.00"; 
     return false; 
   } 
   for (var i = 0; i < temp_value.length; i++) { 
       if (valChars.indexOf(temp_value.charAt(i)) == -1) { 
           //alert("Invalid Character(s)\n\nOnly numbers (0-9), a dollar sign, a comma, and a period are allowed in this field."); 
           //fld.focus(); 
       //fld.select(); 
           return false; 
       } 
   } 
   return true;
} 



function chkdate(datefield) {
	var strDatestyle = "US"; //United States date style
	//var strDatestyle = "EU";  //European date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	strDate = datefield;
	if (strDate.length < 1) {
		return true;
	}
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3) {
				err = 1;
				return false;
			} else {
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
			booFound = true;
		}
	}
	if (booFound == false) {
		if (strDate.length>5) {
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
		}
	}
	if (strYear.length == 2) {
		strYear = '20' + strYear;
	}
	// US style
	if (strDatestyle == "US") {
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if (isNaN(intday)) {
		err = 2;
		return false;
	}
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) {
		err = 3;
		return false;
	}
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) {
		err = 4;
		return false;
	}
	if (intMonth>12 || intMonth<1) {
		err = 5;
		return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
		err = 6;
		return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
		err = 7;
		return false;
	}
	if (intMonth == 2) {
		if (intday < 1) {
			err = 8;
			return false;
		}
		if (LeapYear(intYear) == true) {
			if (intday > 29) {
				err = 9;
				return false;
			}
		} else {
			if (intday > 28) {
				err = 10;
				return false;
			}
		}
	}
	//check over 18
	var yr18 = new Date();
	var year = yr18.getYear();
	yr18.setYear(year - 18);
	if (yr18 < Date.parse(strYear + "/" + strMonth + "/" + strDay)) {
		//alert("Not 18");
		return false;
	} else {
		return true;
	}
}

function LeapYear(intYear) {
	if (intYear % 100 == 0) {
		if (intYear % 400 == 0) { return true; }
	}
	else {
		if ((intYear % 4) == 0) { return true; }
	}
	return false;
}

function OpenFAQ() {
	var WinSettings = "Height=600px,Width=450px,status=no,menubar=no,scrollbars=yes"
	
//var WinSettings = ""
	var FAQWin = window.open("FAQ.aspx", "BS_FAQ", WinSettings);  
	FAQWin.focus();
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
//alert(isNN);
	var keyCode = (isNN) ? e.which : e.keyCode; 
//alert(keyCode);
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	return true;
}

function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length) {
		if(arr[index] == ele) {
			found = true;
		} else {
			index++;
		}
	}
	return found;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1) {
		if (input.form[i] == input) {
			index = i;
		} else {
			i++; 
		}
	}
	return index;
}


//  End -->


