function validateFields(TargetPage)	
{
	//	
	errorField = "";
	strValidationMsg = "";
	
	document.frmLoginNamePass.accountEmail.value = TrimString(document.frmLoginNamePass.accountEmail.value);
								
	if (TargetPage == "Validate") 
	{
		document.frmLoginNamePass.hdnTargetPage.value = "Validate";
		if (document.frmLoginNamePass.accountEmail.value == "")
		{
			strValidationMsg = strValidationMsg + "Please enter your email address and password. Then click \"Login.\"\n";
			errorField = document.frmLoginNamePass.accountEmail;
		}
		else 
		{	
			if (! isEmail(document.frmLoginNamePass.accountEmail.value))
			{
				if (document.frmLoginNamePass.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 = document.frmLoginNamePass.accountEmail;						
					}
			}
			else 
			{

				if (document.frmLoginNamePass.txtPword.value == "")
				{
					strValidationMsg = strValidationMsg + "Please enter your password and click \"Login.\"\n";
					errorField = document.frmLoginNamePass.txtPword;
				}
				else
				{
					if (document.frmLoginNamePass.txtPword.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.frmLoginNamePass.txtPword;
					}
				}

			}
		}	
	}
	if (TargetPage == "ForgetPass") 
	{
		document.frmLoginNamePass.hdnTargetPage.value = "ForgetPass";
		if (document.frmLoginNamePass.accountEmail.value == "")
		{
			strValidationMsg = strValidationMsg + "Please enter your email address and click \"Forgot your password?\" We\'ll email your password to you right away.\n";
			errorField = document.frmLoginNamePass.accountEmail;
		}
		else 
		{	
			if (! isEmail(document.frmLoginNamePass.accountEmail.value))
			{
				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 = document.frmLoginNamePass.accountEmail;						
					}
			}
		}	
	}
			
	
	if (strValidationMsg == "")
	{
		if (TargetPage == "ForgetPass") { 
			document.frmLoginNamePass.action = "/memberacct/loginhint.asp";
		}
		document.frmLoginNamePass.submit();
	} 
	else 
	{
		alert(strValidationMsg);
		errorField.focus();
	}			
}	

function validateFieldsOriginal(TargetPage)	
{
	errorField = "";
	strValidationMsg = "";
								
	if (TargetPage == "Validate") {
		document.frmLoginNamePass.hdnTargetPage.value = "Validate";
	}
	else {
		document.frmLoginNamePass.hdnTargetPage.value = "ForgetPass";
	}
	if (document.frmLoginNamePass.accountEmail.value == ""){
		strValidationMsg = strValidationMsg + "Please enter your email address.\n";
		errorField = document.frmLoginNamePass.accountEmail;
	}
	else {	
		if (! isEmail(document.frmLoginNamePass.accountEmail.value)){
			strValidationMsg = strValidationMsg + "Your email address was not valid; please try again.\n";
				if (errorField == "") {
					errorField = document.frmLoginNamePass.accountEmail;						
				}
		}
		else {
			if (TargetPage != "ForgetPass") {
				if ((document.frmLoginNamePass.txtPword.value == "")||(document.frmLoginNamePass.txtPword.value.length < 4)){
					strValidationMsg = strValidationMsg + "Please enter a valid password that is at least 4 characters long.\n";
					errorField = document.frmLoginNamePass.txtPword;
				}
			}
		}
	}			
	
	if (strValidationMsg == ""){
		document.frmLoginNamePass.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('/Home/homepage/about_erin.asp','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('/Home/homepage/about_award.asp','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('/Home/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) {
  window.open(theURL,winName,features);
}