//set the horiz nav hightlight
if(horiz_bkg && document.getElementById){
	if (horiz_bkg == "ll") {
		document.getElementById("b_about").src = "/advisorchoice/images/b_about_.gif";
	}
	else if (horiz_bkg == "l") {
		document.getElementById("b_your_practice").src = "/advisorchoice/images/b_your_practice_.gif";
	}
	else if (horiz_bkg == "m") {
		document.getElementById("b_products").src = "/advisorchoice/images/b_products_.gif";
	}
	else if (horiz_bkg == "r") {
		document.getElementById("b_technology").src = "/advisorchoice/images/b_technology_.gif";
	}
	else if (horiz_bkg == "rr") {
		document.getElementById("b_services").src = "/advisorchoice/images/b_services_.gif";
	}

}

//make sure the top lines in the content area align on interior pages
if (document.getElementById("right_top_spacer") && document.getElementsByTagName("h2")[0] && document.getElementsByTagName("h2")[0].offsetHeight > 40) {
	document.getElementById("right_top_spacer").style.height = document.getElementsByTagName("h2")[0].offsetHeight - 14 + "px";
}

// set right vertical bar height
if (document.getElementById("body_content") && document.getElementById("body_content").offsetHeight < 358)
document.getElementById("body_content").style.height = "343px" // 15px less because of padding-bottom in style sheet

if (document.getElementById("body_content_wide") && document.getElementById("body_content_wide").offsetHeight < 358)
document.getElementById("body_content_wide").style.height = "343px" // 15px less because of padding-bottom in style sheet

// give alternating colors to tables with the regTbl class
if (document.getElementsByTagName) {
	var el = document.getElementsByTagName("TR");
	
	for (var i=0; i < el.length; i++) {
		if (el[i].parentNode.parentNode.className.indexOf("regTbl") != -1) {
			if (i%2 == 1) {
				el[i].className = "tblon";
			}
			else {
				el[i].className = "tbloff";
			}
		}
	}
}

//begin image viewer
function imageViewer (image_path,top,left) {
	if ((top == "") || (top == null)) {
		top = "50";
	}
	
	if ((left == "") || (left == null)) {
		left = "250";
	}
	
	document.getElementById("image_viewer").innerHTML = "<p style='margin-top: 10px; margin-bottom: 0px; text-align: center;'><a href='Close window' onclick='hideLayer(\"image_viewer\"); return false;'><img src=" + image_path + " border=\"0\"><br />Close window</a></p>";
	document.getElementById("image_viewer").style.top = top + "px";
	document.getElementById("image_viewer").style.left = left + "px";
	//above code uses hide layer from top of document js file
	showLayerOp("image_viewer"); //use fade-in from top of document js file
}

if (document.getElementById) {
	document.write ("<div id='image_viewer' style='position: absolute; top: 50px; left: 250px; visibility: hidden; background: #ddd9d5; padding: 10px; border: 1px solid #999490'></div>");
}
//end image viewer

// check file name and highlight if it matches a link
var file_name = location.href;
// get rid of query string
if (file_name.indexOf('?')!= -1) {
		var query = true;
		var ques_loc = file_name.indexOf('?');
		var query_string = file_name.substring(ques_loc, file_name.length);
		file_name = file_name.substring(0,ques_loc);
}
// get rid of bookmarks
if (file_name.indexOf('#')!= -1) {
		var bm = true;
		var bm_loc = file_name.indexOf('#');
		var bookmark = file_name.substring(bm_loc, file_name.length);
		file_name = file_name.substring(0,bm_loc);
}
// loop through all the links
for (check_links = 0; check_links < document.links.length; check_links++) {
	var link_name = document.links[check_links].href;
	//highlight link if it matches filename
	//exclude nn4 and others
	if(document.getElementById){
		if (link_name == file_name) {
			document.links[check_links].className = "current";
		}
	}
}

