// This script will render the Allstate master header for any page needing it.
//
// The master header consists of the top banner of the page, the navigation bar, the thin
// white spacer below the navigation bar and optionally the blue bar.
//
// Note that there are two terms used through the documentation and script:
//		1)	Calling Site -	The site from which this script is called and needing a header.
//		2) Source Site  -	The site from which the images, includes, etc. are retrieved from.
//
// The only public method of this script is BuildHeaderHtml.
//
// There are five global JavaScript variables that can be set prior to including this file:
//		1)	gsSourceWebSite is intended to either be set to LocalHost or not to be set at all.
//			If not set at all, then the calling site will retrieve all images, includes, etc.
//			from allstate.com.
//			If set to LocalHost, the BuildHeaderHtml method will get any images, includes, etc.
//			from the calling site:
//				/Images/AllNavProductsOn_Btn.gif				/Images/AllNavProductsOff_Btn.gif		
//         	/Images/AllNavCareOn_Btn.gif           	/Images/AllNavCareOff_Btn.gif    
//         	/Images/AllNavAgentOn_Btn.gif          	/Images/AllNavAgentOff_Btn.gif   
//         	/Images/AllNavFinancialOn_Btn.gif        	/Images/AllNavFinancialOff_Btn.gif 
//         	/Images/AllNavBankOn_Btn.gif          	/Images/AllNavBankOff_Btn.gif   
//         	/Images/AllHeadMap_Btn.gif						
//				/images/AllHeadLogo_Img.gif					/Images/ClearSpacer.gif
//				/images/AllHeadSplash1_Img.jpg				/Images/AllHeadSplash2_Img.jpg
//				/images/AllHeadFinanceLogoImg.gif			/Includes/General.css
//		2-4)	gsApplAllstate, gsApplBank, gsApplAgent and gsApplCustCare should only be set for
//				for when allstate, customercare and agent are the calling website.
//			
//	The MainHeader.inc for allstate, agent and customercare would look like:
//
//		<SCRIPT LANGUAGE="JavaScript">                       
//       	var gsApplAllstate="<%=Application("Allstate")%>";
//       	var gsApplBank="<%=Application("Bank")%>";
//       	var gsApplAgent="<%=Application("Agent")%>";      
//       	var gsApplCustCare="<%=Application("CustCare")%>";
//       	var gsSourceWebSite="LocalHost";                  
//    </SCRIPT>	                                         
//
//		<SCRIPT TYPE="text/JavaScript" SRC="/includes/MainHeader.js"></SCRIPT>
//
//		and to use it would be as follows:
//
//		<!-- ***************************************************************** -->
//		<!--#INCLUDE virtual="/includes/MainHeader.inc" -->                       
//		<!-- ***************************************************************** -->
//
//	For external sites all that would be needed would be:
//	 	<!-- ***************************************************************** -->
// 	<SCRIPT TYPE="text/JavaScript" SRC="http://www.allstate.com/includes/MainHeader.js"></SCRIPT>                       
// 	<SCRIPT LANGUAGE="JavaScript">                                            
//			BuildHeaderHtml(BTTN_TOOLS,true)                                        
//  	</SCRIPT>                                                                 
//   	<!-- ***************************************************************** -->
               
// Initialize some variables.
var BTTN_NONE = 0;
var BTTN_PRODUCTS = 10;
var BTTN_CUST_CARE = 20;
var BTTN_AGENT = 30;
var BTTN_FINANCIAL = 40;
var BTTN_TOOLS = 50;
var BTTN_BANK = 60;
var blnPopupTargetSurvey;
var iHdrPopId;
var sectionID = -1;
var spanish = "spanish";


// If the calling site did not set the following three variables, then we shall set them here.
if (!gbAWSFlag)
	var gbAWSFlag=false;
	
if (!gsApplAllstate)
	var gsApplAllstate="www.allstate.com";

if (!gsApplBank)
	var gsApplBank="www.allstatebank.com";

if (!gsApplCustCare)
	var gsApplCustCare="customercare.allstate.com";

if (!gsApplAgent)
	var gsApplAgent="agent.allstate.com";

if (!gsProdURL)
	var gsProdURL="";
	
if (!gsApplInsurance)
	var gsApplInsurance="insurance.allstate.com";

if (!gsApplAutoInsurance)
	var gsApplAutoInsurance="auto-insurance.allstate.com";

if (!gsApplHomeInsurance)
	var gsApplHomeInsurance="home-insurance.allstate.com";
	
if (!gsApplLifeInsurance)
	var gsApplLifeInsurance="life-insurance.allstate.com";	
	
if (!gsApplCarInsuranceQuote)
	var gsApplCarInsuranceQuote="car-insurance-quote.allstate.com";
	
if (!gsApplHomeInsuranceQuote)
	var gsApplHomeInsuranceQuote="home-insurance-quote.allstate.com";
			
// Set where the calling site should get it's images, includes, general.css, etc.

if (gsSourceWebSite)
{
	if (gsSourceWebSite.toUpperCase() == "LOCALHOST")
		gsSourceWebSite = "";
	else
		gsSourceWebSite = document.location.protocol + "//" + gsApplAllstate;
}
else
	var gsSourceWebSite = document.location.protocol + "//" + gsApplAllstate;

DisplayAWSHeaderFooter();
	
function WindowPopUp(piHeight, piWidth, piTop, piLeft, piScrollBars, piResizeable, psURL) 
{
	objAgent = navigator.userAgent;
	
	sWindowName = "";
	
	sParams  = "";
	sParams += "toolbar=0,";
	sParams += "location=0,";
	sParams += "directories=0,";
	sParams += "status=0,";
	sParams += "menubar=0,"; 
	sParams += "scrollbars=" + piScrollBars + ",";
	sParams += "resizable=" + piResizeable + ",";
	sParams += "top=" + piTop + ",";
	sParams += "left=" + piLeft + ",";
	sParams += "height=" + piHeight + ",";
	sParams += "width=" + piWidth;			
   		
	// AOL on Windows 95 & 98 does not support setting a window to a var 
	if ((objAgent.indexOf("AOL") != -1) && ((objAgent.indexOf("Windows 98") != -1) || (objAgent.indexOf("Windows 95") != -1)))
	{
		window.open(psURL, sWindowName , sParams);
	} 
	else 
	{
		var win = window.open(psURL, sWindowName, sParams);
		
		// Set the focus to the pop-up window.
		if (win) 
		{
			win.focus();
		}
	}
}	

function LoadNewImage(sImgFilePath)
{
	imgNew = new Image();
	imgNew.src = sImgFilePath;
	return imgNew;
}

function ChangeImage(sID, sImgFilePath)
{
	document[sID].src = sImgFilePath;
}


function ChangeColorOver(sID)
{
	document.getElementById(sID).color = "#04379A";
}

function ChangeColorOut(sID)
{
	document.getElementById(sID).color = "#4C4B4B";
}


function ICTGetCookie (psTargetCookieName, psOptionalCookiesToSrch) 
{
	// The parameters are case insensitive.
	
	var sResult = null;
	
	if (!psOptionalCookiesToSrch) {
		// The optional parameter was omitted.
		var sAllCookies = "; " + document.cookie + ";";
		var sCookieDelim = "; ";
	}
	else
	{
		var sAllCookies = "&" + psOptionalCookiesToSrch + "&";
		var sCookieDelim = "&";
	}
	
	var sAllCookiesLower = sAllCookies.toLowerCase();
	
	var psTargetCookieName = sCookieDelim + psTargetCookieName.toLowerCase() + "=";
	var iTargetCookieStart = sAllCookiesLower.indexOf(psTargetCookieName);
	var iTargetCookieEnd;

	if (iTargetCookieStart != -1) {
		iTargetCookieStart += psTargetCookieName.length;
		iTargetCookieEnd = sAllCookiesLower.indexOf(sCookieDelim, iTargetCookieStart);
		sResult = unescape(sAllCookies.substring(iTargetCookieStart, iTargetCookieEnd));
	}
	
	return sResult;
}

