
//bUsaNoFloat: for wider pages
//bGoThemeSamePage: stay on same page when changing theme
var D=document, W=window, L=W.location, StateAbbr, aCookies, bKT, aErrScr, bSH, bDev, //bSerpRef, 
	oGrayDiv, oGrayIn, aD=[], SHURL, Color="g"; //DO NOT TOUCH Color!! 1 char only
var E, EvSrc, Gec, Op, Ns, Saf, IE7Q, Nav, IEVer, FFVer, Quirks, Chrome, IEMob, oSH;

//------------------------------------------------------------------------
//Results page part

function InitSH(){
//global params
var Host=L.hostname, thid, ResBase='', aThemes;

if (oSH) return;
bDev=(L.search.indexOf("test=1")!=-1);
if (Host.indexOf('.blogspot.com')!=-1) ResBase='htt'+'p://ww'+'w.auto-insu'+'rance-mate.com';
ResBase+='/commonres/'; GetCookies();

oSH={
	bLIP:false, //(Host.indexOf('.mylifeinsuranceplace.com')!=-1), 
	bSHNoUK:(Host=='www.insuremyauto.co.uk'),
	ResBase:ResBase, LoadTryNo:1, PageH:0, InsurPar:'', ErrNum:0,
	bAu:0, bLf:0, bHl:0, aTheme:false, ThId:0, bGr:(Color=="g"), FFCnt:0
	};
if (oSH.bLIP) return;

SHURL="http"+(oSH.bGr ? "s" : "")+"://www."+SH_Host()+".com/retrieve_listings.asp";
aThemes=SH_TypeCodes(); thid=aCookies['themeid']; 

if (!(thid && thid>=2663 && thid<=2670)) thid=W.ni_ad_client;
//Convert to theme
if (thid){
	oSH.aTheme=aThemes[thid]; sh_theme=oSH.aTheme[1]; oSH.ThId=thid;
	}
else if (W.sh_theme){
	oSH.ThId=SH_TypeId(sh_theme); oSH.aTheme=aThemes[oSH.ThId];
	}
else sh_theme=false;

if (sh_theme=='auto') oSH.bAu=1; else if (sh_theme=='life') oSH.bLf=1; else if (sh_theme=='health') oSH.bHl=1;

ni_zc=getQueryStringVariable('zip');
if (!W.ni_lnt_id) ni_lnt_id=1; //null
ni_var1=Host;
if (ni_var1.substr(0, 4)=='www.') ni_var1=ni_var1.substr(4);
oSH.bTeal=SH_IsTealTempl();
}

//------ Utils

function getbyid(id){return D.getElementById(id);}

function getat(o, at){
var val=o.getAttribute(at); if (Op && val=='') val=null; return val;
}

function setat(o, at, val){
if (Op && val==null) val=''; o.setAttribute(at, val);
}

function trim(str){
return((" "+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,"$1"));
}

function EventInit(e){
E=(!Gec ? event : e); EvSrc=E[Gec ? 'target' : 'srcElement'];
if (Ns && istxt(EvSrc)) EvSrc=EvSrc.parentNode;
}

function SetHandler(Ev, F, O){
if (!O) O=D;
if (O.attachEvent) O.attachEvent(Ev, F); else O.addEventListener(Ev.substr(2), F, false);
} 

function InitUA(){
//This is the main InitUA()!

if (Nav) return;
IEVer=0; FFVer=0; Nav=W.navigator.userAgent; 
Gec=(Nav.indexOf('Gecko')!=-1); 
Saf=(Nav.indexOf(' AppleWebKit/')!=-1 && Nav.indexOf(' Safari/')!=-1);
Op=(Nav.indexOf('Opera')!=-1); //Ns=(Gec && Nav.indexOf('Netscape')!=-1); 
Chrome=(Saf && Nav.indexOf(' Chrome/')!=-1);
Quirks=(D.compatMode=='BackCompat');

if (!Gec && !Op && !Saf){
	if (D.documentMode){
		IEVer=D.documentMode; if (IEVer==5) IEVer=6;
		}
	else{
		if (Nav.match(/ MSIE (\d+)/)) IEVer=RegExp.$1;
		if (IEVer==7 && Quirks) IE7Q=true; //IEVer=6; ?!
		}
	if (Nav.indexOf('IEMobile')!=-1) IEMob=true;
	}
else if (Gec && Nav.match(/Firefox\/(\d+)/)) FFVer=RegExp.$1;

SetBodyCls();
CheckFr(); //setTimeout("CheckFr()", 1);
} 

function CheckFr(bTO){
var Ref=D.referrer;

if (!bTO){
	if (Ref.match("http://\\d{1,3}([.]\\d{1,3}){3}/[?]xurl=http://")){	
		oSH.bFr=true; return;
		}
	//Good
	if (StartsWith(Ref, "http://www.google.com/imgres?")) return;
	if (StartsWith(L.href, "http://translate.googleusercontent.com/translate")) return;
	}

if (W.top!=W && !W.bwhfl){
	R=GetPosRoot();
	if (R.clientWidth==0 && R.clientHeight==0 && !bTO) setTimeout("CheckFr(1)", 1000);
	else KT_OE('fr:'+R.clientWidth+'x'+R.clientHeight+(bTO ? ' (TO)' : ''), L.href, 0, 0, 191);
	}
}

function StartsWith(S1, S2){return (S1.substring(0, S2.length)==S2);}

function SetBodyCls(){
var Cls="";

if (Gec) Cls+=" FF"+(FFVer ? " FF"+FFVer : "");
if (Saf) Cls+=" Saf"+(Chrome ? " Chrome" : "");
if (IEVer) Cls+=" IE"+(" IE"+IEVer);
if (Quirks) Cls+=" Quirks";
//else if (Op) Cls+=" Op";

if (Cls) D.body.className+=Cls;
}

function DelCookie(Name, Path){
D.cookie=Name+"=;expires=Mon, 26 Jul 1997 05:00:00 GMT;path="+(Path ? Path : "/");
}

function GetPosRoot(){
return (D.getElementsByTagName((D.compatMode=='BackCompat') ? 'BODY' : 'HTML')[0]);
}

function AbsPos(O, Parent){
var X=0, Y=0, Next;

Next=O; if (Parent==null) Parent=D;
while (Next!=null && Next!==Parent){
	Y+=Next.offsetTop; X+=Next.offsetLeft; Next=Next.offsetParent;
	}
return [X, Y];
}

function ScrollTo(O, Where, NoFocus){
//Where={top, bottom, middle}
var Pos, Y, ObjH=O.offsetHeight, WinH=D.body.clientHeight, oRoot=GetPosRoot();

Pos=AbsPos(O); Y=Pos[1];

if (Where==null){
	if (Y<oRoot.scrollTop) Where='top';
	else if (Y+ObjH>oRoot.scrollTop+WinH) Where='bottom';
	}

if (Where=='middle'){
	if (ObjH>WinH) Where='top';
	else W.scrollTo(0, Y-Math.round((WinH-ObjH)/2));
	}
if (Where=='top') W.scrollTo(0, Y-1);
else if (Where=='bottom') W.scrollTo(0, Y+ObjH-WinH);

if (NoFocus!=true) W.focus(); 
return false;
}

function SetCookie(Name, Value, Time, Path){
var Res;

Value=Value.toString(); if (Value=="") Time=-1;
if (Time==null) Time=3600*24*30*3; //3 months
if (Path==null) Path="/";
aCookies[Name]=Value;

Res=Name+"="+escape(Value)+ //should escape but all values are Ok
	(Time!=0 ? ";expires="+_CookieDate(Time) : "")+";path="+Path;
D.cookie=Res; return false;
}

function _CookieDate(Time){
var DT=new Date();

if (Time!=null){
	End=new Date(Date.UTC(DT.getUTCFullYear(), DT.getUTCMonth(),
		 DT.getUTCDate(), DT.getUTCHours(), DT.getUTCMinutes(),
		 DT.getUTCSeconds())+Time*1000);
	}
else End=DT;
return End.toGMTString();
}

function GetCookies(){
aCookies=ReadCookies(); //if (aCookies==null) not sure!
}

function DecodeCook(v){
return unescape(v.replace(/[+]/g, ' '));
}

function ReadCookies(){
var Ck=D.cookie, i, Crumb, Len, Cookies, Val; 

if (!Ck) return [];
Ck=Ck.split('; '); Len=Ck.length; Cookies=new Array(Len);

for (i=0; i<Len; i++){
	Crumb=Ck[i].split("="); 
	if (Crumb.length==1) continue;
	Val=Crumb[1];
	if (Val.indexOf('%')!=-1) Val=DecodeCook(Val); //what about '+' ?!
	Cookies[Crumb[0]]=Val;
	}
return Cookies;
}

function istxt(o){
return (o.nodeType==3);
}

function nexttag(o, bCh){

if (!o) return o;
o=(!bCh ? o.nextSibling : o.firstChild);
if (o && istxt(o)) o=o.nextSibling;
return o;
}

//------ End - Utils