//Master list of images for Side Bar.
var sideButton = new Array();
sideButton[1] = new Array("/advisorchoice/images/buttons/090805_HOVtour.gif","151","108","/advisorchoice/library/hovt/","image","new_win","815","455");
sideButton[2] = new Array("/advisorchoice/images/buttons/090512_techDemo.gif","151","108","/advisorchoice/library/technologydemo.asp","image","new_win","800","600");
sideButton[3] = new Array("/advisorchoice/images/buttons/090512_commentaryPodcast.gif","151","108","/experts/","image","new_win","800","600");
sideButton[4] = new Array("/advisorchoice/images/buttons/090512_networkWomen.gif","151","108","women_network.asp","image","same","","");
sideButton[5] = new Array("/advisorchoice/images/buttons/090512_marketingSupport.gif","151","108","advisor_marketing_resources.asp","image","same","","");
sideButton[6] = new Array("/advisorchoice/images/buttons/090512_brokerDealerCheckList.gif","151","108","/advisorchoice/library/broker_dealer_check.asp?affil=" +affiliation+ "","image","new_win","800","600");
sideButton[7] = new Array("/advisorchoice/images/buttons/090512_billRights.gif","151","108","advisor_bill_rights.asp","image","same","","");
sideButton[8] = new Array("/advisorchoice/images/buttons/090512_requestInfo.gif","151","108","request_info.asp","image","same","","");
sideButton[9] = new Array("images/080229_mbo.gif","151","108","/advisorchoice/independenceplus/?utm_campaign=my_back_office&utm_source=rjfsicd_mbo_btn&utm_medium=website&utm_term=rj_independence_plus&utm_content=btn","image","new_win","800","600");
sideButton[10] = new Array("images/080509_embark.gif","151","108","transitioning_tool","image","new_win","790","500");
sideButton[11] = new Array("images/090506_averitt.gif","151","108","discoverrjfs","image","new_win","800","600");
sideButton[12] = new Array("/advisorchoice/images/buttons/090716_smartMoney.gif","151","108","/pr/090609.htm","image","new_win","800","600");
sideButton[13] = new Array("/advisorchoice/images/buttons/090921_rjfs_onwallstreet_lure.gif","151","108","/advisorchoice/library/pdf/0907_onwallstreet_rjfs.pdf","image","new_win","800","600");
sideButton[14] = new Array("/advisorchoice/images/buttons/091103_tomJames09Q4.gif","151","108","/advisorchoice/library/multimedia/media_player.asp?url=2009_1022Q4JamesFBN.flv&mediatype=FLV&width=376&height=350","image","new_win","450","500");

