function getRequester() {
	var requester = null; 
	if (requester != null && requester.readyState != 0 && requester.readyState != 4) {
		requester.abort();
	}
	
	try  { 
		requester = new XMLHttpRequest(); 
	} catch (trymicrosoft) {
    	try {
        	requester = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (othermicrosoft) {
        	try {
            	requester = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch (failed) {
            	requester = null;
        	}  
    	}
	}
	return requester;
}

function validateForm() {
	var val = "";
	val = trim(document.frm_Sub.FirstName.value);
	if (val == "") {
		alert("Please enter first name.");
		document.frm_Sub.FirstName.focus();
		return;
	}
	val = trim(document.frm_Sub.LastName.value);
	if (val == "") {
		alert("Please enter Last name.");
		document.frm_Sub.LastName.focus();
		return;
	}
	val = trim(document.frm_Sub.EmailAddress.value);
	if (val == "") {
		alert("Please enter Email Address.");
		document.frm_Sub.EmailAddress.focus();
		return;
	} else {
		if (validateEmail(val) == false) {
			alert("Please enter a valid Email Address.");
			document.frm_Sub.EmailAddress.focus();
			document.frm_Sub.EmailAddress.value = "";
			return;
		}
	}
	val = trim(document.frm_Sub.EmailAddress2.value);
	if (val == "") {
		alert("Please confirm Email Address.");
		document.frm_Sub.EmailAddress2.focus();
		return;
	} else {
		if (validateEmail(val) == false) {
			alert("Please enter a valid confirmation Email Address.");
			document.frm_Sub.EmailAddress2.focus();
			document.frm_Sub.EmailAddress2.value = "";
			return;
		} else {
			if (trim(document.frm_Sub.EmailAddress2.value) !=
			trim(document.frm_Sub.EmailAddress.value)) {
				alert("Both Email Addresses should be same");
				document.frm_Sub.EmailAddress2.focus();
				return;
			}
		}
	}
	val = trim(document.frm_Sub.Password.value);
	if (val == "") {
		alert("Please enter a valid password.");
		document.frm_Sub.Password.focus();
		return;
	} else {
		if (validatePassword(val) == false) {
			document.frm_Sub.Password.value = "";
			document.frm_Sub.Password.focus();
			return;
		}
	}
	val = trim(document.frm_Sub.Password2.value);
	if (val == "") {
		alert("Please re-enter a valid password.");
		document.frm_Sub.Password2.focus();
		return;
	} else {
		if (validatePassword(val) == false) {
			document.frm_Sub.Password2.value = "";
			document.frm_Sub.Password2.focus();
			return;
		} else {
			if (trim(document.frm_Sub.Password2.value)
			!= trim(document.frm_Sub.Password.value)) {
				alert("Please enter same passwords.");
				document.frm_Sub.Password2.value = "";
				document.frm_Sub.Password2.focus();
				return;
			}
		}
	}
	val = trim(document.frm_Sub.MobilePhone.value);
	if (val == "") {
		alert("Please enter mobile phone number");
		return;
	}
	if (validateFields() == false) {
		return;
	}
	
	document.frm_Sub.SubmitBut.disabled = true;
	document.frm_Sub.submit();
}

function validateFields() {
	var val = "";
	
	val = trim(document.frm_Sub.FirstName.value);
	if (validateString(val) == false) {
		alert("Special characters are not allowed in first name.");
		return false;
	}
	val = trim(document.frm_Sub.MiddleName.value);
	if (validateString(val) == false) {
		alert("Special characters are not allowed in middle name.");
		return false;
	}
	val = trim(document.frm_Sub.LastName.value);
	if (validateString(val) == false) {
		alert("Special characters are not allowed in last name.");
		return false;
	}
	val = trim(document.frm_Sub.HomePhone.value);
	if (validateString(val) == false) {
		alert("Special characters are not allowed in home phone.");
		return false;
	}
	val = trim(document.frm_Sub.MobilePhone.value);
	if (validateString(val) == false) {
		alert("Special characters are not allowed in mobile phone.");
		return false;
	}
	
	return true;
}