function ShowGeoTextInit(){
var pr;

if (sh_theme && (StateAbbr>='A' || ni_zc)){
	if (W.bwhfl) oSH.ht=getQueryStringVariable("t");
	pr=(W.sh_pr ? sh_pr : getQueryStringVariable("pr"));
	if (!pr){
		oSH.bBW=(
			oSH.bAu || oSH.bLf //&& Math.random()>=0.20
			//90% SH sent an abuse for this site
			//|| oSH.bAu && (Math.random()>=0.10 || L.hostname=="www.sermonsinsong.org")
			|| oSH.bHl && (W.bwhfl || Math.random()>=0.35)
			//|| sh_theme=='home' && Math.random()<0.25 //last test 22.12.2011
			);
		} 
	else if (pr=="bw") oSH.bBW=true;
	oSH.InsurPar='&pr='+(!oSH.bBW ? 'sh' : 'bw')+'&th='+oSH.aTheme[1].substr(0, 2);
	}
KTImg();

AddFormStyles();
if (W.CountryId==1 && !aCookies['showus'] && !oSH.bSHNoUK){
	AddUKStyles(); ShowGray('uk');
	}

//Just select state //if (W.bSH_AutoState)
if (!sh_theme || oSH.bFr){
	var F=FindForm();
	if (F){
		if (StateAbbr) F.statecode.value=StateAbbr;
		FixStates();
		}
	return false;
	}


return true;
}

function ShowGeoText(bAuto){
var Text='', State, Pretext, F, lnt_id, ImgCountry, aUKData, FlagLink;

//setTimeout("SendDebug()", 2000);
if (!ShowGeoTextInit()) return;
F=FindForm(); ImgCountry='usa'; 

if (bAuto){
	Pretext="Dear Customer, We value your business and do our best to save your time and efforts. Our system automatically identified you as a ";
	
	if (StateAbbr!='' && StateAbbr!='-'){
		State=(W.USState ? USState : (F ? GetSelOption(F.statecode, StateAbbr) : 'USA'));
		Text=Pretext+"resident of "+State+". The Top Providers that you see below are delivered based on this information. If you are not a resident of "+State+", please select another state to see <NOBR>relevant offers</NOBR>.";
		}
	else if (StateAbbr=='' || StateAbbr=='-'){
		var EndText="select your state to see the Top Providers for your area.";
		var AfterText='If you are a resident of the USA, please '+EndText;
		
		if (StateAbbr==''){
			if (W.CountryId==1 && !oSH.bSHNoUK){
				aUKData=GetUKData(); ImgCountry='uk'; FlagLink='<A HREF="'+aUKData[0]+'" Target=_blank';
				Text=Pretext+" resident of UK. Please "+FlagLink+">click here</A> for "+aUKData[1]+
					" insurance quotes in UK. "+AfterText;
				}
			else{
				Text=Pretext+"non-resident of the USA. Unfortunately we don't have relevant providers for your place of residence. "+AfterText;
				}
			}
		else Text=Pretext+'resident of the USA. Please '+EndText;
		}
	}

if (Text){
	var bNoFloat=(W.bUsaNoFloat); //  && IEVer==6 // && D.all[0].data.toLowerCase().indexOf('strict.')!=-1
	var DivSt='border:1px dotted black;text-align:justify;margin-bottom:15px;margin-top:'+
		(!W.bwhfl ? '7' : '0')+'px;color:black;font:11px Arial;';
	var ImgPath=oSH.ResBase+'images/'+ImgCountry+'-flag-sh.png';
	
	if (bNoFloat){ //IE6 strict wide pages: the bug with disappearing text
		D.write('<DIV Style="'+DivSt+'height1:38px;padding:7px 10px 7px 80px;background: white url('+
			ImgPath+') no-repeat 10px 10px;position:relative;" Id=FlagDiv>'+
			(!FlagLink ? '' : FlagLink+' Class=NoFloat></A>')+
			Text+'</DIV>');
		}
	else{
		D.write('<DIV Style="'+DivSt+'background-color:white;padding:7px 10px 10px 10px;" Id=FlagDiv>'
			+(!FlagLink ? '' : FlagLink+'>')
			+'<Img Src="'+ImgPath+'" ALIGN="left" Style="margin-right:12px;margin-top:3px;width:58px;height:35px;border:0;">'
			+(!FlagLink ? '' : '</A>')
			//This last div makes sure the usa image does not overlap the div's border
			+Text+'<Div Style="clear:left;font-size:0px;"></DIV></DIV>');
		}
	if (W.OnFlagDiv) OnFlagDiv();
	}

if (StateAbbr>='A' || ni_zc){
	//Only for 1 account
	if (sh_theme=='loan'){
		lnt_id=getQueryStringVariable('loantype');
		if (lnt_id) SetCookie('user_lnt_id', lnt_id);
		else{
			lnt_id=aCookies['user_lnt_id'];
			if (!lnt_id) lnt_id=(W.ni_lnt_id ? W.ni_lnt_id : 1); //default
			}
		ni_lnt_id=lnt_id; F.loantype.value=lnt_id;
		}
	else ni_lnt_id=1; //null

	if (F && StateAbbr) F.statecode.value=StateAbbr;
	if (sh_theme) ShowProviders();
	}
else{
	BWHFLEnd();
	if (W.SH_OnParse) SH_OnParse();
	}

if (!F) setTimeout('SH_FinishForm()', 250);
}

function SH_FinishForm(){
var F=FindForm();

if (!F){
	if (++oSH.FFCnt<60) setTimeout('SH_FinishForm()', 250); 
	return;
	}
F.statecode.value=StateAbbr;
if (sh_theme=='loan') F.loantype.value=ni_lnt_id;
FixStates();
}

function FindForm(){
var aForms, i, F;

aForms=D.getElementsByTagName('FORM'); 
for(i=0; i<aForms.length; i++){
	F=aForms[i];
	if (F.statecode) return F;
	}
return null;
}

function GetSelVal(Sel, O){
var aOpt=Sel.options, L=aOpt.length, i;
for(i=0; i<L; i++){if (aOpt[i].firstChild.data==O) return aOpt[i].value;}
return null;
}

function GetSelOption(Sel, Val){
var aOpt=Sel.options, L=aOpt.length, i;
for(i=0; i<L; i++){if (aOpt[i].value==Val) return aOpt[i].firstChild.data;}
return null;
}

function ShowProviders(){
var aVars, aVals=[], Var, Field, ValNum=0, bEsc, Wid, aPar;

if (!W.DayH){
	var DT=new Date(); DayH=DT.getUTCDate()+'.'+DT.getUTCHours();
	}
ni_trn_id=(W.bOff ? '-' : '')+DayH+(oSH.SEQ ? '|'+oSH.SEQ : '');

if (W.bSHCells) D.write('<td class="bg_white">&nbsp;</td><td width="100%" class="bg_textcenter">');
if (W.SH_PreHtml) D.write(SH_PreHtml);
if (Color=="-") KT_OE('No color', L.href, 0);
if (W.SH_PreShow) SH_PreShow();

oSH.TO=setTimeout("SH_TO()", 8000);

if (oSH.bBW) SH_BW();
else{
	if (StateAbbr) ni_str_state_code=StateAbbr; //getQueryStringVariable('statecode');
	
	if (oSH.bGr) ni_ad_client='32600'+oSH.aTheme[3];
	else ni_ad_client=oSH.ThId;
	
	ni_res_id=2; ni_alt_url="https://www."+SH_Host()+".com/search.asp";
	
	if (!W.ni_display_width){
		if (oSH.bLf || oSH.bGr) Wid=SH_SniffTempl();
		if (!Wid) Wid=500;
		ni_display_width=Wid; 
		}
	
	ni_display_height=1000; ni_color_border=""; ni_color_bg="";
	ni_color_link=""; ni_color_url=""; ni_color_text="";

	aVars={
		'ni_ad_client':'src',
		'ni_str_state_code':'ssc',
		'ni_zc':'zc',
		'ni_max_display':'max',
		'ni_page':'pg',
		'ni_res_id':'res',
		'ni_lnt_id':'lnt',
		'ni_var1':'!var1',
		'ni_tkpixel':'!tkpixel',
		'ni_tkurl':'!tkurl',
		'ni_ds':'!ni_ds',
		'ni_uc':'!ni_uc',
		'ni_sc_guid':'ni_sc_guid',
		'ni_trn_id':'trn_id'}; //!
	
	for(Var in aVars){
		if (W[Var]==null) continue;
		Field=aVars[Var];
		if (Field.charAt(0)=='!'){
			bEsc=true; Field=Field.substr(1);
			}
		else bEsc=false;
		aVals[ValNum++]=Field+'='+(bEsc ? escape(W[Var]) : W[Var]);
		
		if (Var=='ni_tkurl')
			aVals[ValNum++]='tkurlopt='+escape(ni_tkurl_options);
		}
	
	aPar=[];
	if (L.search.indexOf('statecode=')==-1) aPar.push('statecode='+StateAbbr);
	aPar.push('aid='+W.ni_var1);
	aVals[ValNum++]='ref='+escape(L.href+(L.search ? '&' : '?')+aPar.join('&'));
	//aVals[ValNum++]='ref='+escape(L.href+'?'+(StateAbbr ? 'statecode='+StateAbbr : '')
		//+'&aid='+W.ni_var1);
		//+'&x='+Math.round(Math.random()*85+15)+'&y='+Math.round(Math.random()*45+8));
	
	AddListingStyles();
	D.write(SH_GetScrTag(SHURL+'?'+aVals.join('&')));
	}

if (ni_zc) SH_SetZip();
oSH.StartTS=new Date; setTimeout('ParseResults()', 1);
}

