//modify for 800x600 resolution - resize elements
function changeWidth(id, width) {
	if(document.getElementById(id)){document.getElementById(id).style.width = width + "px"}
}

if (screen.width < 801){
	
	changeWidth("lcol_spacer", 192)
	changeWidth("mcol_spacer", 384)
	changeWidth("rcol_spacer", 192)
	changeWidth("grand", 770)
	changeWidth("main", 770)
	changeWidth("buttons", 770)
	changeWidth("button_ll_div", 192)
	changeWidth("button_l_div", 192)
	changeWidth("button_r_div", 192)
	changeWidth("button_rr_div", 192)
	
	//drop down positions
	if(document.getElementById("account_login")){document.getElementById("account_login").style.left = "360px"}
	
	// utility button spacing
	if(document.getElementsByTagName){
	var el = document.getElementsByTagName("DIV");
		for(var i=0; i < el.length; i++){
			if(el[i].className.indexOf("u_spacer") != -1){
				el[i].style.paddingLeft = "10px"
				el[i].style.paddingRight = "10px"
			}
		}
	}
	
}
// end 800x600 modify

function navHighlight (horiz_bkg){
	var id
	if (horiz_bkg == "ll"){id = "b_about_the_network"}
	else if (horiz_bkg == "l"){id = "b_services_support"}
	else if (horiz_bkg == "r"){id = "b_resources"}
	else if (horiz_bkg == "rr"){id = "b_events"}
	else {return false;}
	document.getElementById(id).src = "images/nav/" + id + "_.gif"
	document.getElementById(id).onmouseout = function(){
		document.getElementById(id).src = "images/nav/" + id + "_.gif"
	}
}

//check if horiz_bkg exists and run the function if true
if (window.horiz_bkg && document.getElementById) {
	navHighlight(horiz_bkg);
}
// end horizontal nav hightlight




//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
}

// 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";}
		}
	}
}

// place banners on page
var banner_tech_demo = "<a href=\"/advisorchoice/library/technologydemo.asp\" target=\"_blank\"><img src=\"/advisorchoice/images/buttons/090512_techDemo.gif\" id=\"btnTechDemo\" onmouseover=\"hovChange(this.id);\"  onmouseout=\"hovChange(this.id);\" width=\"151\" height=\"108\" title=\"\" alt=\"Technology Demo\" /></a>";

var banner_experts = "<a href=\"/experts/\" target=\"_blank\"><img src=\"/advisorchoice/images/buttons/090512_commentaryPodcast.gif\" id=\"btnCommentaryPodcast\" onmouseover=\"hovChange(this.id);\"  onmouseout=\"hovChange(this.id);\" width=\"151\" height=\"108\" title=\"\" alt=\"Expert Commentary\" /></a>";

var banner_outlook =	"<a href=\"/branches/library/features/midyear_eo/\" target=\"_blank\"><img src=\"/advisorchoice/images/buttons/090715_econUpdate.gif\" id=\"btnEconUpdate\" onmouseover=\"hovChange(this.id);\"  onmouseout=\"hovChange(this.id);\" width=\"151\" height=\"108\" title=\"\" alt=\"Expert Commentary\" /></a>";

var women_network_brochure = "<a href=\"pdf/women_network.pdf\" target=\"_blank\" onclick=\"window.open(this.href); return false;\"><img src=\"images/buttons/090921_network_women_broch.gif\" width=\"151\" height=\"108\" id=\"network_women_broch\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\"></a>";

var smart_money = "<a href=\"/pr/090609.htm\" target=\"_blank\"><img src=\"/advisorchoice/images/buttons/090716_smartMoney.gif\" id=\"btnSmartMoney\" onmouseover=\"hovChange(this.id);\"  onmouseout=\"hovChange(this.id);\" width=\"151\" height=\"108\" title=\"\" alt=\"Raymond James Financial, Inc. was recently ranked the best full-service broker in the 2009 SmartMoney Annual Broker Survey.\" /></a>";

var nfw_reg09 = "<a href=\"http://www.regonline.com/Womens09\" target=\"_blank\"><img src=\"images/buttons/090825_NWAsymposium.gif\" id=\"btn090825_NWAsymposium\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" alt=\"Register for Symposium\" title=\"\" width=\"151\" height=\"130\" />";

var banner_random1;

// For Testing
//var ranNum = 3;

// For Production
var ranNum1 = Math.floor(Math.random()*5);

switch (ranNum1) {
	case 0:
		banner_random1 = banner_tech_demo
		break;
	case 1:
		banner_random1 = banner_experts
		break;
	case 2:
		banner_random1 = banner_outlook
		break;
	case 3:
		banner_random1 = smart_money
		break;
	case 4:
		banner_random1 = nfw_reg09;
		break;
	default:
		banner_random1 = smart_money
}

if (document.getElementById("dynamicBanner1")) {
	document.getElementById("dynamicBanner1").innerHTML = banner_random1;
}

var banner_random2;

var ranNum2 = 3;

switch (ranNum2) {
	case 0:
		banner_random2 = banner_tech_demo
		break;
	case 1:
		banner_random2 = banner_experts
		break;
	case 2:
		banner_random2 = banner_outlook
		break;
	case 3:
		banner_random2 = women_network_brochure
		break;
	case 4:
		banner_random2 = smart_money
		break;
	default:
		banner_random2 = smart_money
}


if (document.getElementById("dynamicBanner2")) {
	document.getElementById("dynamicBanner2").innerHTML = banner_random2;
}

if(document.getElementById && !document.all){
	document.getElementById("grand").style.height = document.getElementById("grand").style.height + 1 + "px"
}

// 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";
		}
	}
}

//start of code for text sizer icons
if (document.getElementById("textSizer")) //check to make sure span tag is there before writting to it.
{
	document.getElementById("textSizer").innerHTML =	"Text Size:\
														<a href=\"sdf\" onclick=\"changeStyle(0); return false;\"><img src=\"images/nav/text_size_sm.gif\" id=\"text_size_sm\" width=\"16\" height=\"15\" alt=\"\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id)\" /></a>\
														<a href=\"sdf\" onclick=\"changeStyle(1); return false;\"><img src=\"images/nav/text_size_m.gif\" id=\"text_size_m\" width=\"16\" height=\"15\" alt=\"\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id)\" /></a>\
														<a href=\"sdf\" onclick=\"changeStyle(2); return false;\"><img src=\"images/nav/text_size_lg.gif\" id=\"text_size_larg\" width=\"16\" height=\"15\" alt=\"\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id)\" /></a>"
}
//end of code for text sizer icons