//The Move Focus Function
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function MoveFocus(input,len, e) {
var keyCode = (isNN) ? e.which : e.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 of The Move Focus Function







// Function Send Form

function sendValidate(form){

	display(form);
	var MyString = (form.Email.value)
	var MyStringUp = MyString.toUpperCase()

	if (trim(form.FirstName.value) == ""){
		alert ("\n Please enter your first name");
		form.FirstName.focus();
	}
	else
	if (trim(form.FirstName.value) == ""){
		alert ("\n Please enter your first name");
		form.FirstName.focus();
	}
	else
	if (trim(form.LastName.value) == ""){
		alert ("\n Please enter your last name");
		form.LastName.focus();	
	}
	else
	if (trim(form.City.value) == ""){
		alert ("\n Please enter your city");
		form.City.focus();
	}
	else
	if (form.State.value == ""){
		alert ("\n Please select a state");
		form.State.focus();
	}
	else
	if (trim(MyStringUp) == "NONE"){
		form.submit();
	}
	else
	if (!validEmail(trim(MyString))){
		alert ("\nInvalid Email Address.. \nIf you do not have an email address please enter \nthe word NONE in the text box");
		form.Email.focus();		
	}
	else
	if (trim(form.Email.value) != trim(form.ChkEmail.value)) {
		alert ("\n Entered Email addresses do not match");
		form.Email.focus();
}
else
	form.submit();
}

// End Function Send Form







// Trim Function

function trim(st) {
var len = st.length
var begin = 0, end = len - 1;
while (st.charAt(begin) == " " && begin < len) {
begin++;
}
while (st.charAt(end) == " " && begin < end) {
end--;
}
return st.substring(begin, end+1);
}

// End Trim Function












// Check Email Function

	function validEmail(email) {
		invalidChars = " /:,;="

		if(email=="") {
			return false
		}
		for (i=0; i<invalidChars.length; i++) {
			badChar=invalidChars.charAt(i)
			if(email.indexOf(badChar,0)>-1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos==-1 || atPos==0) {
			return false
		}
		if (email.indexOf("@",atPos+1) > -1) {
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			return false
		}
		if (periodPos+3 > email.length -1) {
			return false
		}
		return true
	}

// End Check Email



// Get user info

function display(form) {
window.onerror=null;

colors = window.screen.colorDepth;
form.color.value = Math.pow (2, colors);
if (window.screen.fontSmoothingEnabled == true)
form.fonts.value = "Yes";
else form.fonts.value = "No";

form.navigator.value = navigator.appName;
form.version.value = navigator.appVersion;
form.colordepth.value = window.screen.colorDepth;
form.width.value = window.screen.width;
form.height.value = window.screen.height;
form.maxwidth.value = window.screen.availWidth;
form.maxheight.value = window.screen.availHeight;
form.codename.value = navigator.appCodeName;
form.platform.value = navigator.platform;
if (navigator.javaEnabled() < 1) form.java.value="No";
if (navigator.javaEnabled() == 1) form.java.value="Yes";

if(navigator.javaEnabled() && (navigator.appName != "Microsoft Internet Explorer")) {
vartool=java.awt.Toolkit.getDefaultToolkit();
addr=java.net.InetAddress.getLocalHost();
host=addr.getHostName();
ip=addr.getHostAddress();
form.hostname.value = host;
form.ip.value = ip;

   }
   
   
}
// End Get user info