var BWBase0="https://cdn.bwserver.net/";

function SH_BW(){
var PathId;

if (oSH.bGr){bwapsaid="11575"; bwapscid="3859"; PathId="11500";} //bwapscid="3838"; State Submit
else{bwapsaid="10891"; bwapscid="2150";  PathId="10800";}

var Css, Css2, pid, ChL, Scr1, Scr2,
	Base=BWBase0+PathId+"/"+bwapsaid+"/", 
	HH="http://cdn.healthcarecreatives.com/", 
	HSt="styles/bw-styles-health-"+bwapsaid+".css", HF="scripts/bw-header-function",
	HIF="www.healthinsurancefinders.com", LBW="listings.brokersweb.com",
	ARL="/aff/RenderListing.aspx", jsc="-"+bwapsaid+".js";

bw_CA="average"; Scr2="http://"+HIF+ARL;

if (oSH.bHl){
	Css=HH+"bw"+HSt; pid="200"; ChL="160"; Scr1=HH+"bw"+HF+jsc;
	if (oSH.ht){
		var s="individual:200;shortterm:210;group:220;dental:230;medicare:200;student:250", M;
		if (M=s.match(oSH.ht+':(\\d+)')) pid=M[1];
		}
	}
else if (oSH.bAu){
	Css=Base+"styles/auto.css"; //bw-styles-auto-bwapsaid.css - wider
	pid="300"; ChL=""; bw_CA="average"; bwgaoutbound=""; bwgaoutboundview="";
	bwapsadvex=""; //bwapsclickurl=LBW;
	Scr1=Base+HF+"-auto"+jsc; Scr2="http://"+LBW+ARL;
	bwapsStyleSitepreview=""; 
	}
else if (oSH.bLf){
	Css=Base+HSt; pid="260"; ChL="160"; Scr1=Base+HF+jsc;
	}
else if (sh_theme=='home'){
	pid="400"; ChL="160";
	//Css=Base+HSt; Scr1=Base+HF+jsc;
	Css=HH+"bw"+HSt; ChL="160"; Scr1=HH+"bw"+HF+jsc;
	}

bwapsprodid=pid; 
//bwapsSnippetCharsLimit=ChL; bwapsCTRRating="hide"; 

bwapsmaxads="6"; bwapsstyle="layout20";
bwapsSitePreview="hide"; bwapsDomainLogo="show";
bwapsGetQuotesButton="show"; bwapsPlanAvailable="hide";
bwapsSnippet="show:link"; bwapsTitle="show:link";
bwapsUrlDomain="show:link"; bwapszip=""; bwapsstate=""; 
bwapsprodidparam=""; 
bwapszipparam="zipcode"; bwapsstateparam="statecode"; bwapsclickurl="";

if (ni_zc) bwapszip=ni_zc; else if (StateAbbr) bwapsstate=StateAbbr; 

bwapsadsource=ni_trn_id+';'+ni_var1;
Css=Base+"styles/demo-serp.css";

if (FFVer) Css2=
	'https://'+HIF+'/JsSearchStyles.aspx?aid='+bwapsaid+'&cid='+bwapscid+'&Style='+bwapsstyle+'&ShowSitePreview='+
	bwapsSitePreview+(oSH.bAu ? '&StyleSitepreview='+bwapsStyleSitepreview : '')+'&ShowDomainLogo='+bwapsDomainLogo+
	'&ShowPlansAvailable='+bwapsPlanAvailable+'&ShowGetQuotes='+bwapsGetQuotesButton+'&ShowLinkSnippet='+bwapsSnippet+
	'&ShowLinkTitle='+bwapsTitle+'&ShowLinkUrlDomain='+bwapsUrlDomain;

AddListingStylesBW();
D.write(
	'<Link Rel=stylesheet HRef="'+Css+'">'+
	(FFVer>0 ? '<Link Rel=stylesheet HRef="'+Css2+'">' : '')+
	'<'+'Script Src="'+BWBase0+'scripts/jquery-1.3.2.min.js"><'+'/Script>'+
	'<'+'Script Src="'+Base+'scripts/bw-header.js"><'+'/Script>'
	);
}

function SH_SetZip(){
var aIn=D.getElementsByTagName('INPUT'), i, I;

for(i=0; i<aIn.length; i++){
	I=aIn[i];
	if (I.type!='text' || I.name!='zip') continue;
	I.value=ni_zc;
	I.style.backgroundImage='none';
	}
}

function SH_GetScrTag(URL){
return '<'+'Script Src="'+URL+'" Charset="ISO-8859-1"><'+'/Script>';
}

function AddFormStyles(){
D.write('<Style>'+
	'Select[name=statecode]{font-family:Arial;}'+
	'Form Input[type=submit][value=GO]{font:bold 13px Arial;cursor:pointer;}'+
	'#FlagDiv{clear:both;}'+
	'#FlagDiv A{color:blue;font:inherit;text-decoration:underline;}'+
	'#FlagDiv A:hover, #FlagDiv A:active{color:#1E90FF;background:transparent;}'+
	'#FlagDiv A.NoFloat{position:absolute;width:58px;height:35px;top:10px;'+
		(IEVer>6 ? 'left:10px;' : 'left:-71px;')+'}'+
	'Select#select{color:black;'+(!Saf ? '' : 'padding-left:2px;')+'}'+
	'</Style>');
}

function AddListingStyles(){
var S='', aR, i, RE, n, Tag, bOld=SH_OldLst();

if (IEVer) S=
	'#LT LI{TI:-20px;PD:0;}'+ //ML:20px;
	'#LT LI[type=square]{TI:-16px;}'+ //ML:16px;
	'.IE7 #LT LI, .IE6 #LT LI{TI:-16px;}'+ //ML:16px;
	'#LR Span > LI{ML:40px;TI:0;}'+ //, .FF #LR Span > LI
	'#LR Span > LI{PD-left:5px;}'+
	'#LT DIR LI{TI:0;}'+
	'.IE7 #LR Span > LI{TI:-16px;PD-left:0px;}';

if (Gec){ //FFVer
	S=
		'#LT LI{TI:-13px;ML:12px;PD-top:0;PD-bottom:0;}'+
		'.Quirks #LT LI{TI:-15px;ML:10px;}'+
		'#LT DIR LI, .Quirks #LT DIR LI{TI:0;}';
	//S+= if (oSH.bLf) || oSH.bGr?
		//'#SHlistings Div.listingDescriptionBody UL{list-style-position:outside;ML:14px;}';
	}

//-----

if (oSH.bGr && oSH.b15){
	S+='body .text1{padding-right:0px;} #FlagDiv{margin-right:15px;}';
	S+='body .space2{padding-left:40px;} body.'+sh_theme+' #SHlistings{position:relative;left:-33px;}';
	}

S+=
	'.Saf #LR TD > LI{ML:35px;TI:-12px;} #LR DIR LI{ML:-20px;}'+
	'#LR HR{border:0;height:1px;background-color:#707070;margin:0 0 5px 0;}'+
	'#LR BR{font-size:8px;}'+
	'#LR Img, #listingFooter Img, #listingsResults Img{float:none;}'+
	'#LR, #LT TD{color:black;vertical-align:middle;}'+
	//'#LR A:link, #LR A:visited{color:blue;font-family:Arial;}'+ //Verdana
	//'#LR A:hover, #LR A:active{color:blue;background:white;text-decoration:underline;}'+
	'#LR UL{margin-top:5px;PD-top:0;text-align:left;width:auto;height:auto;float:none;list-style-type:disc;border:0;}'+
	'#LR TD LI{background:none;list-style:disc inside none;PD-bottom:0;float:none;display:list-item;width:auto;}'+ //font:12px Verdana
	'#LR .listingDescriptionBody LI{PD:0;display:list-item;}'+
	
	'#LR Span > LI:first-child{margin-top:5px;}'+
	'#LT DIR{PD-left:24px;}'+
	'#LR P{PD-bottom:0;text-align:left;}'+
	'#SHlistings #listingHeading{color:black;float:none;font-family:Arial;font-size:18px;padding:0 0 '+
		(bOld ? '0' : '10px')+' 0;}'+
	'#listingsResults > Div P{text-align:center;}'+
	'#LR Div, #LR LI{line-height:normal;}'+
	'#LR .cstmBtn{float:left;padding-left:0;}'+
	'.shadCountWrapper{display:none;} Div.LT:hover, Div.LTAlt:hover{background-color:#'+
		(oSH.bGr ? 'F0FFF0' : 'FFFABF')+';}'+
	'Div.listingDescriptionBody{text-align:justify;}'+
	'Div.listDetailWrapper{font-family:Arial;}'+
	'.siteHost{font:11px Tahoma;} .listDetailWrapper .siteHostContainer{padding-top:4px;}'+
	'.listDetailWrapper .shadTitle{font-size:16px;}'+
	'#SHlistings #LR Div.listingDescriptionBody UL{margin-bottom:5px;}'
	//'#SHlistings{background-color:white;}'
	//'Html Body Div#SHlistings{display:block;} #SHlistings #mainHeader{display:none;}'+
	;

if (!bOld){
	if (IEVer>0){n=18; Tag='LI';}
	else{
		n=(oSH.bLf || oSH.bGr ? 13 : 12); Tag='LI';
		}
	if (n>0) S+='.listingDescriptionBody '+Tag+'{text-indent:-'+n+'px;margin-left:'+n+'px;}';
	}
else{
	if (Gec) S+='#LR UL{PD-left:0;ML:0;}';
	S+=
		'#LT Div Div{font:12px Arial;text-align:justify;margin:5px 0;cursor:pointer;}'
		+'#LT Div A{font:bold 16px Arial;color:#4169E1;}'
		+'#LT Div A:hover, #LT Div A:active{color:#1E90FF;text-decoration:underline;}'
		+'#LT{border:2px solid #C0C0C0;margin-top:-10px;} HR{display:none;} #LT TD:first-child{PD-left:5px;} #LT TD:first-child + TD{PD-top:5px;} #LT TD:first-child + TD + TD Img{position:relative;left:-5px;}'
		+'#LR #listingHeading{font-family:Arial;}'
		+'#LT:hover{background-color:#F8F8FF;border-color:#256EB4;}'; //#808080 #F8F8F8 #F0F8FF
		//#F8F8F8 #F0F8FF :first-child border-width:1px 0 0 1px;
	}

aR=['LR', 'listingResults', 'LT', 'listingTable', 'TI', 'text-indent', 'ML', 'margin-left', 'PD', 'padding'];
for(i=0; i<aR.length; i+=2){
	RE=RegExp(aR[i], "g"); S=S.replace(RE, aR[i+1]);
	}

if (oSH.bTeal) S+=SH_TealCss();
D.write('<Style>'+S+'</Style>');
}

