// JavaScript Document
function CheckData() {
	var msg = "";
	pass=true;
	var f = document.input;

	//Validate Name
	if  ((pass) && (! ValidateTextBox(f.Name))) {
		msg = "Please enter your Name";
		pass = errorMsg(msg, f.Name);
	}

	//Email
	if ((pass) && (!ValidateEMail(f.Email.value))) {
		msg = "Please enter a valid Email Address";
		pass = errorMsg(msg, f.Email);
	}

	if(!pass){
		return false;
	}
	else {
		f.submit();
		return true;
	}
}

function ValidateTextBox(form_object) {
	if (form_object.value == "") {
		return(false);
	}
	else {
		return(true);
	}
}

function errorMsg(msg, form_object) {
	alert(msg);
	form_object.focus();
	if(form_object.type == "text") {
		form_object.select();
	}
}

function ValidateEMail(i_strEMailAddress) {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) {
			supported = 1;
		}
	}

	if (!supported) {
    		return (i_strEMailAddress.indexOf(".") > 2) && (i_strEMailAddress.indexOf("@") > 0);
    	}

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(i_strEMailAddress) && r2.test(i_strEMailAddress));
}
