var WindowOpener;
//By Pravin for Tooltip on HREF

if (!document.layers&&!document.all)
event="test";
function showtip(current,e,text){

if (document.all){
thetitle=text.split('<br>')
if (thetitle.length>1){
thetitles=''
for (i=0;i<thetitle.length;i++)
thetitles+=thetitle[i]
current.title=thetitles
}
else
current.title=text
}

else if (document.layers){
document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
document.tooltip.document.close()
document.tooltip.left=e.pageX+5
document.tooltip.top=e.pageY+5
document.tooltip.visibility="show"
}
}
function hidetip(){
if (document.layers)
document.tooltip.visibility="hidden"
}
//code for Tool tip ends
function OpenSubWindow(sUrl,iWidth,iHeight,sName){
//open window with with just scrollbars, given url,width,height,optional name
	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName,"top=40,left=40,height=" + iHeight + ",width=" + iWidth + ",status=no,scrollbars=yes,toolbar=no,menubar=no,location=no");
	WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}


function OpenWindow(sUrl,sName){
//open window with all normal features, given url and optional name
	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName);
	WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}

function OpenStatusWindow(sUrl,iWidth,iHeight,sName){
//open window with with just scrollbars, given url,width,height,optional name
	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName,"top=20,left=20,height=" + iHeight + ",width=" + iWidth + ",status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no");
	WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}

function OpenSubWindowNoScroll(sUrl,iWidth,iHeight,sName){
//open window with with just scrollbars, given url,width,height,optional name
	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName,"top=40,left=40,height=" + iHeight + ",width=" + iWidth + ",status=no,scrollbars=no,toolbar=no,menubar=no,location=no");
	WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}

function OpenSubWindowToolbar(sUrl,iWidth,iHeight,sName){
//open window with with just scrollbars, given url,width,height,optional name

	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName,"top=40,left=40,height=" + iHeight + ",width=" + iWidth + ",status=no,scrollbars=yes,toolbar=yes,menubar=yes,location=yes");
	WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}

//file:		lib_c_cookie.js
//for:		cookie functions, client-side
//mods:
//04/26/01 13:40 JC Lango created

function c_SetCookie(sName,sValue,sExpires,sPath,sDomain,bIsSecure){
//write a cookie, long version
//example:c_SetCookie("UserName","Bob","default",null,null,false)
//sName:	cookie name
//sValue:	value to set
//sExpires:	expiration date, if "default" then five years from today
//			if null then expires when browser closed
//sPath:	url folder path that triggers cookie read
//sDomain:	limits cookie read to these domains
//bIsSecure:true=make cookie secure
	if(sExpires=="default"){
		sExpires=new Date();
		sExpires.setTime(sExpires.getTime()+(5*365*24*60*60*1000));//+ five years
	}
	var sExpiresString=((sExpires==null)?"":(";expires=" + sExpires.toGMTString()));
	var sPathString=((sPath==null)?"":(";path=" + sPath));
	var sDomainString=((sDomain==null)?"":(";domain=" + sDomain));
	var sSecureString=(bIsSecure?";secure":"");
	document.cookie=sName+"="+escape(sValue)+sExpiresString+sPathString+sDomainString+sSecureString;
}

function c_SetCookieEZ(sName,sValue){
//write a cookie, short version, expires when browser closed
//example:c_SetCookieEZ("UserName","Bob")
//sName:	cookie name
//sValue:	value to set
	document.cookie=sName+"="+escape(sValue);
}

function c_DeleteCookie(sName){
	var sExpires=new Date();
	sExpires.setTime(sExpires.getTime()-(3*24*60*60*1000));//- three days
	document.cookie=sName+"=x"+";expires="+sExpires.toGMTString();
}

function c_GetCookie(sName){
//get string of all cookie values for a given cookie name
	var sValue=null;
	var sCookie=" " + document.cookie + ";";
	var sSearchName=" " + sName + "=";
	var iCookieStart=sCookie.indexOf(sSearchName);
	var iCookieEnd;
	if(iCookieStart!=-1){
		iCookieStart+=sSearchName.length;
		iCookieEnd=sCookie.indexOf(";",iCookieStart);
		sValue=unescape(sCookie.substring(iCookieStart,iCookieEnd));
	}
	return(sValue);
}

function c_GetCookieCount(){
//get number of cookie values for a given cookie name
	var iCount=0;
	var sCookie=" " + document.cookie + ";";
	var sSearchName=" " + sName + "=";
	var iCookieStart=sCookie.indexOf(sSearchName);
	while(iCookieStart!=-1){
		iCount+=1;
		iCookieStart=sCookie.indexOf(sSearchName,iCookieStart+sSearchName.length);
	}
	return(iCount);
}