function AddListingStylesBW(){
var S='', n;

S+='.bwapsListingSnippet UL{width:auto;height:auto;float:none;line-height:110%;padding-left:0;}'
	+'.bwapsListingSnippet LI{float:none;padding:0;display:list-item;width:auto;font-size:13px;color:black !important;}'
	+'#bwapsilisting{font-family:Arial,Helvetica,sans-serif;font-size: 12px;text-align:left;}' //instead of body
	//+'#bwapsilisting{line-height:normal;}'
	+'#bwst{white-space:nowrap;}'
	+'.IE.Quirks #bwapsilisting .bwapsListingGetQuotes, .IE6 #bwapsilisting .bwapsListingGetQuotes{left:260px;}'
	+'#bwapsilisting #bwapsheader{min-height:0;line-height:115%;}'
	+'#bwapsilisting .bwapsListingSnippet LI{overflow:visible;}'
	+'.bwvisited Div.bwapsListingGetQuotes A{position:relative;left:-36px;}'
	+'.bwvisited .bwapsListingSnippet A UL LI{color:#AAAAAA !important;}' //* HTML
	+'#bwapsilisting UL{border:0;} #bwapsilisting LI{display:list-item;} #bwapsilisting .bottom{padding:0;}' 
	//+'.bwapsListingDestinationUrl{font-size:11px;}'
	//+'#bwapsilisting .bwapstitle, #bwapsilisting .bwapsListingSnippet, #bwapsilisting .bwapsListingDestinationUrl{width:248px;}'
	//+'#bwapsilisting #liquid-round{width:520px;}'
	//+'#bwapsilisting{width:555px;}'
	//+'#bwapsilisting #Container{width:auto !important;}'
	;

if (IEVer>0) n=16; else n=12; //
if (n>0) S+='#bwapsilisting .bwapsListingSnippet UL{margin-left:'+n+'px;text-indent:-'+n+'px;}'; //list-style-type:disc;
if (oSH.bTeal) S+="Table.white #bwapsilisting{width:auto;}"+SH_TealCss();

D.write('<Style>'+S+'</Style>');
}

function SH_TealCss(){
return ".IE #zip.form1{line-height:150%;height:auto;padding-top:5px;padding-bottom:10px;}";
}

function SH_IsTealTempl(){
var aImg, i, aTbls=D.getElementsByTagName('TABLE'), bRow1, aSrc=[], Src, Pos, Row1, St, aStr, MNum=0;

if (aTbls.length>=2 && aTbls[0].className=='white'){
	Row1=aTbls[1].rows[0]; aImg=Row1.getElementsByTagName('IMG');
	bRow1=(aImg.length==6);
	}
if (!bRow1) return false;

St=Row1.cells[5].style; St.width="100%"; St.textAlign='left';

for(i=0; i<aImg.length; i++){
	Src=aImg[i].src; Pos=Src.lastIndexOf("/"); Src=Src.substr(Pos+1); 
	if (i==2){
		Pos=Src.length-12;
		if (Pos<0) Pos=0;
		Src=Src.substr(Pos);
		}
	aSrc.push(Src.substr(0, Src.length-4));
	}

Src=aSrc.join(";"); aStr=['top1', '_quotes', '_ins_top', 'partners', 'ins_types', 'top2'];
for(i=0; i<aStr.length; i++){
	if (Src.indexOf(aStr[i])!=-1) MNum++;
	}
return (MNum>=5);
}

function GetStatePar(){

if (aCookies["autoip2geodt"]) eval(aCookies["autoip2geodt"]);

//Given by filename
if (!ni_zc && !StateAbbr){
	//1. Get
	if (StateAbbr=getQueryStringVariable('statecode')){
		if (StateAbbr!=-1) SetCookie('user_state', StateAbbr);
		else{
			DelCookie('user_state'); StateAbbr=false; //DelCookie('user_ref'); 
			}
		DelCookie('autoip2geo');
		}
	//2. Cookies
	else StateAbbr=aCookies['user_state'];
	}

if (StateAbbr || ni_zc){
	ShowGeoText(false); return;
	}
if ((StateAbbr=SH_AutoGeo())!==false){
	ShowGeoText(true); return;
	}

//None - try auto
D.write('<'+'Script Src="'+oSH.ResBase+'ip2geo-sh.php"><'+'/Script>'); 
}

function SH_AutoGeo(){

if (!aCookies["autoip2geo"]) return false;
var Geo=aCookies["autoip2geo"];
//Sites may provide its own geo info, then use it
if (W.CustomAutoGeo && Geo!=W.CustomAutoGeo){
	Geo=W.CustomAutoGeo; SetCookie("autoip2geo", Geo);
	}
eval(Geo); return StateAbbr;
}

function SH_ToList(){
var oList=getbyid("list");

if (!oList){
	var aLinks=D.getElementsByName('list');
	if (aLinks.length) oList=aLinks[0];
	}
if (!oList) oList=getbyid(!oSH.bBW ?
	(SH_OldLst() ? "listingResults" : "SHlistings") : 'bwapsilisting');
if (oList) ScrollTo(oList, 'top');
}

function SH_OldLst(bLife){
if (oSH.bGr) return bLife;
return (sh_theme=='business' || sh_theme=='home' || (bLife && oSH.bLf));
}


function SH_BlkNum(){
var i, ChNum, BlkNum=0, oUL, aBlk, oCh;

if (oSH.bBW){
	while(true){
		if (!(oUL=nexttag(nexttag(oSH.ResDiv), true))) break;
		aBlk=oUL.childNodes; ChNum=aBlk.length;
		for(i=0; i<ChNum; i++) if (!istxt(aBlk[i])) BlkNum++;
		break;
		}
	}
else if (oUL=oSH.ResDiv){
	var Tag, Val, Prop;

	if (SH_OldLst(0)){
		Tag='TABLE'; Val='listingTable'; Prop='id';
		}
	else{
		Tag='DIV'; Val='shad'; Prop='className';
		}
	aBlk=oUL.childNodes; ChNum=aBlk.length;
	for(i=0; i<ChNum; i++){
		oCh=aBlk[i];
		if (oCh.tagName==Tag && oCh[Prop]==Val) BlkNum++;
		}
	}

if (BlkNum==0) KT_OEIns(188);
}

function KT_OEIns(EId, Msg){
KT_OE((!oSH.bBW ? 'sh' : 'bw')+':'+oSH.aTheme[1].substr(0, 2)+':'+StateAbbr+':'+aCookies['sv']+
	(!Msg ? '' : '; '+Msg), L.href, 0, false, EId);
}