function parseCookie(name) {
  var str = ""
  var a = document.cookie.split(";")
  for (var i=0; i<a.length; i++) {
    a[i] = a[i].replace(/(^\s*)|(\s*$)/g, "");
    if (a[i].substring(0,name.length) == name)
      str = a[i].substring(name.length+1)
      str = unescape(str)
  }
  var a = str.split("&")
  var obj = new Object()
  if (str.length)
    for (i=0; i<a.length; i++) {
      temp = a[i].split("=")
      obj[temp[0]] = temp[1]
    } return obj
}

function addToCookie(cookieName,key,value) {
  var cookies = parseCookie(cookieName)
  cookies[key] = value
  var d = new Date()
  d.setFullYear(d.getFullYear()+1)
  var cookieStr = cookieName + "="
  for (var item in cookies)
    cookieStr += item + "=" + cookies[item] + "&"
  cookieStr = cookieStr.substring(0,cookieStr.length-1)
  //cookieStr = cookieStr + "; expires=" + d.toUTCString()
  cookieStr = cookieStr + "; path=/"

 if ( cookieName.indexOf("AWSNav") > -1 || cookieName.indexOf("AWSFlag") > -1)
 {
  	cookieStr += "; domain=allstate.com"
 }

 document.cookie = cookieStr

}

function getCookie(name,key) {
  var cookies = parseCookie(name)
  return cookies[key]
}

function AWSGetCookie (psTargetCookieName, psOptionalCookiesToSrch) 
{
	// The parameters are case insensitive.
	
	var sResult = "";
	
	if ((psTargetCookieName == "AWSFlag"))
	{
		if (!psOptionalCookiesToSrch) {
			// The optional parameter was omitted.
			var sAllCookies = "; " + document.cookie + "; ";
			var sCookieDelim = "; ";
		}
		else
		{
			var sAllCookies = "&" + psOptionalCookiesToSrch + "&";
			var sCookieDelim = "&";
		}
		
		var sAllCookiesLower = sAllCookies.toLowerCase();
		
		var psTargetCookieName = sCookieDelim + psTargetCookieName.toLowerCase() + "=";
		var iTargetCookieStart = sAllCookiesLower.indexOf(psTargetCookieName);
		var iTargetCookieEnd;

		if (iTargetCookieStart != -1) {
			iTargetCookieStart += psTargetCookieName.length;
			iTargetCookieEnd = sAllCookiesLower.indexOf(sCookieDelim, iTargetCookieStart);
			sResult = unescape(sAllCookies.substring(iTargetCookieStart, iTargetCookieEnd));
		}
	}
	else
	{
		sResult = getCookie("AWSNav",psTargetCookieName)
		if (sResult==null)
			sResult="";
	}
	
	return sResult;
}

function ICTGetSubCookie (psTargetCookieName, psSubCookieName) 
{
	// The parameter is case insensitive.
	
	var sResult = null;
	
	sResult = ICTGetCookie(psSubCookieName, ICTGetCookie(psTargetCookieName));
	
	return sResult;
}

function GetQueryString (psTargetQSName) 
{
	// The parameter is case insensitive.
	
	var sResult = null;
	if (psTargetQSName == "AgentName" || psTargetQSName == "LName" || psTargetQSName == "Calc")
	{
		var sAllQSs = document.location.search + "&";
		var psTargetQSName = psTargetQSName + "=";
	}
	else
	{
		var sAllQSs = document.location.search.toLowerCase() + "&";
		var psTargetQSName = psTargetQSName.toLowerCase() + "=";
	}
	
	var iTargetQSStart = sAllQSs.indexOf(psTargetQSName);
	var iTargetQSEnd;
		
	if (iTargetQSStart != -1) {
		iTargetQSStart += psTargetQSName.length;
		iTargetQSEnd = sAllQSs.indexOf("&", iTargetQSStart);
		sResult = unescape(sAllQSs.substring(iTargetQSStart, iTargetQSEnd));
	}
	
	return sResult;
}

function DisplayAWSHeaderFooter(){
	
	if (gbAWSFlag == true)
	{	
		var currURL = document.location.href.toLowerCase();
		
		if ( currURL.indexOf("leadfusion.com") > 0 )
		{
			//Indicate that the section is planning tools
			sectionID = 4;
			var refURL = document.referrer.toLowerCase();
			if ( GetDomain(refURL) != GetDomain(currURL) )
			{
				document.cookie = "AWSFlag=N" + "; path=/; domain=allstate.com";
				PopulateAWSCookie();
			}
		}
		else
		{
			//init AWSFlag=N on pages where the AWS passes agent query string values.	
			// 5/17/2004 added some more to correct USD#9043877 - cjf		
			if ( (currURL.indexOf("auto/intro.asp?a=1") > 0) ||
				//06-08-2004-Added for olympic project 
				(currURL.indexOf("auto/qqinfo.asp?a=1&m=50") > 0) || 
				//End olympic add
				(currURL.indexOf("prop/intro.asp?a=1") > 0) ||
				(currURL.indexOf("prop/login.asp?a=1") > 0) ||
				(currURL.indexOf("efs_processemail.asp?a=1") > 0) ||
				(currURL.indexOf("ahp_processemail.asp?a=1") > 0) ||
				(currURL.indexOf("rfp_contactinfo.asp?a=1") > 0) ||
				(currURL.indexOf("rfp_preprocessemail.asp") > 0) )	
			{
				document.cookie = "AWSFlag=N" + "; path=/; domain=allstate.com";
			}	
			PopulateAWSCookie();
		}
	}
	else
	{
		document.cookie = "AWSFlag=N" + "; path=/; domain=allstate.com";
	}	
}

function DisplayAWSCalcHeader(){
	
	var currURL = document.location.href.toLowerCase();
	
	if (currURL.indexOf("leadfusion.com") > 0)
	{
	
		//USD - 32858
		if ((AWSGetCookie("AWSFlag") == "Y") && (gbAWSFlag == true))	
		//if (AWSGetCookie("AWSFlag") == "Y")
		{	
		document.write('<TABLE cellspacing=0 cellpadding=0 border=0 width=778px>');
			document.write('<TR>');
				document.write('<TD width=15px>');
					document.write('&nbsp;');
				document.write('</TD>');
				document.write('<TD>');
					document.write('<FONT style="FONT-SIZE: 10px; FONT-FAMILY: Arial; Color: #000000"><br>');
					document.write('<a href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/PlanningTools">PlanningTools</a>');
					document.write(' / ' + (AWSGetCookie("Calc")) + '</font><br>');
				document.write('</TD>');
			document.write('</TR>');
			document.write('<TR>');
				document.write('<td colspan=2 height=17px>');
						document.write('<IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=156>');
					document.write('</TD>');
			document.write('</TR>');
			document.write('<TR>');
				document.write('<TD width=15px>');
					document.write('&nbsp;');
				document.write('</TD>');
				document.write('<TD>');
					document.write('<FONT style="FONT-SIZE: 18px; FONT-FAMILY: Arial; Color: #7D1717">Planning Tools</font>');
				document.write('</TD>');
			document.write('</TR>');
			document.write('<TR>');
			document.write('<td colspan=2 height=14px >');
						document.write('<IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=156>');
					document.write('</TD>');
			document.write('</TR>');
		document.write('</TABLE>');

		document.write('<TABLE cellspacing=0 cellpadding=0 border=0 width=778px>');
			document.write('<TR>');
				document.write('<TD width=15px>');
					document.write('&nbsp;');
				document.write('</TD>');
				document.write('<TD align=left vAlign=top width=778px>');
		}
		else
		{
			document.write('<TABLE cellspacing=0 cellpadding=0 border=0 width=778px>');
			document.write('<TR>');
				document.write('<TD align=center vAlign=top width=778px>');
		
		}
					document.write('<FONT style="FONT-SIZE: 11px; FONT-FAMILY: Arial; Color: #000000">Please see the <b>Important Note </b> below that includes, among other items, information regarding rates of return, the applicability of this tool, and the value of obtaining personal advice from qualified professionals.</font>');
				document.write('</TD>');
			document.write('</TR>');
		document.write('</TABLE>');
	
	}

}