//get cookie values for a given cookie name and index
function c_GetCookieByIndex(sName,iIndex){
	var sValue=null;
	if(iIndex<1)
		return(sValue);
	var sCookie=" " + document.cookie + ";";
	var sSearchName=" " + sName + "=";
	var iCookieStart=sCookie.indexOf(sSearchName);
	var iCookieEnd;
	var i;
	for(i=1;i<iIndex;i++)
		iCookieStart=sCookie.indexOf(sSearchName,iCookieStart+sSearchName.length);
	if(iCookieStart!=-1){
		iCookieStart+=sSearchName.length;
		iCookieEnd=sCookie.indexOf(";",iCookieStart);
		sValue=unescape(sCookie.substring(iCookieStart,iCookieEnd));
	}
	return(sValue);
}


function QueryString(key) {
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse() {
	var query = window.location.search.substring(1);
	var pairs = query.split("&");

	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;
		}
	}
}

QueryString_Parse();
/////////////////////////

	function OpenPetWindow(sUrl, sName){
	//open window with with just scrollbars, given url,width,height,optional name
		sName=new String(sName);
		if(sName=="undefined")
			sName="subWindow";
		//subWindow=window.open(sUrl,sName,"top=40,left=40,height=" + iHeight + ",width=" + iWidth + ",status=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=no");
		subWindow=window.open(sUrl,sName);
		WindowOpener=subWindow.opener;
		setTimeout("subWindow.focus();",100);
	}