//Method for writting out the sidebar content per page.
if(document.getElementById("dynamic_banner1"))
{
	var num1 = Math.floor(Math.random() * fileToShow1.length) + 1;
	
	// subtract 1 to make it work inside array
	num1 = num1 - 1;

	//to test what type of content will be used as well as writting it to the div tag.
	if(sideButton[fileToShow1[num1]][4] == 'text')
	{
		if(sideButton[fileToShow1[num1]][5] == 'new_win')
		{ document.getElementById("dynamic_banner1").innerHTML = "<a href=\"" +sideButton[fileToShow1[num1]][3]+ "\" onclick=\"window.open(this.href,'_blank','resizable=yes,width=" +sideButton[fileToShow1[num1]][6]+ ",height=" +sideButton[fileToShow1[num1]][7]+ ",scrollbars=yes'); return false;\">" +sideButton[fileToShow1[num1]][0]+ "</a>"; }
		
		if(sideButton[fileToShow1[num1]][5] == 'same')
		{ document.getElementById("dynamic_banner1").innerHTML = "<a href=\"" +sideButton[fileToShow1[num1]][3]+ "\">" +sideButton[fileToShow1[num1]][0]+ "</a>"; }	
	}
	
	
	if(sideButton[fileToShow1[num1]][4] == 'flash')
	{ document.getElementById("dynamic_banner1").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+sideButton[fileToShow1[num1]][1]+"' height='"+sideButton[fileToShow1[num1]][2]+"' /><param name='movie' value='"+sideButton[fileToShow1[num1]][0]+"' /><param name='wmode' value='transparent' /><embed src='"+sideButton[fileToShow1[num1]][0]+"' quality='high' wmode='transparent' width='"+sideButton[fileToShow1[num1]][1]+"' height='"+sideButton[fileToShow1[num1]][2]+"' name='happleMenu' align='top' play='true' loop='false' quality='high' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"; }
	
	if(sideButton[fileToShow1[num1]][4] == 'image')
	{
		if(sideButton[fileToShow1[num1]][3] == '/advisorchoice/library/hovt.asp' && (affiliation == 'IAD' || affiliation == 'CORR'))
		{
			sideButton[fileToShow1[num1]][3] = "/advisorchoice/library/hovt_iad_corr.asp"
		}
		
		if(sideButton[fileToShow1[num1]][5] == 'new_win')
		{ document.getElementById("dynamic_banner1").innerHTML = "<a href=\"" +sideButton[fileToShow1[num1]][3]+ "\" onclick=\"window.open(this.href,'_blank','resizable=yes,width=" +sideButton[fileToShow1[num1]][6]+ ",height=" +sideButton[fileToShow1[num1]][7]+ ",scrollbars=yes');urchinTracker(this.href);return false;\"><img src=\"" +sideButton[fileToShow1[num1]][0]+ "\" width=\"" +sideButton[fileToShow1[num1]][1]+ "\" height=\"" +sideButton[fileToShow1[num1]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner1\" /></a>"; }
		else
		{ document.getElementById("dynamic_banner1").innerHTML = "<a href=\"" +sideButton[fileToShow1[num1]][3]+ "\"><img src=\"" +sideButton[fileToShow1[num1]][0]+ "\" width=\"" +sideButton[fileToShow1[num1]][1]+ "\" height=\"" +sideButton[fileToShow1[num1]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner1\" /></a>"; }
	}
}

if(document.getElementById("dynamic_banner2"))
{
	var num2 = Math.floor(Math.random() * fileToShow2.length) + 1;
	
	// subtract 1 to make it work inside array
	num2 = num2 - 1;

	//to test what type of content will be used as well as writting it to the div tag.
	if(sideButton[fileToShow2[num2]][4] == 'text')
	{
		if(sideButton[fileToShow2[num2]][5] == 'new_win')
		{ document.getElementById("dynamic_banner2").innerHTML = "<a href=\"" +sideButton[fileToShow2[num2]][3]+ "\" onclick=\"window.open(this.href,'_blank','resizable=yes,width=" +sideButton[fileToShow2[num2]][6]+ ",height=" +sideButton[fileToShow2[num2]][7]+ ",scrollbars=yes'); return false;\">" +sideButton[fileToShow2[num2]][0]+ "</a>"; }
		
		if(sideButton[fileToShow2[num2]][5] == 'same')
		{ document.getElementById("dynamic_banner2").innerHTML = "<a href=\"" +sideButton[fileToShow2[num2]][3]+ "\">" +sideButton[fileToShow2[num2]][0]+ "</a>"; }	
	}
	
	if(sideButton[fileToShow2[num2]][4] == 'flash')
	{ document.getElementById("dynamic_banner2").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+sideButton[fileToShow2[num2]][1]+"' height='"+sideButton[fileToShow2[num2]][2]+"' /><param name='movie' value='"+sideButton[fileToShow2[num2]][0]+"' /><param name='wmode' value='transparent' /><embed src='"+sideButton[fileToShow2[num2]][0]+"' quality='high' wmode='transparent' width='"+sideButton[fileToShow2[num2]][1]+"' height='"+sideButton[fileToShow2[num2]][2]+"' name='happleMenu' align='top' play='true' loop='false' quality='high' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"; }
	
	if(sideButton[fileToShow2[num2]][4] == 'image')
	{
	
		if(sideButton[fileToShow2[num2]][3] == '/advisorchoice/library/hovt.asp' && (affiliation == 'IAD' || affiliation == 'CORR'))
		{
			sideButton[fileToShow2[num2]][3] = "/advisorchoice/library/hovt_iad_corr.asp"
		}
		
		if(sideButton[fileToShow2[num2]][5] == 'new_win')
		{ document.getElementById("dynamic_banner2").innerHTML = "<a href=\"" +sideButton[fileToShow2[num2]][3]+ "\" onclick=\"window.open(this.href,'_blank','resizable=yes,width=" +sideButton[fileToShow2[num2]][6]+ ",height=" +sideButton[fileToShow2[num2]][7]+ ",scrollbars=yes');urchinTracker(this.href);return false;\"><img src=\"" +sideButton[fileToShow2[num2]][0]+ "\" width=\"" +sideButton[fileToShow2[num2]][1]+ "\" height=\"" +sideButton[fileToShow2[num2]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner2\" /></a>"; }
		
		if(sideButton[fileToShow2[num2]][5] == 'same')
		{ document.getElementById("dynamic_banner2").innerHTML = "<a href=\"" +sideButton[fileToShow2[num2]][3]+ "\"><img src=\"" +sideButton[fileToShow2[num2]][0]+ "\" width=\"" +sideButton[fileToShow2[num2]][1]+ "\" height=\"" +sideButton[fileToShow2[num2]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner2\" /></a>"; }
	}
}


//just for home page buttons
if(document.getElementById("dynamic_banner3"))
{
	var num3 = Math.floor(Math.random() * fileToShow3.length) + 1;
	
	// subtract 1 to make it work inside array
	num3 = num3 - 1;

	//to test what type of content will be used as well as writting it to the div tag.
	if(sideButton[fileToShow3[num3]][4] == 'text')
	{
		if(sideButton[fileToShow3[num3]][5] == 'new_win')
		{ document.getElementById("dynamic_banner3").innerHTML = "<a href=\"" +sideButton[fileToShow3[num3]][3]+ "\" onclick=\"window.open(this.href,'_blank','resizable=yes,width=" +sideButton[fileToShow3[num3]][6]+ ",height=" +sideButton[fileToShow3[num3]][7]+ ",scrollbars=yes'); return false;\">" +sideButton[fileToShow3[num3]][0]+ "</a>"; }
		
		if(sideButton[fileToShow3[num3]][5] == 'same')
		{ document.getElementById("dynamic_banner3").innerHTML = "<a href=\"" +sideButton[fileToShow3[num3]][3]+ "\">" +sideButton[fileToShow3[num3]][0]+ "</a>"; }	
	}
	
	if(sideButton[fileToShow3[num3]][4] == 'flash')
	{ document.getElementById("dynamic_banner3").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+sideButton[fileToShow3[num3]][1]+"' height='"+sideButton[fileToShow3[num3]][2]+"' /><param name='movie' value='"+sideButton[fileToShow3[num3]][0]+"' /><param name='wmode' value='transparent' /><embed src='"+sideButton[fileToShow3[num3]][0]+"' quality='high' wmode='transparent' width='"+sideButton[fileToShow3[num3]][1]+"' height='"+sideButton[fileToShow3[num3]][2]+"' name='happleMenu' align='top' play='true' loop='false' quality='high' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"; }
	
	if(sideButton[fileToShow3[num3]][4] == 'image')
	{
		if(sideButton[fileToShow3[num3]][3] == '/advisorchoice/library/hovt.asp' && (affiliation == 'IAD' || affiliation == 'CORR'))
		{
			sideButton[fileToShow3[num3]][3] = "/advisorchoice/library/hovt_iad_corr.asp"
		}
		
		if(sideButton[fileToShow3[num3]][5] == 'new_win')
		{ document.getElementById("dynamic_banner3").innerHTML = "<a href=\"" +sideButton[fileToShow3[num3]][3]+ "\" onclick=\"window.open('" +sideButton[fileToShow3[num3]][3]+ "','_blank','resizable=yes,width=" +sideButton[fileToShow3[num3]][6]+ ",height=" +sideButton[fileToShow3[num3]][7]+ ",scrollbars=yes'); return false;\"><img src=\"" +sideButton[fileToShow3[num3]][0]+ "\" width=\"" +sideButton[fileToShow3[num3]][1]+ "\" height=\"" +sideButton[fileToShow3[num3]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner3\" /></a>"; }
		
		if(sideButton[fileToShow3[num3]][5] == 'same')
		{ document.getElementById("dynamic_banner3").innerHTML = "<a href=\"" +sideButton[fileToShow3[num3]][3]+ "\"><img src=\"" +sideButton[fileToShow3[num3]][0]+ "\" width=\"" +sideButton[fileToShow3[num3]][1]+ "\" height=\"" +sideButton[fileToShow3[num3]][2]+ "\" onmouseover=\"hovChange(this.id)\" onmouseout=\"hovChange(this.id)\" id=\"side_banner3\" /></a>"; }
	}
}