function GetDomain(URL){
	var sDomain;
	var iDomainStart;
	var iDomainEnd;

	if (URL != "" || URL != null)	
	{
		iDomainStart = URL.indexOf("//");
		iDomainEnd = URL.indexOf("/", iDomainStart + 2);
			
		sDomain = unescape(URL.substring(iDomainStart + 2, iDomainEnd));
	}
	
	return sDomain;	
}

function PopulateAWSCookie(){				
<!-- If AWSFlag is not set to "Y" read query string and set agent web site cookies. -->
	if (AWSGetCookie("AWSFlag") != "Y")
	{	
		var stmpcookie
		//Assign Customer friendly e-mail address (CFEA) 	
		addToCookie("AWSNav","CFEA",(GetQueryString("cfea")))
		//Assign agent type
		stmpcookie = "agenttype=" + (GetQueryString("agenttype"))
		document.cookie = stmpcookie + "; path=/"
		addToCookie("AWSNav","AgentType",(GetQueryString("agenttype")))
		//Assign PFR indicator	
		addToCookie("AWSNav","PFR",(GetQueryString("pfr")))
		//Assign agent name 	
		addToCookie("AWSNav","AgentName",(GetQueryString("AgentName")))
		//Assign agent phone 
		stmpcookie = "AgentPhone=" + (GetQueryString("agentphone"))
		document.cookie = stmpcookie  + "; path=/"
		addToCookie("AWSNav","AgentPhone",(GetQueryString("agentphone")))

		//Assign agent license states 
		if (GetQueryString("lstate") != null)
		{
			addToCookie("AWSNav","LicenseState",(GetQueryString("lstate").toUpperCase()))
		}
		else
		{
			//document.cookie = "LicenseState=";
			addToCookie("AWSNav","LicenseState","")
		}
		//Assign agent license numbers 
		addToCookie("AWSNav","LicenseNum",(GetQueryString("lnum")))
		//Assign agent license name 
		addToCookie("AWSNav","LicenseName",(GetQueryString("LName")))
		//Assign BinderID for bread crumbs 
		addToCookie("AWSNav","BinderID",(GetQueryString("binderid")))
		//Assign ProductID for bread crumbs 
		addToCookie("AWSNav","ProdID",(GetQueryString("prodid")))
		//Assign Calc for Calculator breadcrumbs
		addToCookie("AWSNav","Calc",(GetQueryString("Calc")))

		if (GetQueryString("awsflag") == "y")
		{
			document.cookie = "AWSFlag=Y" + "; path=/; domain=allstate.com";
			ConvertStateAbbrevations()
		}
	}	
}

function ConvertStateAbbrevations () 
{	
	//used for AWS in footer.js 
	var sLicStateList = (AWSGetCookie("LicenseState"));
	var sLicStateLong = "";
	var spacer = "";
	
	if ((sLicStateList != "") || (sLicStateList != null))
	{	
		//only one value given
		if (sLicStateList.indexOf(",")== -1)
		{
		  sLicStateLong = GetFullNameofState(sLicStateList);
		  addToCookie("AWSNav","OfficeState",sLicStateLong)
		  addToCookie("AWSNav","OfficeStateCd",sLicStateList)
		}
		else
		{	
			//populate values in to array 
			var State_array=sLicStateList.split(",");
			var i=0;
			
			addToCookie("AWSNav","OfficeState",(GetFullNameofState(State_array[0])))
			addToCookie("AWSNav","OfficeStateCd",(State_array[0]))
			
			while (i < State_array.length)
			{	
				if (i == 0)
				{
					spacer = "";
				}
				else
				{
					if (i == (State_array.length - 1))
					{
						spacer = " and ";
					}
				}
				
				if ((i != 0) && (i != (State_array.length - 1)))
				{
					{spacer = ", ";}
				}
				
				sLicStateLong = (sLicStateLong + spacer+ GetFullNameofState(State_array[i]));
				i+=1;	
			}
		}
		addToCookie("AWSNav","LicStateListLong",(sLicStateLong))
		
	}
}

function DetermineStateLicNum(sState)
{	
	//used for AWS in footer.js 
	var sLicStateList = (AWSGetCookie("LicenseState"));
	var sLicNumList = (AWSGetCookie("LicenseNum"));
	var sLicNum ="";
	
	if ((sLicStateList != "") || (sLicStateList != null) || (sLicNumList != "") || (sLicNumList != null))
	{	
		//only one value given
		if (sLicStateList.indexOf(",")== -1)
		{
		  sLicNum = (AWSGetCookie("LicenseNum"));
		}
		else
		{	
			//populate values in to array 
			var State_array=sLicStateList.split(",");
			var LicNum_array=sLicNumList.split(",");
			var i=0;
			
			if (State_array.length == LicNum_array.length)
			{ 
				while (i < State_array.length)
				{	
					if (State_array[i] == sState)
					{
						sLicNum = LicNum_array[i];
						break
					}
					i+=1;	
				}
			}	
		}
	}
	
	return sLicNum;
}

function DetermineStateLicName(sState)
{	
	//used for AWS in footer.js 
	var sLicStateList = (AWSGetCookie("LicenseState"));
	var sLicNameList = (AWSGetCookie("LicenseName"));
	var sLicName = "";
	
	if ((sLicStateList != "") || (sLicStateList != null) || (sLicNameList != "") || (sLicNameList != null))
	{	
		//only one value given
		if (sLicStateList.indexOf(",")== -1)
		{
		  sLicName = (AWSGetCookie("LicenseName"));
		}
		else
		{	
			//populate values in to array 
			var State_array=sLicStateList.split(",");
			var LicName_array=sLicNameList.split(",");
			var i=0;
			
			if (State_array.length == LicName_array.length)
			{
				while (i < State_array.length)
				{	
				if (State_array[i] == sState)
				{
					sLicName = LicName_array[i];
					break
				}
					i+=1;	
				}
			}
		}
	}
	
	return sLicName;
}

function DetermineIfMAIState () 
{
	var sMAIStateList = "AL,AZ,CA,CO,CT,FL,GA,IL,IN,KS,KY,LA,MD,MI,MS,MO,NJ,NM,NY,NC,OH,OK,OR,PA,SC,TN,TX,UT,VA,WI";
	var bMAIState = false;
	var sLicStateList = (AWSGetCookie("OfficeStateCd"));
	
	if ((sLicStateList != "") || (sLicStateList != null))
	{	
		//only one value given
		if (sLicStateList.indexOf(",")== -1)
		{
			if (sMAIStateList.indexOf(sLicStateList) != -1)
				{
					bMAIState = true;
				}
		}
		else
		{	
			//populate values in to array 
			var State_array=sLicStateList.split(",");
			var i=0;
			
			while (i < State_array.length)
			{	
				if (sMAIStateList.indexOf(State_array[i]) != -1)
				{	
					bMAIState = true;
					break
				}
				i+=1;	
			}
		}
	}
	
	return bMAIState;
}

