CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
function CSIEStyl(s) { return document.all.tags("div")[s].style; }
function CSNSStyl(s) { return CSFindElement(s,0); }
function CSFindElement(n,ly) { if (CSBVers < 4) return document[n];
	var curDoc = ly ? ly.document : document; var elem = curDoc[n];
	if (!elem) { for (var i=0;i<curDoc.layers.length;i++) {
		elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
	return elem;
}
function CSURLPopupShow(formName, popupName, target) {
	var form  = CSFindElement(formName);
	var popup = form.elements[popupName];
	window.open(popup.options[popup.selectedIndex].value, target);
	popup.selectedIndex = 0;
}


// Check to see if there is a @ and . characters as well as a minimum string length
function checkEmailAddy(theAddy) {
	if(theAddy == null) { return false; }
	if(theAddy.indexOf("@") == -1) { return false; }
	if(theAddy.indexOf(".") == -1) { return false; }
	if(theAddy.length < 6) { return false; }
	return true;	
}

// Check to make sure the phone number is valid
function checkPhone(thePhone) {

	// Check to make sure they're all valid characters
	var valid = '0123456789.- ()';
	var theNums = '0123456789';
	var totalNums = 0;

	for(var i=0; i< thePhone.length; i++) {
        	if(valid.indexOf(thePhone.charAt(i)) == -1)
          		return false;

		if(theNums.indexOf(thePhone.charAt(i)) != -1)
			totalNums++;
    		}

	if(totalNums < 9) { return false; }
    	return true;
}

// Check all the fields in the form before submitting
function checkAllForm() {
	if(InfoForm.name.value.length == 0) { alert('Please enter a valid name'); InfoForm.name.focus(); return false; }
	if(checkPhone(InfoForm.phone.value) == false) { alert('Please enter a valid phone number.'); InfoForm.phone.focus(); return false; }
	if(checkEmailAddy(InfoForm.email.value) == false) { alert('Please enter a valid E-Mail address.'); InfoForm.email.focus(); return false; }
	return true;
}