function ParseResults(){
var oDiv, bBW=oSH.bBW, H, BlkNum, oUL;

oDiv=getbyid(!bBW ? 'listingResults' : 'bwapsheader');
if (!oDiv){
	if (!bBW && getbyid('SHerrorForm')); //errorMessage
	else{
		setTimeout('ParseResults()', 50); return;
		}
	}

oSH.EndTS=new Date;
if (oSH.TO){clearTimeout(oSH.TO); oSH.TO=0;}
oSH.ResDiv=oDiv; setTimeout('SH_BlkNum();', 1);

if (W.SH_OnParse) SH_OnParse();
if (oSH.LoadTryNo>1 && !bBW) KT_OE('Retry:OK', L.href, 0, 1);
if (!bBW && oDiv) FixResultsHtml(oDiv);

if (L.hash=='#list' || ni_zc || L.search.indexOf("statecode=")!=-1){ //aCookies['tolist'] || 
	setTimeout("SH_ToList()", 100); //DelCookie('tolist'); 
	}

if (!bBW){
	if (H=getbyid('listingHeading')) H.style.fontSize='18px';
	}

if (ni_zc){
	var M, State, F=FindForm();
	if (!bBW){
		if (H){
			if (!istxt(H.firstChild)) H=H.firstChild;
			M=H.firstChild.data.match(/Insurance Providers in (.*)$/i); State=M[1];
			}
		}
	else{
		H=getbyid('bwst'); if (H) State=H.firstChild.data;
		} 

	if (State){
		if (F) F.statecode.value=GetSelVal(F.statecode, State);
		}
	else KT_OE('Unknown zip: '+ni_zc, "http://www."+SH_Host()+".com", 0);
	}

if (bBW){
	setTimeout("SH_LoadRedImg();", 100); setTimeout("BWHFLEnd();", 1);
	}

if (oDiv)
	SetHandler("onclick", SH_OC, getbyid(bBW ? 'bwapsListListings': 'listingsResults'));

//if (D.referrer.indexOf('/?xurl=http://')!=-1) KT_OEIns(189, 'Time:'+Math.round((oSH.EndTS-oSH.StartTS)/100)/10);
}

function BWHFLEnd(){
var Text, oText;

if (W.bwhfl) D.body.style.cursor='default';
if (oText=getbyid('bwst')){
	oText=oText.nextSibling; Text=oText.data;
	if (Text.charAt(Text.length-1)=='.') oText.data=Text.substr(0, Text.length-1);
	}
}

function SH_LoadRedImg(){
var aImg=['top-on-red-v2.png', 'top-right-on-red-v2.png', 'rightside-on-red-v2.gif', 'bottom-on-red-v2.png', 'bottom-right-on-red-v2.gif'], i, oImg;

for(i=0; i<aImg.length; i++){
	oImg=new Image; oImg.src=BWBase0+'images/'+aImg[i];
	}
}

function FixResultsHtml(oDiv){
var aTags, aSubTags, P, Child, Sample, aSamples, Text, Html, RE, RE1, RE2, UL, TextBeg, LI, LI2, aTables=[], 
	TblNo, oTbl, SampleNo, aSpans, oSpan, FC, SpanPrnt, ULPrnt, aSpanCh=[], Tag, i, aBlocks, bOld, oBlock, 
	wd, bNrw, bWide, ExtraWid=0, DescrW, DetailW, LogoPad=0, St;

//oDiv.style.marginTop='10px'; 
bOld=SH_OldLst(true); //here +life
aBlocks=oDiv.childNodes;
//aBlocks=oDiv.getElementsByTagName('TABLE');

for(i=0; i<aBlocks.length; i++){
	Child=aBlocks[i]; 
	if (istxt(Child)) continue;
	if (!bOld){
		if (!(Child=Child.firstChild)) continue;
		}
	if (Child.id.indexOf("listingTable")==-1) continue;
	aTables.push(Child);
	}
aBlocks=false;

aSamples=[
	String.fromCharCode(160)+String.fromCharCode(8226),
	'? ',
	String.fromCharCode(65533)+' '
	];

//Analyze first block widths, get extra width for text
if (!bOld){
	oBlock=aTables[0]; wd=parseInt(oBlock.style.width); bNrw=(wd<500);
	
	if (bNrw){
		bNrw=false; //no more with smaller font version
		}
	
	if (bNrw){
		ExtraWid+=(500-wd); aTags=oBlock.childNodes; P=aTags[0];
		
		if (P.className=="listingLogo" && aTags[1].className=="listingDescription"){
			wd=parseInt(P.style.width); bWide=(wd>130);
			if (bWide) ExtraWid+=(wd-130);
			DescrW=(parseInt(aTags[1].style.width)+ExtraWid)+'px';
			DetailW=(parseInt(aTags[1].firstChild.style.width)+ExtraWid)+'px';
			St=(IEVer ? P.currentStyle : getComputedStyle(P, null));
			LogoPad=parseInt(St.paddingTop)+parseInt(St.paddingBottom);
			}
		}
	}

for(TblNo=0; TblNo<aTables.length; TblNo++){ //table=block
	oBlock=aTables[TblNo]; 
	
	if (!bOld){
		if (bNrw){
			oBlock.style.width='500px'; oBlock.style.paddingBottom='5px';

			if (bWide){
				aTags=oBlock.childNodes; 
				St=aTags[0].style; St.width='130px'; St.height='auto';
				aTags[1].style.width=DescrW;
				
				aSubTags=aTags[1].childNodes;
				aSubTags[0].style.width=DetailW;
				aSubTags[1].style.marginTop='15px';
				
				St.height=(aTags[1].offsetHeight-LogoPad)+'px';
				}
			}
		}

	aTags=oBlock.getElementsByTagName('LI');
	for(i=0; i<aTags.length; i++){
		P=aTags[i]; Child=P.firstChild;
		if (!Child) continue;
		if (!(Text=Child.data)) continue;
		if (Text.charAt(0)==' ') Child.data=Text.substr(1);
		Tag=P.parentNode.tagName;
		if (Tag=='SPAN' || Tag=='TD'){
			if (!aSpanCh[TblNo]) aSpanCh[TblNo]=[];
			aSpanCh[TblNo][i]=P;
			} 
		}
	
	aTags=oBlock.getElementsByTagName('P');
	if (aTags.length==0) continue;
	UL=false;

	for(i=0; i<aTags.length; i++){
		P=aTags[i]; Child=P.firstChild;
		if (!Child) continue;

		aSpans=P.getElementsByTagName('SPAN');
		if (aSpans.length){
			oSpan=aSpans[0]; FC=oSpan.firstChild;
			if (FC && istxt(FC) && FC.nextSibling==null) P.style.marginLeft='10px'; 
			}

		if (!(Text=Child.data)) continue;
		TextBeg=Text.substr(0, 2);
		
		for(SampleNo=0; SampleNo<aSamples.length; SampleNo++){
			if (TextBeg==aSamples[SampleNo]) break;
			}

		if (SampleNo>=aSamples.length) continue;
		Html=P.innerHTML.substr(2);

		if (!UL){
			UL=D.createElement("UL"); P.parentNode.insertBefore(UL, P);
			}
		
		LI=D.createElement("LI"); LI.innerHTML=Html; UL.insertBefore(LI, null);
		P.parentNode.removeChild(P); i--;
		}
	}

//Fix InsWeb block (create UL)
for(TblNo in aSpanCh){
	aTags=aSpanCh[TblNo]; ULPrnt=D.createElement("UL"); SpanPrnt=aTags[0].parentNode; 
	for(i=0; i<aTags.length; i++){
		LI=aTags[i]; Html=LI.innerHTML;
		if (IEVer && i==aTags.length-1){	
			Html=Html.replace('</SPAN>', ''); Html=Html.replace('<P></P>', '');
			}
		LI2=D.createElement("LI"); LI2.innerHTML=Html;
		ULPrnt.insertBefore(LI2, null); LI.parentNode.removeChild(LI);
		}
	SpanPrnt.insertBefore(ULPrnt, null);
	}

//Hide numbers and get rid of too high margins in "get quotes" buttons
if (SH_OldLst() && D.querySelectorAll){
	var w, i, aDivs=oDiv.querySelectorAll("Div .cstmBtn"), mg, Div;
	
	for(i=0; i<aDivs.length; i++){
		Div=aDivs[i]; Div.style.marginTop='10px';
		}
	
	if (IEVer){
		aDivs=oDiv.querySelectorAll("Div .listingLogo");
		for(i=0; i<aDivs.length; i++){
			Div=aDivs[i]; Div.style.height='auto';
			}
		}
	
	aDivs=oDiv.querySelectorAll("Div .listDetailWrapper");
	for(i=0; i<aDivs.length; i++){
		Div=aDivs[i]; w=parseInt(Div.style.width);
		if (w<=220) Div.style.width='220px';
		}
	
	}

if (Saf){ //Fix onclicks
	var TD, OC, aUL;
	for(TblNo=0; TblNo<aTables.length; TblNo++){
		oBlock=aTables[TblNo];
		if (bOld) oBlock=oBlock.rows[0].cells[1];
		aSpans=oBlock.getElementsByTagName('SPAN');
		if (!aSpans.length) continue;
		OC=aSpans[0].onclick;
		aUL=oBlock.getElementsByTagName('UL');
		if (!aUL.length) continue;
		aUL[0].onclick=OC;
		}
	}

if (IEVer>=8) FixLIBullets(oDiv);
}