function GetFullNameofState(sState) 
{	
	switch(sState)
	{ 
	case 'AL': 
		sState = "Alabama";
		break
	case 'AK': 
		sState = "Alaska";
		break
	case 'AZ': 
		sState = "Arizona";
		break
	case 'AR': 
		sState = "Arkansas";
		break
	case 'CA': 
		sState = "California";
		break
	case 'CO': 
		sState = "Colorado";
		break
	case 'CT': 
		sState = "Connecticut";
		break
	case 'DE': 
		sState = "Delaware";
		break
	case 'DC': 
		sState = "District of Columbia";
		break
	case 'FL': 
		sState = "Florida";
		break
	case 'GA': 
		sState = "Georgia";
		break
	case 'HI': 
		sState = "Hawaii";
		break
	case 'ID': 
		sState = "Idaho";
		break
	case 'IL': 
		sState = "Illinois";
		break
	case 'IN': 
		sState = "Indiana";
		break
	case 'IA': 
		sState = "Iowa";
		break
	case 'KS': 
		sState = "Kansas";
		break
	case 'KY': 
		sState = "Kentucky";
		break
	case 'LA': 
		sState = "Louisiana";
		break
	case 'ME': 
		sState = "Maine";
		break	
	case 'MD': 
		sState = "Maryland";
		break
	case 'MA': 
		sState = "Massachusetts";
		break	
	case 'MI': 
		sState = "Michigan";
		break	
	case 'MN': 
		sState = "Minnesota";
		break
	case 'MS': 
		sState = "Mississippi";
		break
	case 'MO': 
		sState = "Missouri";
		break
	case 'MT': 
		sState = "Montana";
		break
	case 'NE': 
		sState = "Nebraska";
		break
	case 'NV': 
		sState = "Nevada";
		break
	case 'NH': 
		sState = "New Hampshire";
		break	
	case 'NJ': 
		sState = "New Jersey";
		break
	case 'NM': 
		sState = "New Mexico";
		break	
	case 'NY': 
		sState = "New York";
		break
	case 'NC': 
		sState = "North Carolina";
		break
	case 'ND': 
		sState = "North Dakota";
		break
	case 'OH': 
		sState = "Ohio";
		break
	case 'OK': 
		sState = "Oklahoma";
		break
	case 'OR': 
		sState = "Oregon";
		break
	case 'PA': 
		sState = "Pennsylvania";
		break
	case 'PR': 
		sState = "Puerto Rico";
		break	
	case 'RI': 
		sState = "Rhode Island";
		break
	case 'SC': 
		sState = "South Carolina";
		break
	case 'SD': 
		sState = "South Dakota";
		break
	case 'TN': 
		sState = "Tennessee";
		break
	case 'TX': 
		sState = "Texas";
		break	
	case 'UT': 
		sState = "Utah";
		break
	case 'VT': 
		sState = "Vermont";
		break
	case 'VA': 
		sState = "Virginia";
		break
	case 'WA': 
		sState = "Washington";
		break
	case 'WV': 
		sState = "West Virginia";
		break
	case 'WI': 
		sState = "Wisconsin";
		break
	case 'WY': 
		sState = "Wyoming";
		break	
	} 
	
	return sState;
}

function SurveyPopup(psSurveyID, psSurveyTimeout, psSurveyQueryString)
{ 
 // This function can be overriden in a specific page just be defining it there.
  
 var iHeight;
 var iWidth;
 
 if (gsProdURL == "customercare.allstate.com")
 {
  iHeight = 520;
  iWidth  = 490;
 }
 else
 {
  iHeight = 520;
  iWidth  = 436;
 }

	WindowPopUp(iHeight, iWidth, 25, 250, 1, 0, "http://" + gsApplAgent + "/Survey/Survey.asp?SurveyID=" + psSurveyID + psSurveyQueryString);
}

function SurveyPopupDetermination(psSurveyId, psSurveyNextPopChk, psSurveyTimeOut, psSurveyQueryString)
{	
	// This function can be overriden in a specific page just be defining it there.
	//
	// Parameters:
	//		psSurveyId 			- A number representing the survey to be popped up.
	//		psSurveyNextPopChk	- Specifiy a N if you want to pop this survey irregardless if they have received a
	//								survey in the last sixty days.
	//							  Specifiy a Y if you want the process to check if the user is eligible to see a survey.
	//		psSurveyTimeOut		- Specify a number indicating the number of days the psSurveyId survey should expire in.
	//		psSurveyQueryString	- Here is where additional information can be passed to the survey engine.
	//
	//	SurveyPopupDetermination(45, "Y", 60, "?Addl_ZipCode=60173&Addl_Price=1326.23&Addl_Blah=WhoKnows");
	//
	// Prior to 7/31/2002:
	//		1) The Survey Engine put a simple cookie named "AllstateSurvey" with
	// 		either a value of Displayed or Processed.
	//		2) AllstateSurvey cookie expired after 60 days.
	// 	3) Both 1 and 2 are no longer valid.
	// Now:
	//		1) The cookie never expires.
	//		2) Cookie Sample   = AllstateSurvey=NextPop=08-05-2002&Status2=Displayed&Expire2=09-04-2002&Status25=Processed&Expire25=11-24-2002&...
	//		3) QueryStr Sample = ?SurveyID=25&SurveyEvent=OnLoad&SurveyTimeout=365&SurveyNextPopChk=n
	//		4) Rule that a survey can only been seen by a user if the previous survey has 
	// 		expired, however, the query string "SurveyNextPopChk" can bypass this check.
	//		5) Each survey has it's own expiration date stored as the Expire# subcookie.
	psSurveyNextPopChk = psSurveyNextPopChk.toLowerCase();
	var sAllstateSurvey = ICTGetCookie("AllstateSurvey");
	var sDateNextPopIsEligible = ICTGetSubCookie("AllstateSurvey", "NextPop");	
	blnPopupTargetSurvey = true;
	
	if (sAllstateSurvey != null) {
		// Note: If the NextPop subcookie doesn't exist, the lDateNextPopIsEligibleInMS date will be 12/31/1969.\
		var dNextPopIsEl = new Date(sDateNextPopIsEligible);
		var lDateNextPopIsEligibleInMS = dNextPopIsEl.getTime();
		var dCurrDate = new Date();
		var lCurDateInMS = dCurrDate.getTime();
		
		if ((psSurveyNextPopChk == "y") & (lDateNextPopIsEligibleInMS > lCurDateInMS)) {
			// A request was made for the standard popup check AND
			// the survey is not eligible to be popped.
			blnPopupTargetSurvey = false;
		}
		else {
			// Check to see if the user can see the target survey.
			// Note: If the Expire# subcookie doesn't exist, 
			//			the lTargetSurveyExpireInMS date will relect 12/31/1969.
			var dTargetSurveyExp = new Date(ICTGetSubCookie("AllstateSurvey", "Expire" + GetQueryString("surveyid")));
			var lTargetSurveyExpireInMS = dTargetSurveyExp.getTime();
			if (lTargetSurveyExpireInMS > lCurDateInMS) {
				blnPopupTargetSurvey = false;
			}
		}
	}
		
			
	if (blnPopupTargetSurvey == true) {
		SurveyPopup(psSurveyId, psSurveyTimeOut, psSurveyQueryString);
	}
}

function SurveyOnLoad() 
{
	// This function can be overriden in a specific page just be defining it there.
	
	if (document.location.search.indexOf("surveyevent=onload") > 0) {	
		SurveyPopupDetermination(GetQueryString("surveyid"), GetQueryString("surveynextpopchk"), GetQueryString("surveytimeout"), document.location.search.toLowerCase());
	}	
}

function SurveyOnUnLoad() 
{
	// This function can be overriden in a specific page just be defining it there.
	
	if (document.location.search.indexOf("surveyevent=onunload") > 0) {	
		SurveyPopupDetermination(GetQueryString("surveyid"), GetQueryString("surveynextpopchk"), GetQueryString("surveytimeout"), document.location.search.toLowerCase());
	}	
}

function CCCPageOnLoad() 
{
	// Intentionally left blank.
}

