// JavaScript Document
function hidezip(Formvalue)
{
	if (Formvalue=='United States')
	{
		var emailvalue=document.getElementById('Zip').value;

		if (emailvalue =='')
		{
			emailvalue='5 Digit Zip Code - US Only';
		}
		document.getElementById('Zip').disabled=false;
	}else{
		if (emailvalue =='')
		{
		emailvalue='5 Digit Zip Code - US Only';
		}
		document.getElementById('Zip').disabled=true;
	}
}
function SubmitEmail()
{
	var errTxt='';
	if(!checkEmail())
	{
		errTxt+='Please enter a valid email\n';
	}
	
	if(!validateZIP())
	{	
		if(document.getElementById('country').value=='United States')
		{
		errTxt+='Please enter a valid 5 digit Zip code\n';
		}
	}
	
	
	if(errTxt!='')
	{
		alert(errTxt);
	}else{
	//pass form.
	document.frmMail.submit();
	}
	
}

function CheckUrl(url)
{

 var mySplitResult = url.split("?");
  	if(mySplitResult.length > 1)
	   {
	 if (mySplitResult[1] !='')
	 {
		 var splitEmail = mySplitResult[1].split("=");
	
		if (splitEmail[0]=='email')
					   {
						   document.getElementById('Email').value=splitEmail[1];
					   }
	 }
	   }
}

function checkEmail() {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('Email').value)){
return (true)
}

return (false)
}


function validateZIP() {
var field=	document.getElementById('Zip').value;
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {

return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {

return false;
   }
}
return true;
}
function verifyUnsub() {
    var errTxt = '';
    if (!checkEmailunsub()) {
        errTxt += 'Please enter a valid email\n';
    }




    if (errTxt != '') {
        alert(errTxt);
    } else {
        document.form1.submit()
    }
    function checkEmailunsub() {
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email_field_200a').value)) {
            return (true)
        }

        return (false)
    }

}

function ClearEmail()
{

	if(document.getElementById('Email').value =='Your Email Here')
	{
		document.getElementById('Email').value ='';
	
	}
}

function ClearEmailUnsub()
{

	if(document.getElementById('email_field_200a').value =='Your Email Here')
	{
		document.getElementById('email_field_200a').value ='';
	}
	
}


function CheckUrlUnsub(url) {

    var mySplitResult = url.split("?");

    if (mySplitResult.length > 1) {
        var splitvars = mySplitResult[1].split("&");
        if (splitvars.length > 0) {

            for (var i = 0; i <= splitvars.length-1; i++) {
                var splitEmail = splitvars[i].split("=");
                if (splitEmail[0] == 'email') {
                    document.getElementById('email_field_200a').value = splitEmail[1];
                }
                if (splitEmail[0] == 'esp_job_id') {
                    document.getElementById('esp_job_id').value = splitEmail[1];
                }
            }



        } else {

            if (mySplitResult[1] != '') {
                var splitEmail = mySplitResult[1].split("=");

                if (splitEmail[0] == 'email') {
                    document.getElementById('email_field_200a').value = splitEmail[1];
                }
            }
        }
    }
}
