//global vars
var EsuranceWebServerName = "www.esurance.com";
var EsuranceContentServerName = "web.esurance.com";


EsuranceContentServerName = "http://" + EsuranceContentServerName;
EsuranceWebServerName = "http://" + EsuranceWebServerName;

function DeleteCookie()
{
	window.location.href = EsuranceWebServerName+"/Welcome/Home/Homepage.aspx?sessionstatus=abandon";
}

function isZip() 
{
     // Check for correct zip code
	if(document.landingform.txtEnterKey != null)
	{
	
		if(document.landingform.txtEnterKey.value != "1")
		{
			var s="";
			if(document.landingform.txtZipCode!=null)
			{
				s = document.landingform.txtZipCode.value;
			}
			else if(document.landingform.zip1_txtZipCode!=null)
			{
				s = document.landingform.zip1_txtZipCode.value;
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				s = document.landingform.V1A_txtZipCode.value;
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				s = document.landingform.V1B_txtZipCode.value;
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				s = document.landingform.V2A_txtZipCode.value;
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				s = document.landingform.V2B_txtZipCode.value;
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				s = document.landingform.V3A_txtZipCode.value;
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				s = document.landingform.V3B_txtZipCode.value;
			}
			reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
			if (!reZip.test(s)) 
			{
				alert("Please enter a 5-digit numeric ZIP Code.");
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
			var s="";
			if(document.landingform.txtZipCode!=null)
			{
				s = document.landingform.txtZipCode.value;
			}
			else if(document.landingform.zip1_txtZipCode!=null)
			{
				s = document.landingform.zip1_txtZipCode.value;
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				s = document.landingform.V1A_txtZipCode.value;
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				s = document.landingform.V1B_txtZipCode.value;
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				s = document.landingform.V2A_txtZipCode.value;
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				s = document.landingform.V2B_txtZipCode.value;
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				s = document.landingform.V3A_txtZipCode.value;
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				s = document.landingform.V3B_txtZipCode.value;
			}
			
			reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
			if (!reZip.test(s)) 
			{
				alert("Please enter a 5-digit numeric ZIP Code.");
				return false;
			}
			else
			{
				return true;
			}
	}
}
function validateFieldsOnEnter(e)	
{
	var keynum;
	var keychar;
	var numcheck;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if(keynum == 13) 
	{
		var strZipCode ="";
		var prefix = "";
		if(document.landingform.txtZipCode!=null)
			{
				strZipCode = document.landingform.txtZipCode.value;
				prefix="";
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1A_txtZipCode.value;
				prefix= "V1A_";
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1B_txtZipCode.value;
				prefix = "V1B_";
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2A_txtZipCode.value;
				prefix = "V2A_";
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2B_txtZipCode.value;
				prefix = "V2B_";
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3A_txtZipCode.value;
				prefix = "V3A_";
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3B_txtZipCode.value;
				prefix = "V3B_";
			}

		if(document.getElementById(prefix + "txtAcctPwd").value == "" && strZipCode == "")
		{
			document.getElementById("txtEnterKey").value = "2";
		}
		else
			document.getElementById("txtEnterKey").value = "1";
		if(document.getElementById(prefix + "txtAcctPwd").value != "" && strZipCode != "")
		{
			document.getElementById("txtEnterKey").value = "1";
		}
		return validateFields('Validate');
    }
}

function nopassworderror()
{
	var strVal = "The email address you entered is not valid.";
	strVal = strVal + "\n\nPlease reenter and try again.";
	alert(strVal);
}

function submitForm() {
		var strZipCode
		if(document.landingform.txtZipCode!=null)
			{
				strZipCode = document.landingform.txtZipCode.value;
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1A_txtZipCode.value;
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1B_txtZipCode.value;
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2A_txtZipCode.value;
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2B_txtZipCode.value;
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3A_txtZipCode.value;
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3B_txtZipCode.value;
			}

                                        
        if ((strZipCode == "") || (isNaN(strZipCode)) || (strZipCode < 0 || strZipCode.length != 5) || (strZipCode.indexOf(".") != -1)) {
            window.location = "/";
        }
        else {
            document.landingform.submit();  
        }
}



function ClickEnter(btnName)
{      
	
	var evt = window.event;
	if (evt != null)
	{
		if (evt.keyCode==13)
		{ 		
			var btn;
			if(btnName != null)
			{
				if(document.getElementById(btnName)!=null)
				{
					btn = document.getElementById(btnName);
				}
				else if(document.getElementById("V1A_" + btnName)!=null)
				{
					btn= document.getElementById("V1A_" + btnName);
				}
				else if(document.getElementById("V1B_" + btnName)!=null)
				{
					btn = document.getElementById("V1B_" + btnName)
				}
				else if(document.getElementById("V2A_" + btnName)!=null)
				{
					btn = document.getElementById("V2A_" + btnName)
				}
				else if(document.getElementById("V2B_" + btnName)!=null)
				{
					btn = document.getElementById("V2B_" + btnName)
				}
				else if(document.getElementById("V3A_" + btnName)!=null)
				{
					btn = document.getElementById("V3A_" + btnName)
				}
				else if(document.getElementById("V3B_" + btnName)!=null)
				{
					btn = document.getElementById("V3B_" + btnName)
				}
		}
			else
			{
				if(document.getElementById(btnGoZip)!=null)
				{
					btn = document.getElementById(btnGoZip);
				}
				else if(document.getElementById("V1A_btnGoZip")!=null)
				{
					btn= document.getElementById("V1A_btnGoZip");
				}
				else if(document.getElementById("V1B_btnGoZip")!=null)
				{
					btn = document.getElementById("V1B_btnGoZip")
				}
				else if(document.getElementById("V2A_btnGoZip")!=null)
				{
					btn = document.getElementById("V2A_btnGoZip")
				}
				else if(document.getElementById("V2B_btnGoZip")!=null)
				{
					btn = document.getElementById("V2B_btnGoZip")
				}
				else if(document.getElementById("V3A_btnGoZip")!=null)
				{
					btn = document.getElementById("V3A_btnGoZip")
				}
				else if(document.getElementById("V3B_btnGoZip")!=null)
				{
					btn = document.getElementById("V3B_btnGoZip")
				}
			}				
			if (btn != null)
			{ 
				btn.click(); 
				return false; 
			} 
		}
	} 
}


function validateFields(TargetPage)	
{
	//	
	
	errorField = "";
	strValidationMsg = "";
	var strAcctEmail="";
	var acctEmail;
	var strAcctPwd="";
	var acctPwd;
			if(document.landingform.txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.txtAcctEmail.value;
				acctEmail = document.landingform.txtAcctEmail;
			}
			else if(document.landingform.V1A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V1A_txtAcctEmail.value;
				acctEmail = document.landingform.V1A_txtAcctEmail;
			}
			else if(document.landingform.V1B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V1B_txtAcctEmail.value;
				acctEmail = document.landingform.V1B_txtAcctEmail;
			}
			else if(document.landingform.V2A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V2A_txtAcctEmail.value;
				acctEmail = document.landingform.V2A_txtAcctEmail;
			}
			else if(document.landingform.V2B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V2B_txtAcctEmail.value;
				acctEmail = document.landingform.V2B_txtAcctEmail;
			}
			else if(document.landingform.V3A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V3A_txtAcctEmail.value;
				acctEmail = document.landingform.V3A_txtAcctEmail;
			}
			else if(document.landingform.V3B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V3B_txtAcctEmail.value;
				acctEmail = document.landingform.V3B_txtAcctEmail;
			}
	
			if(document.landingform.txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.txtAcctPwd.value;
				acctPwd = document.landingform.txtAcctPwd;
			}
			else if(document.landingform.V1A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V1A_txtAcctPwd.value;
				acctPwd = document.landingform.V1A_txtAcctPwd;
			}
			else if(document.landingform.V1B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V1B_txtAcctPwd.value;
				acctPwd = document.landingform.V1B_txtAcctPwd;
			}
			else if(document.landingform.V2A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V2A_txtAcctPwd.value;
				acctPwd = document.landingform.V2A_txtAcctPwd;
			}
			else if(document.landingform.V2B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V2B_txtAcctPwd.value;
				acctPwd = document.landingform.V2B_txtAcctPwd;
			}
			else if(document.landingform.V3A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V3A_txtAcctPwd.value;
				acctPwd = document.landingform.V3A_txtAcctPwd;
			}
			else if(document.landingform.V3B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V3B_txtAcctPwd.value;
				acctPwd = document.landingform.V3B_txtAcctPwd;
			}
	strAcctEmail = TrimString(strAcctEmail);
	
	if (TargetPage == "Validate") 
	{
		document.landingform.hdnTargetPage.value = "Validate";
		if(acctEmail!=null)
		{
			if(strAcctEmail!="" || strAcctEmail!="")
			{
				if (strAcctEmail == "")
				{
					strValidationMsg = strValidationMsg + "Please enter your email address and password. Then click \"Login.\"\n";
					errorField = acctEmail;
				}
				else 
				{	
					if (! isEmail(strAcctEmail))
					{
						if (document.landingform.AccountCreation) {
							strValidationMsg = strValidationMsg + "If you are creating a new account, please verify your password. If you already have an account, please check your email address to make sure that it is correct.";
						}
						else {
							strValidationMsg = strValidationMsg + "We don\'t have the email address you entered on file. Please double-check the address and try again.\n";
						}
							if (errorField == "") 
							{
								errorField = acctEmail;						
							}
					}
					else 
					{

						if (strAcctPwd == "")
						{
							strValidationMsg = strValidationMsg + "Please enter your password and click \"Login.\"\n";
							errorField = acctPwd;
						}
						else
						{
							/*if (document.landingform.txtAcctPwd.value.length < 4)
							{
								strValidationMsg = strValidationMsg + "The password you entered does not match the email address on file. Please re-enter it and try again.\n If you\'ve forgotten your password, click \"Forgot your password?\" and we\'ll send it to you right away.";
								errorField = document.landingform.txtAcctPwd;
							}*/
						}

					}
				}
			}
			else
			{
				if (strAcctEmail == "")
				{
					strValidationMsg = strValidationMsg + "Please enter your email address and password. Then click \"Login.\"\n";
					errorField = acctEmail;
				}
				else 
				{	
					if (! isEmail(strAcctEmail))
					{
						if (document.landingform.AccountCreation) {
							strValidationMsg = strValidationMsg + "If you are creating a new account, please verify your password. If you already have an account, please check your email address to make sure that it is correct.";
						}
						else {
							strValidationMsg = strValidationMsg + "We don\'t have the email address you entered on file. Please double-check the address and try again.\n";
						}
							if (errorField == "") 
							{
								errorField = acctEmail;						
							}
					}
					else 
					{

						if (strAcctPwd == "")
						{
							strValidationMsg = strValidationMsg + "Please enter your password and click \"Login.\"\n";
							errorField = acctPwd;
						}
						else
						{
							/*if (document.landingform.txtAcctPwd.value.length < 4)
							{
								strValidationMsg = strValidationMsg + "The password you entered does not match the email address on file. Please re-enter it and try again.\n If you\'ve forgotten your password, click \"Forgot your password?\" and we\'ll send it to you right away.";
								errorField = document.landingform.txtAcctPwd;
							}*/
						}

					}
				}
			}
		}	
	}
	
	if (TargetPage == "ForgetPass") 
	{
		document.landingform.hdnTargetPage.value = "ForgetPass";
		if (strAcctEmail == "")
		{
			strValidationMsg = strValidationMsg + "Please enter your email address and click \"Forgot your password?\" We\'ll email your password to you right away.\n";
			errorField = acctEmail;
		}
		else 
		{	
			if (! isEmail(strAcctEmail))
			{
				strValidationMsg = strValidationMsg + "We don\'t have the email address you entered on file. Please double-check the address and try again.\n";
					if (errorField == "") 
					{
						errorField = acctEmail;						
					}
			}
		}	
	}
			
	
	if (strValidationMsg == "")
	{
		if (TargetPage == "ForgetPass") 
		{ 
			str = window.location.host;
			if (str.toUpperCase() == "LOCALHOST")
			{
				strServer = "http://localhost/09-REL-05";
			}
			else
			{
				strServer = "http://"+str;
			}
			window.open(strServer + "/Welcome/common/Account/LoginHint.aspx?Email="+strAcctEmail+"&SessnId="+document.landingform.LCC1_SessionId.value,"_self");
		}
		
	} 
	else 
	{
		alert(strValidationMsg);		
		errorField.focus();
		if(TargetPage != 'ForgetPass')
			return false;
	}			
}	

function validateFieldsOriginal(TargetPage)	
{
	errorField = "";
	strValidationMsg = "";
	var strAcctEmail="";
	var acctEmail;
	var strAcctPwd="";
	var acctPwd;
			if(document.landingform.txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.txtAcctEmail.value;
				acctEmail = document.landingform.txtAcctEmail;
			}
			else if(document.landingform.V1A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V1A_txtAcctEmail.value;
				acctEmail = document.landingform.V1A_txtAcctEmail;
			}
			else if(document.landingform.V1B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V1B_txtAcctEmail.value;
				acctEmail = document.landingform.V1B_txtAcctEmail;
			}
			else if(document.landingform.V2A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V2A_txtAcctEmail.value;
				acctEmail = document.landingform.V2A_txtAcctEmail;
			}
			else if(document.landingform.V2B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V2B_txtAcctEmail.value;
				acctEmail = document.landingform.V2B_txtAcctEmail;
			}
			else if(document.landingform.V3A_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V3A_txtAcctEmail.value;
				acctEmail = document.landingform.V3A_txtAcctEmail;
			}
			else if(document.landingform.V3B_txtAcctEmail!=null)
			{
				strAcctEmail = document.landingform.V3B_txtAcctEmail.value;
				acctEmail = document.landingform.V3B_txtAcctEmail;
			}
	
			if(document.landingform.txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.txtAcctPwd.value;
				acctPwd = document.landingform.txtAcctPwd;
			}
			else if(document.landingform.V1A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V1A_txtAcctPwd.value;
				acctPwd = document.landingform.V1A_txtAcctPwd;
			}
			else if(document.landingform.V1B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V1B_txtAcctPwd.value;
				acctPwd = document.landingform.V1B_txtAcctPwd;
			}
			else if(document.landingform.V2A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V2A_txtAcctPwd.value;
				acctPwd = document.landingform.V2A_txtAcctPwd;
			}
			else if(document.landingform.V2B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V2B_txtAcctPwd.value;
				acctPwd = document.landingform.V2B_txtAcctPwd;
			}
			else if(document.landingform.V3A_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V3A_txtAcctPwd.value;
				acctPwd = document.landingform.V3A_txtAcctPwd;
			}
			else if(document.landingform.V3B_txtAcctPwd!=null)
			{
				strAcctPwd = document.landingform.V3B_txtAcctPwd.value;
				acctPwd = document.landingform.V3B_txtAcctPwd;
			}
											
	if (TargetPage == "Validate") {
		document.landingform.hdnTargetPage.value = "Validate";
	}
	else {
		document.landingform.hdnTargetPage.value = "ForgetPass";
	}
	if (strAcctEmail == ""){
		strValidationMsg = strValidationMsg + "Please enter your email address.\n";
		errorField = acctEmail;
	}
	else {	
		if (! isEmail(strAcctEmail)){
			strValidationMsg = strValidationMsg + "Your email address was not valid; please try again.\n";
				if (errorField == "") {
					errorField = acctEmail;						
				}
		}
		else {
			if (TargetPage != "ForgetPass") {
				if ((strAcctPwd == "")||(strAcctPwd.length < 4)){
					strValidationMsg = strValidationMsg + "Please enter a valid password that is at least 4 characters long.\n";
					errorField = acctPwd;
				}
			}
		}
	}			
	
	if (strValidationMsg == ""){
		document.landingform.submit();
	} 
	else {
		alert(strValidationMsg);
		errorField.focus();
	}			
}	
function isEmail(strData) {
	// Email address must be of form a@b.c -- in other words:
	// * there must be at least one character before the @
	// * there must be at least one character before and after the .
	// * the characters @ and . are both required
	var	iCtr,
		jCtr,
		sLength,
		atPos,
		cs,
		cTemp;
				
	if (isEmpty(strData))
		if (isEmail.arguments.length == 1)
			return false;
		else
			return (isEmail.arguments[1] == true);
		   
    if (isWhitespace(strData))
		return false;
		    
    iCtr = 1;
    sLength = strData.length;

    iCtr = strData.indexOf("@");
    atPos = iCtr;
		    
    if ( iCtr < 0 )
		return false;
	else 
		iCtr+=2;
			
	iCtr = strData.lastIndexOf(".");
    if ( iCtr < 0 )
		return false;
	else 
		iCtr++;			
			    
    if (iCtr > sLength)
		return false;
		    
    if(! isAlphanumeric(strData.substring( iCtr, strData.length)))
		return false;
			
	cTemp	= "";
	cs		= "";
	for(jCtr = atPos+1; jCtr < strData.length; jCtr++) {
		cTemp =  strData.charAt(jCtr);
		if( (cTemp != ".") && (cTemp != "-") )
			cs += cTemp;
	}
			
	if(! isAlphanumeric(cs))
		return false;
				
	return true;
}	

function isEmpty(strData) {
	return ((strData == null) || (strData.length == 0));
}

var whitespace = " \t\n\r";		
function isWhitespace(strData) {
	var iCtr,
		cTemp;

    if (isEmpty(strData))
		return true;

    for (iCtr = 0; iCtr < strData.length; iCtr++) {   
        var cTemp = strData.charAt(iCtr);
		if (whitespace.indexOf(cTemp) == -1)
			return false;
    }

    return true;
}


function isAlphanumeric(strData) {
	var iCtr,
		cTemp;

    if (isEmpty(strData)) 
		if (isAlphanumeric.arguments.length == 1)
			return false;
		else
			return (isAlphanumeric.arguments[1] == true);

	for (iCtr = 0; iCtr < strData.length; iCtr++) {
        cTemp = strData.charAt(iCtr);
        if (! (isLetter(cTemp) || isDigit(cTemp)))
			return false;
    }

    return true;
}

function isLetter(strData) {
	for (iCtr = 0; iCtr < strData.length; iCtr++) {
		cDigit = strData.charAt(iCtr);
	    if (! (((cDigit >= "a") && (cDigit <= "z")) || ((cDigit >= "A") && (cDigit <= "Z"))))
			return false;
	}
	return true;
}

function isDigit(strData) {
	if (strData==null) return false;
	for (iCtr = 0; iCtr < strData.length; iCtr++) {
		cDigit = strData.charAt(iCtr);
	    if ((cDigit < "0") || (cDigit > "9"))
			return false;
	}
	return true;
}
		
function oneClick()
	{
		if(document.getElementById) {
			document.getElementById('erin').style.backgroundColor = '#FFFFFF';
			document.getElementById('erin').style.width = '240px';
			document.getElementById('erin').style.left = '515px';
			document.getElementById('erin').style.top = '160px';
			document.getElementById('erin').style.border = '2px solid #FF3399';
			document.getElementById('erin').style.padding = '8px';
			document.getElementById('erin').style.visibility = 'visible';
		}
		else {
			window.open(strServer + '/Welcome/Home/homepage.aspx','esurance','width=200,height=300,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,screenX=50,screenY=500,top=50,left=500');
			}
	}

function award()
	{
		if(document.getElementById) {
			document.getElementById('award').style.backgroundColor = '#DCEDFF';
			document.getElementById('award').style.width = '500px';
			document.getElementById('award').style.left = '181px';
			document.getElementById('award').style.top = '448px';
			document.getElementById('award').style.border = '2px solid #003399';
			document.getElementById('award').style.padding = '8px';
			document.getElementById('award').style.visibility = 'visible';
		}
		else {
			window.open(strServer + '/Welcome/Home/homepage.aspx','esurance','width=500,height=325,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,screenX=0,screenY=0,top=0,left=0');
			}
	}
	
function shutit()
	{		
		if (document.getElementById) {
			document.getElementById('erin').style.visibility = 'hidden';
		}
	}     
	
function shutit_award()
	{		
		if (document.getElementById) {
			document.getElementById('award').style.visibility = 'hidden';
		}
	}    
	
function secure(){
	window.name = "main";
	window.open(EsuranceContentServerName + '/content/homepage/about_secure.asp','secure','width=500,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,screenX=0,screenY=0,top=0,left=0');
	
}

function checkEnterLogin(e)
{ 
	//e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	//document.forms[0].submit() //submit the form
		validateFields('Validate')
		return false 
	}
	else{
		return true 
	}
}

function checkEnterZipCode(e)
{ 
	//e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	//document.forms[0].submit() //submit the form
		 
		submitForm()
		//document.menuForm.ZipCode.focus();
		 
		return false 
	}
	else{
		 
		return true  
	}
}