function SurveyinQuote(calledfrom, Addl_State, Addl_Type, Addl_Price, Addl_Zip, Addl_Company, Addl_Age, Addl_Quoteduration, Addl_Drivers, Addl_Alstar, Addl_Cars)
{
// calledfrom key:

// '0' = Auto quick quote by other means or property quick quote
// '1' = Auto or property full quote
// '2' = Auto quick quote (using Auto Coverage Guide)
//8-20-2003 cjf added back in to fix AHD Request Detail 7665055

var randomint6=Math.floor(6*Math.random()+1);
var randomint2=Math.floor(2*Math.random()+1);


var Addl_String = new String("&Addl_Info=Addl_State=" + Addl_State + "~Addl_Type=" + Addl_Type + "~Addl_Price="
				+ Addl_Price +"~Addl_Zip=" + Addl_Zip + "~Addl_Company=" + Addl_Company + 
				"~Addl_Age=" + Addl_Age + "~Addl_Drivers=" + Addl_Drivers +  "~Addl_Alstar=" 
				+ Addl_Alstar + "~Addl_Cars=" + Addl_Cars);

var CGcheck = ICTGetCookie("AllstateCovGuide");


if (CGcheck == "1")
	{
	calledfrom = 2;	
	}

switch (calledfrom)
	{
	case 0:				
		if (randomint6 == 1)
			{
			SurveyPopupDetermination(64,"Y",60,Addl_String);
			}
		else if (randomint6 == 2)
			{
			SurveyPopupDetermination(65,"Y",60,Addl_String);
			}
		break;		
	case 1:

		if (randomint2 == 1)
			{SurveyPopupDetermination(66,"Y",60,Addl_String);}
		else
			{SurveyPopupDetermination(67,"Y",60,Addl_String);}
		break;	
	case 2:

		SurveyPopupDetermination(68,"Y",60,Addl_String);
		break;
		
	}							 

}


function PageOnLoad() 
{
	imgDummy = LoadNewImage(gsSourceWebSite + "/Images/AllNavProductsOn_Btn.gif");
	imgDummy = LoadNewImage(gsSourceWebSite + "/Images/AllNavCareOn_Btn.gif");
	imgDummy = LoadNewImage(gsSourceWebSite + "/Images/AllNavAgentOn_Btn.gif");
	imgDummy = LoadNewImage(gsSourceWebSite + "/Images/AllNavFinancialOn_Btn.gif");
	imgDummy = LoadNewImage(gsSourceWebSite + "/Images/AllNavBankOn_Btn.gif");
	
	//cjf 8/08/2003 making the necessary changes to remove the WEbIQ Survey from the web
	//WebIQSurveyPopUp();
	
	SurveyOnLoad();
	
	CCCPageOnLoad();
}
//cjf 8/08/2003 removal of the WebIQ Survey from the site
function WebIQSurveyPopUp(){
	//if(isWebIQEntryPage() && IsSurveyEligibleForPopup()){
	//	WebIQCookieCheck();
	//}
}

function isWebIQEntryPage(){
	
	var currUrl = document.location.href.toLowerCase();
	
	var homePageUrl = gsApplAllstate + "/Home/Home.asp";
	homePageUrl = homePageUrl.toLowerCase();
	
	var agentPageUrl = gsApplAgent + "/Alocator.asp";
	agentPageUrl = agentPageUrl.toLowerCase();
	
	var cccPageUrl = gsApplCustCare;
	cccPageUrl = cccPageUrl.toLowerCase();
	
	//var buyPageUrl1 = "buy.allstate.com/auto/GetStarted.asp";
	var buyPageUrl1 = "Y0001-Web0198-S.allstate.com/auto/GetStarted.asp";
	buyPageUrl1 = buyPageUrl1.toLowerCase();
	
	//var buyPageUrl2 = "buy.allstate.com/prop/QQIntro.Asp";
	var buyPageUrl2 = "Y0001-Web0198-S.allstate.com/prop/QQIntro.Asp";
	buyPageUrl2 = buyPageUrl2.toLowerCase();
	
	if((currUrl.indexOf(homePageUrl) > 0) ||
		(currUrl.indexOf(agentPageUrl) > 0) ||
		(currUrl.indexOf(cccPageUrl) > 0) ||
		(currUrl.indexOf(buyPageUrl1) > 0) ||
		(currUrl.indexOf(buyPageUrl2) > 0)){
			
			return true;
		}
	return false;
}

function IsSurveyEligibleForPopup()
{	
	var sAllstateSurvey = ICTGetCookie("AllstateSurvey");
	var sDateNextPopIsEligible = ICTGetSubCookie("AllstateSurvey", "NextPop");	
	var blnIsEligible = true;
	
	if (sAllstateSurvey != null) {
		// Note: If the NextPop subcookie doesn't exist, the lDateNextPopIsEligibleInMS date will be 12/31/1969.\
		var dNextPopIsEl = new Date(sDateNextPopIsEligible);
		var lDateNextPopIsEligibleInMS = dNextPopIsEl.getTime();
		var dCurrDate = new Date();
		var lCurDateInMS = dCurrDate.getTime();
		
		if (lDateNextPopIsEligibleInMS > lCurDateInMS) {
			// A request was made for the standard popup check AND
			// the survey is not eligible to be popped.
			blnIsEligible = false;
		}
	}
		
	return blnIsEligible;
}


function PageOnUnLoad() 
{
	SurveyOnUnLoad();
}

function Level2DropDownNavigate()
{
	for (var i=0; i < document.frmNavForm.selLev2Nav.options.length; i++)
	{
		if ((document.frmNavForm.selLev2Nav.options[i].selected==true) && (document.frmNavForm.selLev2Nav.options[i].value != "0"))
		{
			window.location.href = document.frmNavForm.selLev2Nav.options[i].value;
		}
	}
}

function goToUrlwoPopUp(psURL)
{
	launchPFRSurvey = false;
	window.location.href = psURL;
}

function MastHeadPopup(piHdrPopId)
{
	if (screen.height > 600)
		var iVariance = 145
	else
		var iVariance = 65
		
	WindowPopUp(329, 218, screen.height / 2 - iVariance, 0, 0, 0, "http://" + gsApplAllstate + "/includes/MainHeaderPopup.asp?PopupId=" + piHdrPopId + "&ParentWindow=" + window.location.href);
}

function MastHeadAutoPopup(piHdrPopId)
{
	var sAllstateAutoMastHeadPopup = ICTGetCookie("AllstateMastHeadPopup");
	
	if (sAllstateAutoMastHeadPopup == null) {
		document.cookie = "AllstateMastHeadPopup=Displayed" + "; path=/; domain=.allstate.com; expires=Thu, 18-Jan-38 00:00:01 GMT";
		MastHeadPopup(piHdrPopId);
	}	
}