function FixLIBullets(oDiv){
var aLI, i, j, oLI, oText, oSpan, aChild, oChild, FS, Type, bSq;

aLI=oDiv.getElementsByTagName('LI');
for(i=0; i<aLI.length; i++){
	oLI=aLI[i]; Type=oLI.currentStyle.listStyleType;
	if (Type!='disc' && Type!='square') continue;
	bSq=(Type=='square');
	if (!FS){
		FS=oLI.currentStyle.fontSize; 
		if (FS.charAt(FS.length-1)=='%') FS='12px'; 
		}

	oSpan=D.createElement('SPAN'); oSpan.style.fontSize=FS;
	aChild=oLI.childNodes;
	
	for(j=0; j<aChild.length; j++){
		oChild=aChild[j];
		oSpan.insertBefore(oChild, null);
		}
	oLI.insertBefore(oSpan, oLI.firstChild); oLI.style.fontSize=(!bSq ? '13px' : '10px');
	if (!bSq) oLI.style.lineHeight='110%';
	}
}

function GoTheme(ThemeId){

SetCookie('themeid', ThemeId, 0); //SetCookie('tolist', 1, 0);
if (L.pathname=='/' || W.bGoThemeSamePage) L.reload();
else L.href='http://'+L.host+'/';
return false;
}

function KTImg(){

if (oSH.bFr) return;
//if (oSH.bGr) return;
if (bKT || getbyid('KTImg')) return;
var uid, i, R="", S, E, RE, SE, Q='', M, SN=0, SE0, Q0, bSE, oImg, SE2, Q2, Host;

uid=aCookies['kt_uid']; i=aCookies['kt_se'];
if (i && (M=i.match("^([^:]+):([^:]+):(.*)"))){
	SN=M[1]; SE0=M[2]; Q0=M[3];
	}

R=D.referrer; if ((i=R.lastIndexOf("#"))!=-1) R=R.substr(0, i); 
if (R && !R.match("^https?://"+L.host)){
	//SE & Referrer
	S="^https?://([^/]*[.])?"; E="=([^&]+)"; 
	aRE=[
		S+'(google|alltheweb[.]com|ask[.]com|altavista|msn|bing[.]com|alexa[.]com|infoseek|search[.]live[.]com)([.][^/]+)?/.*[?&](q)'+E,
		S+'(search[.]yahoo)([.][^/]+)?/.*[?&](p)'+E,
		S+'(aol|search[.]lycos|search[.]netscape|mamma[.]com|hotbot[.]com)([.][^/]+)?/.*[?&](query|encquery)'+E,
		S+'(webcrawler|excite[.]com|infospace[.]com)([.][^/]+)?/.*/(web)/([^/]+)'];
	
	for(i=0; i<aRE.length; i++){
		RE=new RegExp(aRE[i], "i");
	 	if (!(M=R.match(RE))) continue;
		SE=M[2]; Q=M[5]; break;
	 	}

	if (SE){
		if (SE=='search.live.com' || SE=='bing.com' || SE=='Bing.com') SE='msn';
		else if (SE.substr(0, 7)=="search.") SE=SE.substr(7);
		}
	else{
		M=R.match("^https?://([^/:]+)"); SE=M[1];
		}
	}

bSE=(SE && (SE!=SE0 || Q!=Q0));
if (!uid || bSE){
	if (!uid){
		uid=Math.random().toString().substr(2); SetCookie("kt_uid", uid, 259200); //D.cookie="kt_uid="+uid+CS;
		}
	if (bSE) SetCookie("kt_se", (++SN)+":"+SE+":"+Q, 259200);
	//D.cookie="kt_se="+((++SN)+":"+SE+":"+Q)+CS; //Q is escaped in referrer!
	}

if (!IEMob) oImg=D.createElement('IMG'); else oImg=new Image();

oImg.style.position='absolute';
oImg.style.visibility='hidden'; oImg.style.width='0px';
oImg.id='KTImg';

D.body.insertBefore(oImg, D.body.firstChild); 
Host=SH_Dec(oSH.bGr ? "usbdlodporvfs" : "lfztusbdlfs");

oImg.src='http://www.'+Host+'.com/h.png?uid='+uid+'&sn='+SN+'&s=d&url='+escape(L.href)+
	'&ref='+escape(R)+oSH.InsurPar+'&n='+Math.random().toString().substr(2, 4);

if (sh_theme){
	if (SE && Q){SE2=SE; Q2=Q;} else if (SE0 && Q0){SE2=SE0; Q2=Q0;}
	if (SE2 && Q2){
		if (SE2=='google') SE2='g'; else if (SE2=='yahoo') SE2='y'; else if (SE2=='msn') SE2='m';
		//leave some chars escaped here to pass them correctly, decode later
		oSH.SEQ=SE2+"|"+Q2.replace(/([+]|%20)/g, ' ').replace(/ /g, '|');
		}
	}

KT_UId=uid+"-"+SN; bKT=true;
}

function SH_Dec(Str){
var i, Res="";
Res=""; for(i=0; i<Str.length; i++) Res+=String.fromCharCode(Str.charCodeAt(i)-1);
return Res;
}

function KT_OE(Msg, URL, LineNo, bForce, EId){
var bShort;

if (URL.substr(0, 5)=='file:') return true;
if (URL.substr(0, 7)=='chrome:') return true;
if (URL.substr(0, 27)=='http://translate.google.com') return true; //G.transl.

bShort=EId;
if (!EId) EId=158;

//No need to know/show
if (Msg.indexOf('WidgetManager')!=-1) return true;
else if (Msg=='Error loading script'){ //FF
	if (URL.indexOf("http://www.blogger.com/widgets/")==0) return true;
	//Try reload these
	if (URL=="http://www.google-analytics.com/urchin.js"){
		if (!aErrScr[URL]){
			aErrScr[URL]=true; D.write("<Script Src='"+URL+"'></"+"Script>"); return true;
			}
		}
	//Sometimes listings aren't loaded in that case I retry
	else if (oSH.LoadTryNo<=2 && URL.indexOf(SHURL)==0){
		oSH.LoadTryNo++; D.write(SH_GetScrTag(URL+'&n='+oSH.LoadTryNo)); return true;
		}
	}

//if (W.oEBImg && !bForce) return false;
if (oSH.ErrNum>=10 && !bForce) return false;

oEBImg=D.createElement('IMG'); oSH.ErrNum++;
oEBImg.src="http://"+SH_EBH()+".com/handler.php?e="+EId+"&descr="+
	escape(L.href)+KT_Line(Msg)+
	(!bShort ? KT_Line(URL+' line '+LineNo) : '')+
	KT_Line(W.navigator.userAgent)+KT_Line('Ref:'+D.referrer)+
	(!bShort ? KT_Line('<HR>') : '');
return false; //Do show the message for us to see it
}

function SH_EBH(){
return SH_Dec(oSH.bGr ? "fchso" : "ktfsspst/gppmqsppgtfswfst");
}

function SH_Host(){
return SH_Dec(oSH.bGr ? "tinluqm" : "ofyujotvsf");
}

function KT_Line(Line){return escape("\n"+Line);}

function FixStates(){
var aSel, i, oSel, j, oOpt, State, aOptO, Val;

aSel=D.getElementsByTagName('SELECT');

for(i=0; i<aSel.length; i++){
	oSel=aSel[i];
	if (oSel.options.length<2) continue;
	Val=oSel.options[1].value;
	if (Val!="AK" && Val!="AL") continue; //Alaska 1st!
	aS=[]; aOpt=oSel.options; Val=oSel.value;
	
	for(j=1; j<aOpt.length; j++){
		oOpt=aOpt[j];
		State=(oOpt.value!="DC" ? oOpt.text : "District of Columbia");
		aS[j-1]=[oOpt.value, State];
		}
	aS.sort(StateCB);
	for(j=1; j<aOpt.length; j++){
		oOpt=aOpt[j]; oOpt.value=aS[j-1][0]; oOpt.text=aS[j-1][1];
		}

	if (StateAbbr){
		aOpt[0].text='Auto Select...'; aOpt[0].value=-1;
		}

	//Restore after mixing
	oSel.value=Val;
	break;
	}

delete aS;
}

function StateCB(a1, a2){
return (a1[1]<a2[1] ? -1 : (a1[1]>a2[1] ? 1 : 0));
}

function SH_TypeId(T){
var Ids=SH_TypeCodes(), Id;

for(Id in Ids){
	if (Ids[Id][1]==T) return Id;
	}
}

function SH_TypeCodes(){
//sh-insur.txt!!
return {2663: ['001;car', 'auto', 'car', 0], 2670: ['0049;business', 'business', 0, 5], 
	2665: ['0013;health', 'health', 'medical', 1], 2666: ['004;home', 'home', 0, 2], 
	2668: ['0012;life', 'life', 0, 3], 0: ['003;generic', "generic"], 0: ['003;generic', "loan"]};
}