function TrimString(str) 
{
	str = str.replace(/^[ ]+(.*)$/, '$1'); // Trims leading spaces
	str = str.replace(/^(.*)[ ]+$/, '$1'); // Trims trailing spaces
	return str;
}

function openNewWindow(theURL,winName,features) 
{
   theURL = EsuranceContentServerName + theURL;
  window.open(theURL,winName,features);
}

function openSecureLoginWindow()
	{
	  var freshurl= EsuranceContentServerName + '/content/ResourceCenter/SecureInfo.asp?pagetype=p';
	    SmallWin = window.open(freshurl, 'footerwindow','scrollbars=yes,resizable=yes,toolbar=no,height=450,width=471');

		if( ! isIE4() )
		{
            if (window.focus) {
                SmallWin.focus();
            }
		}

	    if (SmallWin.opener == null) SmallWin.opener = window;
            SmallWin.opener.name = "PUMain";
	}
   function openWindow(freshurl)
	{
		freshurl = EsuranceContentServerName + freshurl;
	    SmallWin = window.open(freshurl, 'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=480,width=471');

		if( ! isIE4() )
		{
            if (window.focus) {
                SmallWin.focus();
            }
		}

	    if (SmallWin.opener == null) SmallWin.opener = window;
            SmallWin.opener.name = "PUMain";
	}
	
   function openSizedWindow(freshurl, theWidth, theHeight, theLeft, theTop)
	{
	freshurl = EsuranceContentServerName + freshurl;
	    SmallWin = window.open(freshurl, 'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=' + theHeight + ' width=' + theWidth + ' left=' + theLeft + ' top=' + theTop);

		if( ! isIE4() )
		{
            if (window.focus) {
                SmallWin.focus();
            }
		}

	    if (SmallWin.opener == null) SmallWin.opener = window;
            SmallWin.opener.name = "PUMain";
	}
   
   function isIE4()
	{
		return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
	}
	
	   