function BuildHeaderHtml(iButtonNumberOn, blnBlueBar, strSpanishApplication)
// This is the only public method and is responsbile for building the HTML necessary
// to build the header.
// iButtonNumberOn - Which button, if any, should be turned on.  Use the BTTN_ constants defined above.
// blnBlueBar - true or false as to whether the blue bar (i.e. peripheral section) to show.
{
	//USD - 32858
		if ((AWSGetCookie("AWSFlag") == "Y") && (gbAWSFlag == true))
	//if (AWSGetCookie("AWSFlag") == "Y")

	{	
		document.write('<link rel="stylesheet" type="text/css" href="' + gsSourceWebSite + '/Includes/General.css">');
		//8/25 cjf commented out for WebIQ Pop-up removal - NTNI testing
		//document.write('<script language="JavaScript" src="' + document.location.protocol + '//' + gsApplAllstate + '/Includes/webiq.js"></script>');	
		document.write('<table border="0" width="779px" Height="69px"; cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">');	
		
			document.write('<tr>');
				document.write('<!-- Global Links -->');
					document.write('<!-- Alstate.com -->');
						document.write('<td valign=middle Height="20px">');
							document.write('<a id="ICTAWS_Home" href="http://' + gsApplAllstate + '/Home/Home.asp">');
							document.write('<IMG alt="Allstate.com" Border="0"');
							document.write('src="' + gsSourceWebSite + '/images/gl_nav_allstateCom.gif"></a>');
					
					if (AWSGetCookie("AgentType") == "6" || AWSGetCookie("AgentType") == "8" || AWSGetCookie("AgentType") == "41" || AWSGetCookie("AgentType") == "40")
					{	
						<!-- MAI state -->
						if (DetermineIfMAIState())
						{	
							document.write('<!-- Get a Quote -->');
							document.write('<a id="ICTAWS_GetAQuote" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/GetAQuote/">');
							document.write('<IMG alt="Get a Quote" Border="0"');
							document.write('src="' + gsSourceWebSite + '/images/gl_nav_quote.gif"></a>');
						}
						else
						{	
						<!-- non MAI state -->
							document.write('<!-- Request Quote -->');
							document.write('<a id="ICTAWS_SendEmail" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/ContactMe/SendEmail.aspx?task=rfp">');
							document.write('<IMG alt="Request a Quote" Border="0"');
							document.write('src="' + gsSourceWebSite + '/images/gl_nav_requestQuote.gif"></a>');
						}
					document.write('<!-- Contact Me -->');
							document.write('<a id="ICTAWS_ContactMe" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/ContactMe/">');
							document.write('<IMG alt="Contact Me" Border="0"');
							document.write('src="' + gsSourceWebSite + '/images/gl_nav_contactMe.gif"></a>');
					}
					document.write('<!-- Join Our Mailing List -->');
							document.write('<a id="ICTAWS_MailingList" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/JoinOurMailingList/">');
							document.write('<IMG alt="Join Mailing List" Border="0"');
							document.write('src="' + gsSourceWebSite + '/images/gl_nav_join.gif"></a>');
					document.write('</td>');
				
				document.write('<td valign=top align=middle rowspan="2">');
					document.write('<IMG alt="Allstate"');
					document.write('src="' + gsSourceWebSite + '/images/img_ll_wave_1.gif">');
					
				document.write('<!-- Display agent/agency name and phone -->');
					document.write('<BR><B><FONT style="FONT-SIZE: 15px; FONT-FAMILY: Arial; Color: #003399"><B>' + (AWSGetCookie("AgentName")) + '</B></font></B>');
					document.write('&nbsp;&nbsp;&nbsp;');
					document.write('<B><font style="FONT-SIZE: 15px; FONT-FAMILY: Arial; Color: #666666"><B>' + (AWSGetCookie("AgentPhone")) + '</B></font></B>');
					document.write('</td>');
			document.write('</tr>');
			
		document.write('<!-- Agent Masthead -->');
				document.write('<tr Width="354px">');
					document.write('<td Height="30px">');
						//document.write('<a href="http://' + gsApplAllstate + '/Home/Home.asp">');
						document.write('<IMG alt="Allstate" border="0"');
						document.write('src="' + gsSourceWebSite + '/images/img_ll_logo.gif">');
						document.write('<IMG alt="Allstate"');
						document.write('src="' + gsSourceWebSite + '/images/img_ll_wave_2.gif">');
					document.write('</td>');
				document.write('</tr>');
								
		if (AWSGetCookie("AgentType") == "6" || AWSGetCookie("AgentType") == "8" || AWSGetCookie("AgentType") == "41" || AWSGetCookie("AgentType") == "40")
		{ 
			var currURL = document.location.href.toLowerCase();
			document.write('<!-- Main Navigation -->')
				document.write('<tr>');

						document.write('<td colspan="2">');
						document.write('<IMG alt="Allstate"');
						
				if ( sectionID == 4 )
					document.write('src="' + gsSourceWebSite + '/images/img_grad_white.gif">');
				else
					document.write('src="' + gsSourceWebSite + '/images/img_grad_gray.gif">');
					
				document.write('<!-- Welcome Button -->')
						document.write('<a id="ICTAWS_Welcome" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/Welcome/?currDomain=' + GetDomain(currURL) + '"');
						document.write('><IMG alt="Welcome" border=0 height=31 NAME="Welcome"');
						
				if ( sectionID == 1 )
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_welcome_on.gif"></a>');
				else
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_welcome_off.gif"></a>');
					
				document.write('<!-- Agency Info Button -->')
						document.write('<a id="ICTAWS_AgencyInfo" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/AgencyInfo/"');
						document.write('><IMG alt="Agency Info" border=0 height=31 NAME="AgencyInfo"');
				
				if ( sectionID == 2 )
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_agencyInfo_on.gif"></a>');
				else
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_agencyInfo_off.gif"></a>');
					
				document.write('<!-- Products Button -->')
						document.write('<a id="ICTAWS_AllstateProducts" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/AllstateProducts/"');
						document.write('><IMG alt="Products" border=0 height=31 NAME="Products"');
						
				if ( sectionID == 3 )
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_allProducts_on.gif"></a>');
				else
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_allProducts_off.gif"></a>');
					
				document.write('<!-- Planning Tools Button -->')
						document.write('<a id="ICTAWS_PlanningTools" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/PlanningTools/"');
						document.write('><IMG alt="Planning Tools" border=0 height=31 NAME="PlanTools"');
			
				//If the section is planning tools then highlight the button
				if ( sectionID == 4 )
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_planTools_on.gif"></a>');
				else
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_planTools_off.gif"></a>');
					
				document.write('<!-- Policy & Claims Services Button -->')
						document.write('<a id="ICTAWS_AccountServices" href="http://' + gsApplAgent + '/' + (AWSGetCookie("CFEA")) + '/AccountServices"');
						document.write('><IMG alt="Policy & Claim Service" border=0 height=31 NAME="PolicyServices"');
				
				if ( sectionID == 5 )
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_policyServices_on.gif"></a>');
				else
					document.write('src="' + gsSourceWebSite + '/Images/btn_gl_policyServices_off.gif"></a>');
					
					document.write('</td>');
			document.write('</tr>');
		}
		else if ( AWSGetCookie("AgentType") == "13" )
		{
			document.write('<!-- Main Navigation -->')
			document.write('<tr>');
			document.write('<td colspan="2">');
			document.write('<IMG alt="Allstate"');
			document.write('src="' + gsSourceWebSite + '/images/img_grad_grayEFS.gif">');
			document.write('<IMG alt=""');
			document.write('src="' + gsSourceWebSite + '/images/img_grad_EFSshadow_gray.gif">');
			document.write('</td>');
			document.write('</tr>');
		}
		document.write('</table>');
		
		DisplayAWSCalcHeader();
	}
	else
	{
	document.write('<link rel="stylesheet" type="text/css" href="' + gsSourceWebSite + '/Includes/General.css">');
	//8/25 cjf commented out for WebIQ Removal and NTNI testing
	//document.write('<script language="JavaScript" src="' + document.location.protocol + '//' + gsApplAllstate + '/Includes/webiq.js"></script>');	
	
	//document.write('<body bgcolor="#FFFFFF" leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" vlink="0000FF" ONLOAD="PageOnLoad();" ONUNLOAD="PageOnUnLoad();">');
	document.write('<!-- Main Header -->');
	document.write('<table border="0" width="780" cellspacing="0" cellpadding="0" bgcolor="#003399">');  
//	<!-- **********************************************************************  -->
//  <!-- Allstate.com Masthead Project [586]                                     -->
//	<!-- 10/31/2003 jfo2j/rwas3 Commented out old masthead code below 			 -->
//	<!-- **********************************************************************  -->
//		document.write('<tr>');		
//			document.write('<td width="203" align="left"><a href="http://' + gsApplAllstate + '"><IMG alt="Return to Home" height="76" border=0');
//				document.write(' src="' + gsSourceWebSite + '/images/AllHeadLogo_Img.gif"></a></td>');
//	     		document.write('<td width="480" align="middle">');
//				iHdrPopId = Math.floor(4 * Math.random() + 1);
//				document.write('<a href="javascript:MastHeadPopup(' + iHdrPopId + ')"><IMG height="76" border=0 src="' + gsSourceWebSite + '/Images/AllMastHead' + iHdrPopId + '.gif" alt="The Right Hands Make All The Difference."></a>');
//			document.write('</td>');		
//			document.write('<td width="97" align="right">');
//				document.write('<map name="FPMap0">');
//					document.write('<area href="http://' + gsApplAllstate + '/About/" shape="rect" coords="35, 5, 113, 15">');
//					document.write('<area href="http://' + gsApplAllstate + '/Tools/" shape="rect" coords="11, 22, 113, 32">');
//					document.write('<area href="javascript:goToUrlwoPopUp(&quot;http://' + gsApplAllstate + '/ContactUs/&quot)" shape="rect" coords="45, 40, 113, 51">');
//					document.write('<area href="http://' + gsApplAllstate + '/SiteMap/" shape="rect" coords="55, 55, 113, 70">');
//					document.write('</map>');
//				document.write('<IMG alt="" height="76" border=0 usemap="#FPMap0" src="' + gsSourceWebSite + '/Images/AllHeadMap_Btn.gif">');
//			document.write('</td>');
//		document.write('</tr>');
//	<!-- **********************************************************************  -->
//  <!-- Allstate.com Masthead Project [644]                                     -->   
//  <!-- Added new masthead code below                                           -->
//	<!-- **********************************************************************  -->				
		document.write('<tr>');		
//2 images 168 & 211 pixels width, height 72
			document.write('<td width="168" rowspan="2" align="right" border="0"><a id="ICTHeader_Home" href="http://' + gsApplAllstate + '"><IMG alt="Allstate.com Home" height="72" width="168" border=0');
				document.write(' src="' + gsSourceWebSite + '/images/AllHeadLogoClouds_Img.jpg"></a>');				
			document.write('</td>');				
			document.write('<td width="211" rowspan="2" align="right" border="0"><IMG height="72" width="211" border=0');
				document.write(' src="' + gsSourceWebSite + '/images/AllHeadClouds_Img.jpg"></a>');				
			document.write('</td>');
//401 pixels width
			document.write('<td width="401" cellspacing="1" height="2"');	
				//spacer from the top margin
			document.write('</td>');			
		document.write('</tr>');
		
//links	
//	<!-- *************************************************************************************************  -->
//  <!-- Allstate.com Project [730] Iteration 6 - Remove Image links in header Navigation top bar and		-->
//	<!-- replace with text	Links																			-->   
//  <!-- Msoyy - 11/29/2004																					-->
//	<!-- *************************************************************************************************	-->
		document.write('<tr>');				
			document.write('<td width="401" Align="left" valign="top" halign="right">');
				document.write('<table width="100%" height="19" cellspacing="0" cellpadding="0">');
				document.write('<tr>');
				document.write('<td width="80" class="topNavBar" align="center" valign="middle">');
				document.write('<a id="ICTHeader_ClaimsCenter" href="http://' + gsApplAllstate + '/ClaimsCenter/" title="Claim Center">');
				document.write('Claim Center');
				document.write('</td>');
				document.write('<td width="1">');
				document.write('<img src="' + gsSourceWebSite + '/images/NavSeparator.gif" width="1" height="13">');					
				document.write('</td>');
				document.write('<td width="66" class="topNavBar" align="center" valign="middle">');
				document.write('<a id="ICTHeader_ContactUs" href="http://' + gsApplAllstate + '/ContactUs/" title="Contact Us" class="topNavBar">');
				document.write('Contact Us');					
				document.write('</td>');
				document.write('<td width="1">');
				document.write('<img src="' + gsSourceWebSite + '/images/NavSeparator.gif" width="1" height="13">');					
				document.write('</td>');
				document.write('<td width="86" class="topNavBar" align="center" valign="middle">');
				if (iButtonNumberOn == BTTN_CUST_CARE)
				{
					document.write('<a id="ICTHeader_MailingList" href="https://' + gsApplAllstate + '/JoinOurMailingList/AddPreferences.aspx" title="E-mail Sign Up" class="topNavBar">');
					document.write('E-mail Sign Up');
					document.write('</a>');
				}
				else
				{
					document.write('<a id="ICTHeader_MailingList" href="https://' + gsApplAllstate + '/JoinOurMailingList/" title="E-mail Sign Up" class="topNavBar">');
					document.write('E-mail Sign Up');
					document.write('</a>');
				}				
				document.write('</td>');
				document.write('<td width="1">');
				document.write('<img src="' + gsSourceWebSite + '/images/NavSeparator.gif" width="1" height="13">');					
				document.write('</td>');
				document.write('<td width="55" class="topNavBar" align="center" valign="middle">');
				document.write('<a id="ICTHeader_SiteMap" href="http://' + gsApplAllstate + '/SiteMap/" title="Site Map" class="topNavBar">');
				document.write('Site Map');
				document.write('</a>');					
				document.write('</td>');
				document.write('<td width="1">');
				document.write('<img src="' + gsSourceWebSite + '/images/NavSeparator.gif" width="1" height="13">');					
				document.write('</td>');
				document.write('<td width="90" class="topNavBar" align="center" valign="middle">');
				document.write('<a id="ICTHeader_AboutAllstate" href="http://' + gsApplAllstate + '/About/" title="About Allstate" class="topNavBar">');
				document.write('About Allstate');
				document.write('</a>');					
				document.write('</td>');					
				document.write('</tr>');	
				document.write('</table>');
			document.write('</td>');									
		document.write('</tr>');						
		
		
//	<!-- **********************************************************************  -->
//  <!-- Allstate.com Masthead Project [644]                                     -->   
//  <!-- Added new masthead code above                                           -->
//  <!-- End of code changes                                                     -->
//	<!-- **********************************************************************  -->

//	<!-- *************************************************************************************************  -->
//  <!-- Allstate.com Project [730] Iteration 6 - Remove Image links in header Navigation bar and replace	-->
//	<!-- with text	Links																					-->   
//  <!-- Msoyy - 11/29/2004																					-->
//	<!-- *************************************************************************************************	-->

	document.write('</table>');

	document.write('<!-- Spacer Lines -->');
	document.write('<table border="0" width="780" cellspacing="0" cellpadding="0">');	
	document.write('  <tr>');
	document.write('    <td height="3" width="780" bgcolor="#000000"><IMG border=0 height=4 src="' + gsSourceWebSite + '/Images/AllHeadLine_Img.gif" width=780></td>');
	document.write('  </tr>');
	document.write('</table>');	
	
	document.write('<!-- Global Navigation -->');
	document.write('<table border="0" width="780" height="29" cellspacing="0" cellpadding="0" bgcolor="#D6D6CE">');
	document.write('<tr>');

	<!-- Products Button -->
	document.write('		<td width="156" align="center"><A id="ICTHeader_InsuranceProducts" href="http://' + gsApplInsurance + '"  class="NavBar" title="Insurance Products"');
	if (iButtonNumberOn == BTTN_PRODUCTS)
	{
		document.write('		><font color="#04379A" class="NavBar">Insurance Products</font></A></td>');
	}
	else	
	{
		document.write('			ONMOUSEOVER="ChangeColorOver(&quot;lnkInsurance&quot;)" ; return true;"');
		document.write('			ONMOUSEOUT="ChangeColorOut(&quot;lnkInsurance&quot;)" ; return true;"');
		document.write('			><font id="lnkInsurance" color="#4C4B4B">Insurance Products</font></A></td>');
	}
	document.write(' <td height="26" align="middle"><IMG border=0 height=13 src="' + gsSourceWebSite + '/Images/NavSeparator.gif" width=1></td>');
	<!-- Financial Button -->
	document.write('    	<td width="156" align="center"><A id="ICTHeader_FinancialProducts" href="http://' + gsApplAllstate + '/Finance/" style="text-decoration:none" title="Financial Products"');
	if (iButtonNumberOn == BTTN_FINANCIAL)
		document.write('			><font color="#04379A" class="NavBar">Financial Products</font></A></td>');
	else
	{
		document.write('			ONMOUSEOVER="ChangeColorOver(&quot;lnkFinance&quot;)" ; return true;"');
		document.write('			ONMOUSEOUT="ChangeColorOut(&quot;lnkFinance&quot;)" ; return true;"');
		document.write('			><font id="lnkFinance" class="NavBar" color="#4C4B4B">Financial Products</font></A></td>');	}
		document.write(' <td height="26" align="center"><IMG border=0 height=13 src="' + gsSourceWebSite + '/Images/NavSeparator.gif" width=1></td>');
	
	<!-- Savings and Banking Button -->
	document.write('    	<td width="156" align="center"><A id="ICTHeader_SavingsBanking" href="http://' + gsApplBank + '" style="text-decoration:none" title="Savings and Banking"');
	if (iButtonNumberOn == BTTN_BANK)
		document.write('			><font color="#04379A" class="NavBar">Savings & Banking</font></A></td>');
	else
	{
		document.write('			ONMOUSEOVER="ChangeColorOver(&quot;lnkBanksavings&quot;)" ; return true;"');
		document.write('			ONMOUSEOUT="ChangeColorOut(&quot;lnkBanksavings&quot;)" ; return true;"');
		document.write('			><font id="lnkBanksavings" class="NavBar" color="#4C4B4B">Savings & Banking</font></A></td>');	}
	
		document.write(' <td height="26" align="center"><IMG border=0 height=13 src="' + gsSourceWebSite + '/Images/NavSeparator.gif" width=1></td>');
	<!-- Agent Button -->
	document.write('    	<td width="156" align="center"><A id="ICTHeader_FindAgent" href="http://' + gsApplAgent + '" style="text-decoration:none" title="Find an Agent"');
	if (iButtonNumberOn == BTTN_AGENT)
		document.write('			><font color="#04379A" class="NavBar">Find an Agent</font></A></td>');
	else
	{
		document.write('			ONMOUSEOVER="ChangeColorOver(&quot;lnkAgent&quot;)" ; return true;"');
		document.write('			ONMOUSEOUT="ChangeColorOut(&quot;lnkAgent&quot;)" ; return true;"');
		document.write('			><font id="lnkAgent" class="NavBar" color="#4C4B4B">Find an Agent</font></A></td>');	}
			document.write(' <td height="26" align="center"><IMG border=0 height=13 src="' + gsSourceWebSite + '/Images/NavSeparator.gif" width=1></td>');
	<!-- Customer Care Button -->
	document.write('    	<td width="156" align="center"><A id="ICTHeader_CustomerCare" href="https://' + gsApplCustCare + '" style="text-decoration:none" title="Customer Care Center"');
	if (iButtonNumberOn == BTTN_CUST_CARE)
		document.write('			><font color="#04379A" class="NavBar">Customer Care Center</font></a></td>');
	else
	{
		document.write('			ONMOUSEOVER="ChangeColorOver(&quot;lnkCCC&quot;)" ; return true;"');
		document.write('			ONMOUSEOUT="ChangeColorOut(&quot;lnkCCC&quot;)" ; return true;"');
		document.write('			><font id="lnkCCC" class="NavBar" color="#4C4B4B">Customer Care Center</font></A></td>');	}
	

	document.write('  </tr>');
	document.write('  </table>');
	document.write('<table>');	//added for CCC winrunner scripts per Susan Tulley's 5/6/04 request
	document.write('</table>'); //added for CCC winrunner scripts per Susan Tulley's 5/6/04 request		
	
//	document.write('<!-- Spacer Lines -->');
//	document.write('<table border="0" width="780" cellspacing="0" cellpadding="0">');
//	document.write('  <tr>');
//	document.write('    <td height="4" width="780" bgcolor="#000000"><IMG border=0 height=4 src="' + gsSourceWebSite + '/Images/AllHeadLine_Img.gif" width=780></td>');
//	document.write('  </tr>');
//	document.write('  <tr>');
//	document.write('    <td height="1" width="780"><IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=780></td>');
//	document.write('  </tr>');
//	document.write('</table>');
	
	DisplayAWSCalcHeader();
	
	}
	
	if (blnBlueBar == true)
	{	
		var homePageUrl = "http://" + gsApplAllstate + "/Home/Home.asp";
		homePageUrl = homePageUrl.toLowerCase();
		
		//5-21-04 SEO Hosting and Redirects might affect the URL comparison, 
		//so for now we're adding additional statements to catch the URL
		var CurrURL = document.location.href.toLowerCase();
		var homePageUrl1 = "http://" + gsApplAllstate + "/";
		homePageUrl1 = homePageUrl1.toLowerCase();
		var homePageUrl2 = "http://car-insurance-company.allstate.com/Home/Home.asp";
		homePageUrl2 = homePageUrl2.toLowerCase();
		//Defect 2382 (SEO)
		//var homePageUrl3 = "http://car-insurance-company.allstate.com" + "/"
		//homePageUrl3 = homePageUrl3.toLowerCase();	
		
		document.write('<!-- Main Section -->');
		document.write('<table border="0" width="780" cellspacing="0" cellpadding="0">');
		document.write('  <tr>');
		//USD - 32858
		if ((AWSGetCookie("AWSFlag") == "Y") && (gbAWSFlag == true))
		//if (AWSGetCookie("AWSFlag") == "Y")
		{
			document.write('     <td width="156" align="middle" bgcolor="#FFFFFF" valign="top">');
			document.write('			<!-- Left Side Section -->');
			document.write('			<table border="0" width="100%" cellspacing="0" cellpadding="0">');
			document.write('			  <tr>');
			document.write('			    <td height="1" width="100%"><IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=156></td>');
			document.write('			  </tr>');
			document.write('			</table>');
		}		
		else if ((CurrURL ==  homePageUrl) || (CurrURL == homePageUrl1) || (CurrURL == homePageUrl2))
		{
			// For homepage only removed color bgcolor="#000066".  Inserted watermark.  
			document.write('     <td width="156" valign="top" background="' + gsSourceWebSite + '/home/images/allstate_logo_wtrmk.gif"');
			document.write('			<!-- Left Side Section -->');
//			document.write('			<table border="0" width="100%" cellspacing="0" cellpadding="0">');
//			document.write('			  <tr>');
//			document.write('			    <td height="1" width="100%"><IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=156></td>');
//			document.write('			  </tr>');
//			document.write('			</table>');
		}			
		else
		{
			if (strSpanishApplication == "spanish")  
			{
				document.write('     <td width="156" align="middle" bgcolor="" valign="top">');
				document.write('			<!-- Left Side Section -->');
			}
			else
			{
				document.write('     <td width="156" align="middle" BGCOLOR="#000066" valign="top">');
				document.write('			<!-- Left Side Section -->');
			}
			document.write('			<table border="0" width="100%" cellspacing="0" cellpadding="0">');
			document.write('			  <tr>');
			document.write('			    <td height="1" width="100%"><IMG border=0 height=1 src="' + gsSourceWebSite + '/Images/ClearSpacer.gif" width=156></td>');
			document.write('			  </tr>');
			document.write('			</table>');
		}
	}
	//else
	//{
	//	document.write('    <td width="156" align="middle" valign="top">');
	//}
	
	// MastHeadAutoPopup(iHdrPopId);
	
}