function SH_AutoUKTheme(){
var Id, T=D.title, aW=[], aT, RE, M, KW, aThemes=SH_TypeCodes();

if (!T.match(/insur/i)){
	T=W.location.href; if (!T.match(/insur/i)) return 0; 
	}

for(Id in aThemes){
	aT=aThemes[Id]; aW.push(aT[1]);
	if (aT[2]) aW.push(aT[2]);
	}
RE=new RegExp("("+aW.join("|")+").*insurance", "i");
if (!(M=T.match(RE))) return 0;

KW=M[1].toLowerCase();
for(Id in aThemes){
	aT=aThemes[Id]; if (aT[1]==KW || aT[2]==KW) return aT;
	}
}

function GetUKData(){
var aParams, Domain, Theme;

if (sh_theme) aParams=oSH.aTheme;
else if (!(aParams=SH_AutoUKTheme())) KT_OE('AutoUKTheme failed', L.href, 0);

if (!sh_theme) aParams[1]=false;
Domain=L.hostname.replace('www.', '');

return ['http://www.quotezone.co.uk/SetAffiliate.php?aid='+SH_Dec(oSH.bGr ? 'C:X6I5' : 'D9N9D8')+'-'+
	aParams[0].replace(";", "&type=")+'&kw='+Domain, aParams[1]];
}

//------- 3rd party utils

function ValidateForm(F){
var strErr, tmpZip;

if (!F) F=D.getQuoteForm;
strErr=""; tmpZip=trim(F.zip.value);

F.zip.value=tmpZip;
if (tmpZip.search(/^\d{5}/) == -1 || tmpZip.length > 5){
	strErr=strErr + "Zip Code is required and must be in the format 00000.\n";
	}

if (strErr!=""){
	alert(strErr); F.zip.focus(); return false;
	}

preserveRefby(F); return true;
}
 
function preserveRefby(F){
var QS=L.search.substring(1).toLowerCase(), Pos1=QS.indexOf("refby="), Pos2, Refby="";

if (Pos1>=0) Pos2=QS.indexOf("&", Pos1+6); else Pos2=-1;   
if (Pos2>0) Refby=QS.substring(Pos1+6, Pos2);
else if (Pos1>=0) Refby=QS.substring(Pos1+6, QS.length);

if (Refby.length>0){
	if (F.Refby) F.Refby.value=Refby;
	}
}

function SetRefBy(){
var aIds=['terms', 'privacy'], i, A, RefBy, o;

for(i in aIds){
	if (!(A=getbyid(aIds[i]))) continue;
	if (A.href.indexOf('Refby=')!=-1) continue;
	
	if (!RefBy){
		if (!(o=getbyid("Refby"))) return;
		if (o.length){
			o=o[0]; KT_OE('SetRefBy(): more than 1 Refby', L.href, 0);
			}
		RefBy=o.value;
		}
	
	A.href=A.href+"?Refby="+RefBy;
	}
}

function getQueryStringVariable(Param){

if (typeof aGetVars=="object") return aGetVars[Param];
var aParams, Len, i, Crumb;

aParams=L.search.substring(1).split('&'); Len=aParams.length; aGetVars=new Array(Len);
for (i=0; i<Len; i++){
	Crumb=aParams[i].split("="); 
	if (Crumb.length==1) continue;
	aGetVars[Crumb[0]]=unescape(Crumb[1].replace(/\+/g, ' '));
	}
return aGetVars[Param];
}

//------- End - 3rd party utils

function ShowGray(Type){
var oDiv, oRoot, St, bFst;

if (Quirks) oRoot=D.body; else oRoot=D.getElementsByTagName('HTML')[0];

if (IEVer==6 || IE7Q){
	if (sh_theme){
		if (oSH.PageH!=oRoot.scrollHeight){
			oSH.PageH=oRoot.scrollHeight; setTimeout("ShowGray(Type)", 333); return;
			}
		}
	}

if (!oGrayDiv){
	//The Gray BG
	bFst=true; oDiv=D.createElement('DIV'); St=oDiv.style;
	St.backgroundColor='black'; St.zIndex='1100';

	if (IEVer) St.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
	else St.opacity='0.5';

	if ((IEVer>=7 && !IE7Q) || FFVer || Saf){
		St.position="fixed"; St.width='100%'; St.height='100%';
		}
	if (IEVer==6 || IE7Q){
		St.position="absolute"; St.width=oRoot.scrollWidth; St.height=oRoot.scrollHeight;
		}
	St.top='0px'; St.left='0px'; 
	}

if (IEVer==6 || IE7Q) ShowSelects(false);

if (bFst){
	oGrayDiv=oDiv; D.body.insertBefore(oGrayDiv, D.body.firstChild); 
	//Content
	oDiv=D.createElement('DIV'); St=oDiv.style; St.visibility='hidden'; St.zIndex='1101';
	St.position=(IEVer!=6 && !IE7Q ? "fixed" : "absolute"); 
	St.top='50%'; St.left='50%'; oGrayIn=oDiv;
	}

if (Type=='uk'){
	oGrayIn.innerHTML=GetUKMsgHtml(GetUKData()); oGrayIn.id='UKMsg'; 
	}
else if (Type=='bwhfl'){
	var oBWH=getbyid('BWH');
	if (!oBWH){
		oGrayIn.innerHTML='<Iframe Name=BWH Id=BWH FRAMEBORDER=0 Width=700 Height='+(oRoot.clientHeight-75)+'></Iframe>'; 
		oGrayIn.style.backgroundColor='white';
		}
	else{
		setat(oBWH, 'height', oRoot.clientHeight-75);
		}
	setTimeout('W.BWH.location.replace("'+'http://'+W.location.host+'/commonres/sh/bwhfl-2.html?t='+BWHType+'"); W.BWH.focus();', 1);
	}

if (bFst){
	D.body.insertBefore(oGrayIn, D.body.firstChild); 
	setTimeout("FixFlashes();", 1); 
	}
else{
	oGrayIn.style.visibility='hidden'; oGrayIn.style.display='block'; oGrayDiv.style.display='block';
	}
setTimeout("ShowGrayEnd()", 1);
oSH.BlkType=Type;
}

function ShowGrayEnd(){
var St=oGrayIn.style;

St.marginLeft='-'+Math.round(parseInt(oGrayIn.scrollWidth)/2)+'px';
St.marginTop='-'+(Math.round(parseInt(oGrayIn.scrollHeight)/2)+(oSH.BlkType=='uk' ? 50 : 0))+'px';
St.visibility='visible'; 
}

function ShowSelects(bShow){
var aSel=D.getElementsByTagName('SELECT'), i, Vis=(bShow ? 'visible' : 'hidden');
for(i=0; i<aSel.length; i++) aSel[i].style.visibility=Vis;
}

function GetFlashParam(oFlash, Param, bObj){
var aCh, k, Ch;

aCh=oFlash.childNodes;
for(k=0; k<aCh.length; k++){
	Ch=aCh[k];
	if (Ch.nodeName!='PARAM') continue;
	if (getat(Ch, 'name')==Param){
		if (bObj) return Ch;
		return getat(Ch, 'value').toLowerCase();
		}
	}
}

function GetFlashes(){
var aTags, i, j=0, aFl=[], oFl, P, Prnt, At, OK, oFlash;

aTags=D.getElementsByTagName('OBJECT');
for(i=0; i<aTags.length; i++){
	while(true){
		OK=false; oFlash=aTags[i];
		if (IEVer){
			At=getat(oFlash, 'codebase');
			if (At){
				if (At.indexOf("flash")!=-1) OK=true;
				break;
				}
			if (GetFlashParam(oFlash, 'movie')){
				OK=true; break;
				}
			}
		At=getat(oFlash, 'type'); //in FF with type
		if (At && At.indexOf("flash")!=-1) OK=true;

		break;
		}
	if (OK) aFl[j++]=oFlash;
	}

if (IEVer) return aFl;

aTags=D.getElementsByTagName('EMBED');
for(i=0; i<aTags.length; i++){
	oFlash=aTags[i]; At=getat(oFlash, 'type');
	if (At && At.indexOf("flash")!=-1) aFl[j++]=oFlash;
	}
return aFl;
}

function FixFlashes(){
var i, aFl, oFl, Tag, oClone, P, Prnt, Val;

aFl=GetFlashes(); 

for(i=0; i<aFl.length; i++){

	oFl=aFl[i]; Tag=oFl.tagName;
	if (Tag=='OBJECT'){
		P=GetFlashParam(oFl, 'wmode', true);
		if (P) Val=getat(P, 'value').toLowerCase(); else Val='';
		if (Val=='opaque') continue;
		if (P) setat(P, 'value', 'opaque');
		else{
			P=D.createElement("PARAM"); P.name="wmode"; P.value="opaque"; oFl.insertBefore(P, null);
			}
		}
	else{
		if (getat(oFl, 'wmode')=='opaque') continue;
		setat(oFl, 'wmode', 'opaque');
		}
	
	oClone=oFl.cloneNode(true);
	if (Tag=='OBJECT'){
		if (!P){
			//P=D.createElement("PARAM"); P.name="wmode"; P.value="opaque"; oClone.insertBefore(P, null);
			}
		}
	//else setat(oClone, 'wmode', 'opaque');
	Prnt=oFl.parentNode; Prnt.insertBefore(oClone, oFl); Prnt.removeChild(oFl);
	}
}

