// EMAIL VALIDATION
// var emailregex = /^[a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]{2,4}$/i ;
var emailregex  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
function correct_email(str) {
   return emailregex.test(str)
}
function chkform(obj)
{
	for(var i=0; i<obj.length-1;i++)
	{
		if (obj[i].value=='' || obj[i].value==null || obj[i].value=='null')
		{
			alert("Please enter your info in this field.");
			obj[i].focus();
			return false;
		}
	}
	if(!correct_email(obj.Email.value)) {
		alert("The Email Address entered is not a valid Email address");
		return false;
		}
    return true;
}



// TIME STAMP
function stamptime() {
    document.frmEmail.time.value = new Date();
}


// OPEN WINDOW 1
function open_window(url) {
window.open(url,"newWindow","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=600,height=454");
}

// OPEN WINDOW 2
function open_window2(url) {
window.open(url,"newWindow2","toolbar=no,scrollbars=yes,resizable=yes,location=no,status=no,width=600,height=304");
}

// OPEN WINDOW HOMES
function open_window_homes(url) {
window.open(url,"newWindowHomes","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=600,height=590");
}

// OPEN WINDOW CONTEST
function open_window_contest(url) {
window.open(url,"newWindowContest","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=502,height=700");
}


	//Homes Registration
function verifyhomesreg() {
var themessage = "Please complete the following field(s):\n\n";
if (document.frmEmail.Name.value=="") {
themessage = themessage + "  -  Name\n";
}
if (document.frmEmail.Phone.value=="") {
themessage = themessage + "  -  Phone\n";
}
if (document.frmEmail.Email.value=="") {
themessage = themessage + "  -  Email\n";
}
//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following field(s):\n\n") {
document.frmEmail.submit();
}
else {
alert(themessage);
return false;
   }
}
