// 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;
}

function chkformEmail(obj)
{
	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 3
function open_window3(url) {
window.open(url,"newWindow","toolbar=no,scrollbars=yes,resizable=no,location=no,status=no,width=830,height=700");
}

// OPEN WINDOW 4
function open_window4(url) {
window.open(url,"newWindow","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=770,height=512");
}
// OPEN WINDOW 5
function open_window5(url) {
window.open(url,"newWindow","toolbar=no,scrollbars=yes,resizable=no,location=no,status=no,width=775,height=600");
}
// OPEN WINDOW 6
function open_window6(url) {
window.open(url,"newWindow","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=350,height=300");
}


// 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");
}

// OPEN WINDOW GOLF GETAWAY
function open_window_golfgetaway(url) {
window.open(url,"newWindowGolfGetaway","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=600,height=700");
}

// OPEN WINDOW STAY and PLAY
function open_window_stayandplay(url) {
window.open(url,"newWindowStayandPlay","toolbar=no,scrollbars=no,resizable=no,location=no,status=no,width=598,height=600");
}

	//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;
   }
}

function verifygetaway() {
var themessage = "Please complete the following field(s):\n\n";
if (document.golfgetaway.firstname.value=="") {
themessage = themessage + "  -  First Name\n";
}
if (document.golfgetaway.lastname.value=="") {
themessage = themessage + "  -  Last Name\n";
}
if (document.golfgetaway.Email.value=="") {
themessage = themessage + "  -  Email\n";
}
if(!correct_email(golfgetaway.Email.value)) {
themessage = themessage + "  -  Email not a valid format\n";
}
if (document.golfgetaway.address.value=="") {
themessage = themessage + "  -  Address\n";
}
if (document.golfgetaway.city.value=="") {
themessage = themessage + "  -  City\n";
}
if (document.golfgetaway.province.value=="") {
themessage = themessage + "  -  Province\n";
}
if (document.golfgetaway.postal.value=="") {
themessage = themessage + "  -  Postal Code\n";
}
if (document.golfgetaway.phone.value=="") {
themessage = themessage + "  -  Phone\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q1.length; i++) {if (golfgetaway.q1[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 1\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q2.length; i++) {if (golfgetaway.q2[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 2\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q3.length; i++) {if (golfgetaway.q3[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 3\n";
}
if (document.golfgetaway.q4.value=="") {
themessage = themessage + "  -  Question 4\n";
}
if (document.golfgetaway.q5.value=="") {
themessage = themessage + "  -  Question 5\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q6.length; i++) {if (golfgetaway.q6[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 6\n";
}
if (	document.golfgetaway.q7a.checked == false &&
	document.golfgetaway.q7b.checked == false &&
	document.golfgetaway.q7c.checked == false &&
	document.golfgetaway.q7d.checked == false &&
	document.golfgetaway.q7e.checked == false &&
	document.golfgetaway.q7f.checked == false &&
	document.golfgetaway.q7g.checked == false ) 
	{
themessage = themessage + "  -  Question 7\n";
}
if (	document.golfgetaway.q8a.checked == false &&
	document.golfgetaway.q8b.checked == false &&
	document.golfgetaway.q8c.checked == false &&
	document.golfgetaway.q8d.checked == false &&
	document.golfgetaway.q8e.checked == false ) 
	{
themessage = themessage + "  -  Question 8\n";
}
if (document.golfgetaway.q9.value=="") {
themessage = themessage + "  -  Question 9\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q10.length; i++) {if (golfgetaway.q10[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 10\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q11.length; i++) {if (golfgetaway.q11[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 11\n";
}
myOption = -1;
for (i=0; i<golfgetaway.q12.length; i++) {if (golfgetaway.q12[i].checked) {myOption = i;}
}
if (myOption == -1) {themessage = themessage + "  -  Question 12\n";
}
//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following field(s):\n\n") {
document.golfgetaway.submit();
}
else {
alert(themessage);
return false;
   }
}