radioDoSurvey = "";
radioDoNewsletter = "";
function validateThis(){
var doNotSubmit = false

var isEmail = document.form1.email.value;


var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var validateEmail = emailfilter.test(isEmail);
//var validateEmail = isEmail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
//phone number
var isPhone = document.form1.phone.value;
var validatePhone = isPhone.match(/\d{3,3}-\d{3,3}-\d{4,4}|\d{10,10}|\d{3,3} \d{3,3} \d{4,4}/);
//mobile number
var isMobile = document.form1.mobile.value;
var validateMobile = isMobile.match(/\d{3,3}-\d{3,3}-\d{4,4}|\d{10,10}|\d{3,3} \d{3,3} \d{4,4}/);
//postal code
var isPostal = document.form1.postal.value
var validatePostal = isPostal.match(/[a-zA-Z][0-9][a-zA-Z](-| |)[0-9][a-zA-Z][0-9]/)

for (var i=0; i < document.form1.length ; i++){
	if ( i < 11 ){
	
	document.form1[i].style.background='#FFF';
	}
}
for (var i=0; i < document.form1.length ; i++){
		if (document.form1[i].type == "text" && document.form1[i].value == ""){			
			if ( i != 6 && i != 7 ){
			//alert ("This field is required. Thank you.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1[i].focus();
			//break;
			}
		}if (document.form1[i].name == "pw" && document.form1[i].value == "") {
			//alert ("Please enter a valid email address.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1.email.focus();
			document.form1.email.select();
			//break;
		}if (document.form1[i].name == "pwcheck" && document.form1[i].value == "") {
			//alert ("Please enter a valid email address.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1.email.focus();
			document.form1.email.select();
			//break;
		}if (document.form1[i].name == "pw" && document.form1[i].value != "" && document.form1[i].value!=document.form1[i+1].value) {
			//alert ("Please enter a valid email address.");
			doNotSubmit = true;
			document.form1["pwcheck"].style.background='red';
			document.form1.email.focus();
			document.form1.email.select();
			//break;
		}if (document.form1[i].name == "email" && !validateEmail) {
			//alert ("Please enter a valid email address.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1.email.focus();
			document.form1.email.select();
			//break;
		}if (document.form1[i].name == "phone" && document.form1[i].value != "" && !validatePhone) {
			//alert ("Please format your phone number as: ###-###-####");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1[i].focus();
			//break;
		}if (document.form1[i].name == "mobile" && document.form1[i].value != "" && !validatePhone) {
			//alert ("Please format your mobile number as: ###-###-####");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1[i].focus();
			//break;
		}if (document.form1[i].name == "province" && document.form1[i].value == "") {
			//alert ("Please select your your province.");
			doNotSubmit = true;
			document.form1[i].style.border='#000 1px solid';
			document.form1[i].style.margin='0';
			document.form1[i].style.background='red';
			document.form1[i].focus();
			//break;
		}if (document.form1[i].name == "postal" && !validatePostal) {
			//alert ("Please select your your province.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1[i].focus();
			//break;
		/*}  if (document.form1[i].name == "code") {
			strCode = document.form1[i].value.toLowerCase()
			if(strCode != strCodeRnd){
			//alert ("Please select your your province.");
			doNotSubmit = true;
			document.form1[i].style.background='red';
			document.form1[i].focus();
			}
			//break;*/
		}if (document.form1[i].name == "doSurvey" && radioDoSurvey == "") {
			doNotSubmit = true;
			document.getElementById("surveyerror").style.backgroundColor="red";
			//break;
			
		} else if (document.form1[i].name == "doSurvey" && radioDoSurvey != ""){
		document.getElementById("surveyerror").style.backgroundColor="#ffffff";
		
		}if (document.form1[i].name == "doNewsletter" && radioDoNewsletter == "") {
			doNotSubmit = true;
			document.getElementById("newslettererror").style.backgroundColor="red";
                        //break;

		} else if (document.form1[i].name == "doNewsletter" && radioDoNewsletter != ""){
                    document.getElementById("newslettererror").style.backgroundColor="#ffffff";
                }

		if (document.form1[i].name == "regs" && document.form1[i].checked == false) {
		
			//alert ("You must agree to the contest rules and regulations");
			doNotSubmit = true;
			//document.form1[i].focus();
			document.getElementById("ruleserror").style.backgroundColor="red";
			//break;
			
	}if (document.form1[i].name == "regs" && document.form1[i].checked == true) {
		
			//alert ("You must agree to the contest rules and regulations");
			//doNotSubmit = false;
			//document.form1[i].focus();
			document.getElementById("ruleserror").style.backgroundColor="#ffffff";;
			//break;
		}
}

	// Please ensure the highlighted fields above are completed and submit again.
	
	if (doNotSubmit == false) {
                //document.form1.submit();
                return true;
	}else{
		document.getElementById('err02').style.display='block';
                return false;
	}
}

function validateLogin(){
	if (document.form2.email.value == "") {
	document.form2.email.style.background='red';
	document.form2.email.focus();
	document.getElementById('err01').innerHTML="Please ensure you've entered the correct email address and login again.";
        return false;
	}else{
	return true;
        //document.form2.submit();
	}
}
function openWin(val,w,h){
	var placeLeft = 100
	var placeTop = 100
	window.open(val,null,"height="+h+",width="+w+",screenX="+placeLeft+",left="+placeLeft+",screenY="+placeTop+",top="+placeTop+",scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no");
}

function checkEmail(myForm){
    var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
    var validateEmail = emailfilter.test(myForm.email.value);
    if(validateEmail){
        myForm.submit();
    } else {
        document.getElementById('errorText').innerHTML = '<span style="color:red;">ERROR – The email address you have entered is incorrect. Please verify and try again. </span>';
    }
}

function checkMatch(myForm){
    if (myForm.pw.value=='' || myForm.pwcheck.value==''){
        document.getElementById('errorText').innerHTML = '<span style="color:red;">ERROR – Please fill out all fields. </span>';
    }
    else if(myForm.pw.value != myForm.pwcheck.value){
        document.getElementById('errorText').innerHTML = '<span style="color:red;">ERROR - Passwords do not match. Please try again.</span>';
    } else {
        myForm.submit();
    }
}