//set the horiz nav hightlight
if(horiz_bkg && document.getElementById) {
	var small_width = "";
	
	//this sets it to a different image for 800x600 resolution
	if (screen.width < 801) {
		small_width = "_800";
	}
	
	if (horiz_bkg == "ll") {
		document.getElementById("b_about").src = "images/2009build/b_about" + small_width + "_.gif";
		
		document.getElementById("b_about").onmouseout = function() {
			document.getElementById("b_about").src = "images/2009build/b_about" + small_width + "_.gif";
		}
	}
	
	if (horiz_bkg == "l") {
		document.getElementById("b_tech").src = "images/2009build/b_tech" + small_width + "_.gif";
		
		document.getElementById("b_tech").onmouseout = function() {
			document.getElementById("b_tech").src = "images/2009build/b_tech" + small_width + "_.gif";
		}
	}
	
	if (horiz_bkg == "r") {
		document.getElementById("b_products").src = "images/2009build/b_products" + small_width + "_.gif";
		
		document.getElementById("b_products").onmouseout = function() {
			document.getElementById("b_products").src = "images/2009build/b_products" + small_width + "_.gif";
		}
	}
	
	if (horiz_bkg == "rr") {
		document.getElementById("b_services").src = "images/2009build/b_services" + small_width + "_.gif";
		
		document.getElementById("b_services").onmouseout = function() {
			document.getElementById("b_services").src = "images/2009build/b_services" + small_width + "_.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) {
	 // 15px less because of padding-bottom in style sheet
	document.getElementById("body_content").style.height = "343px";
}

if (document.getElementById("body_content_wide") && document.getElementById("body_content_wide").offsetHeight < 358) {
	 // 15px less because of padding-bottom in style sheet
	document.getElementById("body_content_wide").style.height = "343px";
}

// 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].style.color = '#236fdc';
		}
	}
}

//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_marketingSupport.gif","151","108","market_service.asp","image","same","","");
sideButton[5] = new Array("/advisorchoice/images/buttons/090512_brokerDealerCheckList.gif","151","108","/advisorchoice/library/broker_dealer_check.asp?affil=CORR","image","new_win","800","600");
sideButton[6] = new Array("/advisorchoice/images/buttons/090512_requestInfo.gif","151","108","request_info.asp","image","same","","");

//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] == '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] == '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>"; }
	}
}