function openWindowLarge(theURL,winName) 
		{ 
	//theURL = "http://www.esurance.com" + theURL;
  window.open(theURL,winName,'scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,height=480,width=800');

		}

function openFooterWindow(theURL,winName) 
{ 
	theURL = EsuranceWebServer + theURL;
	window.open(theURL,winName,'scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,height=480,width=800');

}
  
   function HelpInfo(DefNo) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/HelpInfo/HelpInfo.asp?DefNo=" + DefNo;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=375,height=400,alwaysRaised=yes') ;
	
     }

   function HelpInfo2() { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/QuoteBuilder/comparePop.asp";
	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=350,height=275,alwaysRaised=yes') ;
	
     }     

   function HelpInfo3(DefNo) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/HelpInfo/HelpInfo.asp?DefNo=" + DefNo;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=300,scrollbars=yes,width=800,height=570,alwaysRaised=yes') ;
	
     }
     
   function ClaimsPopup(No) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/ClaimsPopup/ClaimsPopup.asp?No=" + No;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=450,alwaysRaised=yes') ;
	
     }
      function TreesPopup(Name) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/TreesPopup/TreesPopup.asp?Name=" + Name;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=480,alwaysRaised=yes') ;
	
     }
	function TreePopup(Name) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/TreesPopup/TreesPopup.asp?Name=" + Name;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=355,alwaysRaised=yes') ;
	
     }
     
   function RaceSchedulePopup(No) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/RaceSchedulePopup/RaceSchedulePopup.asp?No=" + No;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,top=400,scrollbars=yes,width=400,height=480,alwaysRaised=yes') ;
		
     }
     
    function SpecialDealsPopup(No) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/SpecialDealsPopup/SpecialDealsPopup.asp?No=" + No;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=480,alwaysRaised=yes') ;
	
     }
   function MonolithRadio() { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName +"/Monolith/radio.asp?";

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=425,height=415,alwaysRaised=yes') ;
	
     }
     
   function HomeownersPopup(DefNo) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/HomeownersPopup/HomeownersPopup.asp?DefNo=" + DefNo;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=480,alwaysRaised=yes') ;
		
     }

	function HomepagePopup(DefNo) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/HomepagePopup/HomepagePopup.asp?DefNo=" + DefNo;

	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=400,height=480,alwaysRaised=yes') ;
		
     }
  
   function AvailableStatesPopup(DefNo) { 
     var strASPPage;
     
     	strASPPage=EsuranceContentServerName + "/Content/AvailableStatesPopup/AvailableStatesPopup.asp?DefNo=" + DefNo;
		
	    newWindow3 = window.open(strASPPage, 'newwindowWin3', 'toolbar=no,resizable=yes,location=no ,left=400,scrollbars=yes,width=550,height=480,alwaysRaised=yes') ;
	
     }
     
     function validateAccountChanges() 
			{
				strValidationMsg = "";
				errorField = "";
				sData = "";
				
				//validate email format
				if (document.frmChngAcctInf.accountEmail.value == "") 
				{	strValidationMsg = strValidationMsg + "Please enter an email address.\n";
					if (errorField == "")
						errorField = document.frmChngAcctInf.accountEmail;
				}
				else 
				{	if (! isEmail(document.frmChngAcctInf.accountEmail.value)) 
					{	strValidationMsg = strValidationMsg + "Your email address was not valid; please try again.\n";
						if (errorField == "")
							errorField = document.frmChngAcctInf.accountEmail;		
				
					}
				}
				
				//validate  old password
				if ((document.frmChngAcctInf.txtPwordOld.value != "")&&(document.frmChngAcctInf.txtPwordOld.value.length < 4)) 
				{	strValidationMsg = strValidationMsg + "Please enter your current password that is at least 4 characters long.\n";
					if (errorField == "")
					errorField = document.frmChngAcctInf.txtPwordOld;
				}
				else {
					
						if (document.frmChngAcctInf.txtPwordOld.value == ""){
							strValidationMsg = strValidationMsg + "Please enter your current password.\n";
							if (errorField == "")
							errorField = document.frmChngAcctInf.txtPwordOld;
						}				
					
				}
				//validate  password length
				if ((document.frmChngAcctInf.txtPword1.value != "")&&(document.frmChngAcctInf.txtPword1.value.length < 4)) 
				{	strValidationMsg = strValidationMsg + "Your password was too short; please use 4 or more characters and/or numbers.\n";
					if (errorField == "")
						errorField = document.frmChngAcctInf.txtPword1;
				}
				
				//check if password entered has both digits and letters
				sData = document.frmChngAcctInf.txtPword1.value
				if (sData != "")
				{
					if ((document.frmChngAcctInf.txtPword2.value != "")&&(document.frmChngAcctInf.txtPword2.value.length < 4)) 
					{
						strValidationMsg = strValidationMsg + "Please re-enter the password for verification.\n";
						if (errorField == "")
							errorField = document.frmChngAcctInf.txtPword2;
					}
					else 
					{	
						if (document.frmChngAcctInf.txtPword1.value != document.frmChngAcctInf.txtPword2.value) 
						{	
							strValidationMsg = strValidationMsg + "Your password entries did not match; please try again.\n";	 
							if (errorField == "")
								errorField = document.frmChngAcctInf.txtPword1;
						}
					}
				}
					
				//if error return message
				if (strValidationMsg == "")
				{	
					//document.frmChngAcctInf.submit();
					//alert("passed validate fields")
					return true; // true;
				}
				else 
				{	alert(strValidationMsg);
					if (errorField != "")
					errorField.focus();
					return false;
					
				}											
	
			
			}
			
			
		function submitForm1() 
			{
		
		var flg=false;
        var strZipCode
		if(document.landingform.txtZipCode!=null)
			{
				strZipCode = document.landingform.txtZipCode.value;
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1A_txtZipCode.value;
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V1B_txtZipCode.value;
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2A_txtZipCode.value;
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V2B_txtZipCode.value;
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3A_txtZipCode.value;
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				strZipCode = document.landingform.V3B_txtZipCode.value;
			}
                                        
        if ((strZipCode == "") || (isNaN(strZipCode)) || (strZipCode < 0 || strZipCode.length != 5) || (strZipCode.indexOf(".") != -1))
         {
			alert('Please enter valid zip code');
			var strZipCode
		if(document.landingform.txtZipCode!=null)
			{
				document.landingform.txtZipCode.select();
				document.landingform.txtZipCode.focus();
			}
			else if(document.landingform.V1A_txtZipCode!=null)
			{
				document.landingform.V1A_txtZipCode.select();
				document.landingform.V1A_txtZipCode.focus();
			}
			else if(document.landingform.V1B_txtZipCode!=null)
			{
				document.landingform.V1B_txtZipCode.select();
				document.landingform.V1B_txtZipCode.focus();
			}
			else if(document.landingform.V2A_txtZipCode!=null)
			{
				document.landingform.V2A_txtZipCode.select();
				document.landingform.V2A_txtZipCode.focus();
			}
			else if(document.landingform.V2B_txtZipCode!=null)
			{
				document.landingform.V2B_txtZipCode.select();
				document.landingform.V2B_txtZipCode.focus();
			}
			else if(document.landingform.V3A_txtZipCode!=null)
			{
				document.landingform.V3A_txtZipCode.select();
				document.landingform.V3A_txtZipCode.focus();
			}
			else if(document.landingform.V3B_txtZipCode!=null)
			{
				document.landingform.V3B_txtZipCode.select();
				document.landingform.V3B_txtZipCode.focus();
			}

            flg=false;
        }
 
        else {
            flg=true;
        }
        return flg;
}

		