function AddUKStyles(){

D.write(
	'<Style>'+
	'#UKMsg{border:1px solid #D4D0C8;border-right-color:#808080;border-bottom-color:#808080;}'+
	'#UKMsg Div{padding:0;margin:0;}'+
	'#UKMsg .border2{border:1px solid white;border-right-color:#D4D0C8;border-bottom-color:#D4D0C8;}'+
	'#UKMsg .border3{border:1px solid #D4D0C8;border-right-color:white;border-bottom-color:white;}'+
	'#UKMsg .border4{border:1px solid #808080;border-right-color:#D4D0C8;border-bottom-color:#D4D0C8;padding:15px;background-color:white;}'+	
	'#UKMsg H1{font:bold 22px Georgia;color:#760404;margin-bottom:10px;}'+
	'#UKMsg TD{font:16px Georgia;}'+
	'#UKMsg .Flag{width:150px;height:113px;background-image:url('+
		oSH.ResBase+'images/uk-usa-flags-sh.jpg);text-align:left;}'+
	'#UKMsg .Flag A{position:absolute;width:150px;height:113px;}'+
	'#UKMsg .US{background-position:-150px 0px;}'+
	'#UKMsg .btmrect{background-color:#FBFBFB;text-align:center;border: 1px solid #EBEBEB;}'+
	'#UKMsg TD{padding:20px;}'+
	'#UKMsg TD A{text-decoration:underline;font:inherit;background:transparent;}'+
	'#UKMsg TD A:link, #UKMsg TD A:visited{color:#3E7EB3;}'+
	'#UKMsg TD A:hover, #UKMsg TD A:active{color:#0000CD;}'+
	'</Style>');
}

function CloseUKMsg(){

oGrayIn.style.display='none'; oGrayDiv.style.display='none';
if (IEVer==6 || IE7Q) ShowSelects(true);

if (oSH.BlkType=='uk'){
	oGrayIn.innerHTML='&nbsp;'; SetCookie('showus', 1, 0); UKClick();
	}
else if (oSH.BlkType=='bwhfl') W.BWH.location.replace("about:blank");

return false;
}

function UKClick(A){
var Scr=D.createElement('SCRIPT'), eid=(A ? 162 : 161);

if (A){
	oGrayIn.style.cursor='wait'; A.style.cursor='wait'; UKA=A; 
	}

D.body.insertBefore(Scr, null);
Scr.src="http://"+SH_EBH()+".com/handler.php?e="+eid+"&descr="+escape(L.href);
if (A) UKTO=setTimeout('GoUK(1)', 5000); 
return false;
}

function GoUK(bTO){

if (!bTO) clearTimeout(UKTO);
if (Gec) L.href=getat(UKA, 'url'); 
else{
	UKA.onclick=null; UKA.href=UKA.url; UKA.click();
	}
oGrayIn.style.cursor=''; UKA.style.cursor='';
}

function GetUKMsgHtml(aUKData){

return '<DIV Class=border2><DIV Class=border3><DIV Class=border4><table width="600" cellspacing="0">'+
	'<tr><td colspan="2" align="center" Style="padding-bottom:0px;"><h1>Dear visitor,</h1>'+
		'<Center>This website is USA-oriented. We identified that you visit us from UK. To get the UK '+
		(aUKData[1] ? aUKData[1] : '')+' insurance quotes, '+
		'<a href=# url="'+aUKData[0]+'" onclick="return UKClick(this)">proceed to another website</a>.</Center></td></tr>'+
	'<tr><td align="right"><DIV Class="UK Flag"><a href=# url="'+aUKData[0]+'" onclick="return UKClick(this)"></a></DIV></td>'+
	'<td align="left"><DIV Class="US Flag"><a href=# OnClick="return CloseUKMsg()"></a></DIV></td></tr>'+
	'<tr><td colspan="2" class="btmrect">If you wish to continue browsing the original USA website, '+
		'<a href="#" OnClick="return CloseUKMsg()">please click here</a>.</td>'+
	'</tr></table></DIV></DIV></DIV>';
}

function SH_Life(){

D.write('<Iframe FRAMEBORDER=0 Height=976 Width=791 SCROLLING="No" Src="http://j.jiuyt.com/cgi/r?;n=203;c=623006;s=7636;x=7936;f=201006181207370;u=j;z=TIMESTAMP"></Iframe>');
var aSel=D.getElementsByTagName('SELECT'), i, oSel, o;

for(i=0; i<aSel.length; i++){
	oSel=aSel[i];
	if (oSel.name!="statecode") continue;
	
	o=oSel;
	while(o){
		o=o.parentNode;
		if (o.tagName=='FORM'){
			o.style.display='none'; break;
			}
		}
	break;
	}
}

function SH_SniffTempl(){
var Wid, aImg=D.images, aScr, i, aTD;

while(true){
	
	if (aImg.length>=2){
		if (aImg[1].src.indexOf("/commonres/sh/")!=-1) Wid=555;
		else if (aImg[aImg.length-1].src.indexOf("/imaged/1-5/")!=-1){
			Wid=650; oSH.b15=true;
			}
		if (Wid) break;
		}

	aTD=D.getElementsByTagName('TD');
	if (aTD && aTD.length && aTD[0].className=='bg_top_orange'){Wid=700; break;}

	aScr=D.getElementsByTagName('SCRIPT'); 
	if (aScr && (i=aScr.length)){
		var P, St, Pad;
		
		P=aScr[i-1].parentNode;
		if (P.tagName=='P') P=P.parentNode;

		St=(!Gec ? P.currentStyle : getComputedStyle(P, null));
		Pad=parseInt(St.paddingRight)+parseInt(St.paddingLeft);
		Wid=P.offsetWidth-(Pad>0 ? Pad : 15);
		if (Wid<500) Wid=500; else if (Wid>700) Wid=700; 
		}

	break;
	}

return Wid;
}

function SH_OC(e){
var Tag, bClk=true, Cls;

if (oSH.bClk) return;
EventInit(e); Tag=EvSrc.tagName;

while(true){
	if (Tag=='A' || Tag=='IMG' || Tag=='LI' || Tag=='SPAN' || Tag=='UL') break;
	if (!oSH.bBW && Tag=='DIV'){
		Cls=EvSrc.className;
		if (Cls=='listingLogo' || Cls=='listDetailWrapper' || Cls=='listingLogoWrapper'
		 || Cls=='listingDescriptionBody' || Cls=='listDetailWrapper') break;
		}
	return;
	}
KT_OEIns(190); oSH.bClk=true;
}

function SH_TO(){
oSH.TO=0; KT_OEIns(184);
}

function Debug(s){
if (!bDev) return;
alert(s);
}

function SendDebug(){
if (!bDev) return;
KT_OE(aD.join("\n"), "debug", 0, true);
}

function SH_ShowMenuA(bGoOn){
var aDivs, A;

if (!bGoOn){
	if (!D.querySelectorAll) return;
	D.write('<Style>A.ml, A.ml:visited{position:fixed;left:0;top:0px;text-decoration:none;color:#696969;}</Style>');
	}
if (sh_theme && !oSH.EndTS){
	setTimeout('SH_ShowMenuA(1)', 100); return;
	}

aDivs=D.querySelectorAll("Div.of, Div.ld, Div.up, Div.al");
if (!aDivs || aDivs.length==0) return;
A=D.createElement('A'); A.className='ml';
A.appendChild(D.createTextNode(String.fromCharCode(0x25CF))); A.href='javascript:SH_Menu()';
D.body.insertBefore(A, null); oSH.oMenu=aDivs[0];
}

function SH_Menu(){
var Cls, oMenu=oSH.oMenu;

if (Cls=oMenu.className){
	oMenu.className=''; setat(oMenu, 'cls', Cls); oMenu.style.clear='both';
	W.scrollTo(0, 10000);
	}
else oMenu.className=getat(oMenu, 'cls'); 
}

function SHGo(){

bSH=true; InitSH(); W.onerror=KT_OE; aErrScr=[]; InitUA();
//Should be before ShowGeoText()
//KTImg();

if (true){ //sh_theme || W.bSH_AutoState
	if (oSH.bLIP){
		KTImg(); SH_Life();
		}
	else{
		GetStatePar(); FixStates();
		}
	}
else{
	//KTImg();
	//if (!W.bSHNoGeo) D.write('<'+'Script Src="'+oSH.ResBase+'ip2geo-sh.php"><'+'/Script>');
	}
setTimeout('SetRefBy();', 1);
if (W.bOff) SH_ShowMenuA();
}

//---------
if (!bSH) SHGo();