function formURL(command) {
	url = '/HICServlet' + '?' + command + '=' + '&code=';
	x=QueryString('code');
	//document.promocode.code.value = x;
	url = url + x;
	OpenPetWindow(url,'PetInsurance')
}
function openPetInCurrWindow(command) {
	url = '/HICServlet' + '?' + command + '=' + '&code=';
	x=QueryString('code');
	url = url + x;
	document.location.href = url;
}	
/////////////////////////	
	
	function appLauncher(link, img, alt, extraParams, newWindow) {
		urlToLaunch = link;
		if (extraParams != "") {
			if (link.indexOf("?") != -1) {
				nextChar = "&";
			} else {
				nextChar = "?";
			}
			fields = extraParams.split(",");
			for (var i=0; i<fields.length; i++) {
				var value = QueryString(fields[i]);
				if (value != null) {
					urlToLaunch = urlToLaunch + nextChar + fields[i] + "=" + value;
					nextChar = "&";
				}
			}
		}

		if ((newWindow == "Y") || (newWindow == "y")) {
			destination = 'javascript:OpenStatusWindow(' + "'" + urlToLaunch + "'" + ",655, 500,'" + "app" + "');";
		} else {
			destination = urlToLaunch;
		}

		if (img != "") {
			visual = '<img src="' + img + '" alt="' + alt + '">';
		} else {
			visual = alt;
		}

		builtLink = '<a href="' + destination + '">' + visual + '</a>'

		document.write(builtLink);
	}

	function leaveSiteLink(img, alt) {
	    var linkUrl = QueryString('url');
            builtLink = '<a href="#" onclick="openLink(\'' + linkUrl + '\');"><img src="' + img + '" alt="' + alt + '"></a>';
	    document.write(builtLink);
	}

	
	 function openLink(url) {
	   var isMaximisedWindow = QueryString('MaxWin');
	   //var bMaxWindow = window.confirm('Click on \"OK\" if you would like to open the site in a maximised window.\n                                          OR\nClick on \"Cancel\" if you would like to open the site in this window.');
	   if(isMaximisedWindow != null && isMaximisedWindow =='Y'|| isMaximisedWindow =='y' ){
		   window.location.href=url;
		   window.moveTo(0,0);
	   	   window.resizeTo(screen.availWidth,screen.availHeight);
	  }
	  else{
		  window.location.href=url;
	  }
	}

	function maximiseWindow() {
	   var isMaximisedWindow = QueryString('MaxWin');
	   //var bMaxWindow = window.confirm('Click on \"OK\" if you would like to open the site in a maximised window.\n                                          OR\nClick on \"Cancel\" if you would like to open the site in this window.');
	   if(isMaximisedWindow != null && isMaximisedWindow =='Y'|| isMaximisedWindow =='y' ){
		   window.moveTo(0,0);
	   	   window.resizeTo(screen.availWidth,screen.availHeight);
	  }
	  else{
		//do not maximise window
	  }
	}
	

	function getElement(name) {
		return document.getElementById(name);
	}

	function checkGecko(sUrl,iWidth,iHeight,sName){
		if (navigator.product == 'Gecko'){
			//alert("Gecko");
		location.href=sUrl;
		} else {
			//alert("Not Gecko");
			OpenStatusWindow(sUrl,iWidth,iHeight,sName);
		}
	}
	
	function SubmitQuote(sproduct, stateField) {
		var product;
		var state;
		var a = QueryString('a');
		var cid = QueryString('cid');
		var target = QueryString('target');
	
		if(a==null){
			a = QueryString('A');
		}

		if(cid==null){
			cid = QueryString('CID');
		}

		if(target==null){
			target = QueryString('TARGET');
		}

		
		var panswerfinancial="";

		if(a==null && cid!=null && target !=null){
			 panswerfinancial = "&cid="+cid+"&target="+target;
		}else if(cid==null && a!=null && target !=null){
			 panswerfinancial = "&a="+a+"&target="+target;
		}else if(target==null && a!=null && cid !=null){
			 panswerfinancial = "&cid="+cid+"&a="+a;
		}else if(target==null && a==null && cid !=null){
			 panswerfinancial = "&cid="+cid;
		}else if(target==null && cid==null && a !=null){
			 panswerfinancial = "&a="+a;
		}else if(target!=null && cid==null && a ==null){
			panswerfinancial = "&target="+target;
		}
		else if(target!=null && cid!=null && a !=null){
			panswerfinancial = "&cid="+cid+"&a="+a+"&target="+target;
		}


		product = sproduct ;
		if(product=="homeowners")
		{
			state=stateField.options[stateField.selectedIndex].value;
			

			if(state=="NY"){
				OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuoteNY=&lstProperty=' + product +  '&lstState=' + state+ '&accept-language=en-US',650,550,'sub');
			}
			else{

					if(a==null&&cid==null&&target==null){
						//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners&accept-language=en-US',650,660,'sub');
						window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');

					}else {
						//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners&a='+a+'&cid='+cid+'&target='+target+'&accept-language=en-US',650,660,'sub');
						//window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners&a='+a+'&cid='+cid+'&target='+target+'&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
						window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners'+panswerfinancial+'&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
					}
			}
		} else if(product=="renters"){
			state=stateField.options[stateField.selectedIndex].value;
			code = QueryString('code');
				if(code == null){
					code = "001" ;
				}

			//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=' + product + '&code='+code + '&a='+a+'&cid='+cid+'&target='+target+ '&lstState=' + state+ '&accept-language=en-US',650,660,'sub');
			//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=' + product + '&code='+code +panswerfinancial+ '&lstState=' + state+ '&accept-language=en-US',650,660,'sub');
			window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=renters&code='+code +panswerfinancial+ '&lstState=' + state+ '&accept-language=en-US','sub',"" +'height=450,width=650, screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
		} else if(product=="auto"){
			
			if(a==null&&cid==null&&target==null){
				//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=auto&accept-language=en-US',650,660,'sub');
				window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=auto&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
			}else{
				//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=auto&a='+a+'&cid='+cid+'&target='+target+'&accept-language=en-US',650,660,'sub');
				window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=auto'+panswerfinancial+'&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
			}
		}	else if(product=="homeownerswithoutstate"){
			
				product="homeowners";
				if(a==null&&cid==null&&target==null){
					//OpenSubWindowToolbar('/HICServlet?cmd_InsuranceQuote=&lstProperty=' + product + '&accept-language=en-US',screen.availheight,screen.availwidth,'sub');
					window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=' + product + '&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
				}else{

					//window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners&a='+a+'&cid='+cid+'&target='+target+'&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
					window.open('/HICServlet?cmd_InsuranceQuote=&lstProperty=homeowners'+panswerfinancial+'&accept-language=en-US','sub',"height=" + screen.availheight + ",width=" + screen.availwidth +'screenX=0,screenY=0,top=0,left=0,status=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes');
				}
			}
		
	}

	///// Added on 08/10/2004 for register4bib.html /////////

	var isNS=(navigator.appName=="Netscape");

	var documentRef=(isNS)?"document":"document.all";
	var styleRef=(isNS)?"":".style";
	var showRef=(isNS)?"show":"visible";
	var hideRef=(isNS)?"hide":"hidden";

	function showDivAt(divId,popX,popY){
		eval(documentRef + '.' + divId + styleRef + '.visibility = "' + showRef + '"');
		eval(documentRef + '.' + divId + styleRef + '.top = ' + popX);
		eval(documentRef + '.' + divId + styleRef + '.left = ' + popY);
	}

	function hideDiv(divId){
		eval(documentRef + '.' + divId + styleRef + '.visibility = "' + hideRef + '"');
	}


	function HideIt(){
		if(isNS){
			hideDiv("divLinkDisclaimer1");
			hideDiv("divLinkDisclaimer2");
		}
	}

	function ShowIt2(posX,posY){
		if(isNS){
		var popX
		var popY
		popX=(posX + 20)
		popY=(posY + 10)
		showDivAt("divLinkDisclaimer2",popY,popX);
		}
	}

//Function added to call UFA Pages from Left nav
function OpenResizableWindow(sUrl,iWidth,iHeight,sName)
{
//open window with with just scrollbars, given url,width,height,optional name
	sName=new String(sName);
	if(sName=="undefined")
		sName="subWindow";
	subWindow=window.open(sUrl,sName,"top=40,left=40,height=" + iHeight + ",width=" + iWidth + ",status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes");
	//WindowOpener=subWindow.opener;
	setTimeout("subWindow.focus();",100);
}
	///// End of addition on 08/10/2004 for register4bib.html /////////