// JavaScript Document
function changeLink() {
for (i=0; i<10; i++) {
u = "0"+i;
idcontainer = 'RepeaterAdListing20_ctl'+u+'_bwapslistingContainer';
idtitle = 'RepeaterAdListing20_ctl'+u+'_bwapsListingTitleLink';
//idsnippet = 'RepeaterAdListing20_ctl'+u+'_bwapsListingSnippet';
idurl = 'RepeaterAdListing20_ctl'+u+'_bwapsListingDestinationUrlLink';
idlogo = 'RepeaterAdListing20_ctl'+u+'_bwapsListingDomainLogoLink';
idbutton = 'RepeaterAdListing20_ctl'+u+'_bwapsListingGetQuotes';
idbullet = 'bulletNmbr'+u;
var container=document.getElementById(idcontainer);
var title=document.getElementById(idtitle);
//var snippet=document.getElementById(idsnippet);
var url=document.getElementById(idurl);
var logo=document.getElementById(idlogo);
var button=document.getElementById(idbutton);
var bullet=document.getElementById(idbullet);
if(container != null) {
resultLink = title.childNodes[0].getAttribute('href');
bullet.childNodes[0].href = resultLink;
} else {i=10;}
}
}
function updateStyleListings(){
	var classUlContainer = "bwapsListListings";
	var classListingContainer = "bwapslistingContainer";		
	var i = 1;
	var j = i - 1;
	var topHtmlCode = '<div class="bulletNmbr" id="bulletNmbr0'+j+'"><a href="" target="_blank">#'+i+'</a></div>';
	var ulContainer = $("."+classUlContainer);
	$(ulContainer).children().each(function() {	    
		$(this).append(topHtmlCode);
		i++;
		j++;
		topHtmlCode = '<div class="bulletNmbr" id="bulletNmbr0'+j+'"><a href="" target="_blank">#'+i+'</a></div>';//<div class="center-content">';
	});
    changeLink();
}

function getElementsByClassName(className) {
    var match = new RegExp('(^|\\\\s)' + className + '(\\\\s|$)');
    var matchingTags = new Array();
    var allTags = document.getElementsByTagName('*');
    for (var i = 0; i < allTags.length; i++) {
        if (match.test(allTags[i].className)) {
            matchingTags.push(allTags[i]);
        }
    }
    return matchingTags;
}

document.write(unescape("%3Cscript type='text/javascript' language='javascript' src='http://cdn.healthcarecreatives.com/scripts/gup.js' %3E %3C/script%3E "));
//bwapsmaxads = "8";

window.onload = function() {
var element = getElementsByClassName('bwapsproductstate');
titletext=element[0].lastChild.data;
stringprod = "";
state = "";
bw_a_prodid = product=gup('prodid');
	if (bwapsprodid != "") product=bwapsprodid;
	else if (bw_a_prodid =="" && bwapsprodid =="") product='200';
	else {
		bw_a_prodid;
	}
	if (bwapszip != "") zcode=bwapszip;
	else if (bwapszip =="") zcode = gup('zip');

switch (product){
	case '200':
	state=titletext.replace(" Individual and Family Health Insurance","");
	stringprod = " Health Insurance";
	break;

}
var newTag = document.createElement("span");
if (typeof bw_CA !="undefined"){
	switch (bw_CA){
		case 'average':
		newTag.innerHTML = "We have matched you with the top rated <span style=\"color:#CC0000;\" id=\"bwprod\">"+state+"</span> Health Insurance companies to help you <span style=\"color:#CC0000;\" id=\"bwprod\">Lower your Rates</span>:";
		break;
	}
}
else{
}
    element[0].lastChild.data="";
    element[0].appendChild(newTag);
    updateStyleListings();
    $("#bwapsref a").html("Powered By BrokersWeb");
    $("#bwapsref").css("background-position", "400px -9px");
}


