//begin horizontal nav hightlight
function navHighlight (horiz_bkg) {
    var id;

    if (horiz_bkg == "ll") {
        id = "b_aboutus";
    }
    else if (horiz_bkg == "l") {
        id = "b_products";
    }
    else if (horiz_bkg == "m") {
        id = "b_technology";
    }
    else if (horiz_bkg == "r") {
        id = "b_research";
    }
    else if (horiz_bkg == "rr") {
        id = "b_yourbiz";
    }
    else {
        return false;
    }

    var fileNameOrg = document.getElementById(id).src;
    var fileNameNew;

    var appendPart;

    if (fileNameOrg.indexOf("?") > -1) {
        appendPart = filename.substring(filename.indexOf("?"), filename.length);
        fileNameNew = filename.substring(0, filename.indexOf("?"));
    }
    else {
        appendPart = "";
    }

    if (fileNameOrg.indexOf(".gif") > -1) {
        if (fileNameOrg.charAt(fileNameOrg.length - 5) == "_") {
            fileNameNew = fileNameOrg.substring(0, fileNameOrg.length - 5) + ".gif" + appendPart;
        }
        else {
            fileNameNew = fileNameOrg.substring(0, fileNameOrg.length - 4) + "_.gif" + appendPart;
        }
    }
    else if (fileNameOrg.indexOf(".jpg") > -1) {
        if (fileNameOrg.charAt(fileNameOrg.length - 5) == "_") {
            fileNameNew = fileNameOrg.substring(0, fileNameOrg.length - 5) + ".jpg" + appendPart;
        }
        else {
            fileNameNew = fileNameOrg.substring(0, fileNameOrg.length - 4) + "_.jpg" + appendPart;
        }
    }

    document.getElementById(id).src = fileNameNew;
}

//check if horiz_bkg exists and run the function if true
if (window.horiz_bkg && document.getElementById) {
    navHighlight(horiz_bkg);
}
// end horizontal nav hightlight

// 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 = "342px";
}

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 = "342px";
}

// 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 showLayerOp fuction from 2008begining.js should be included at top of main document.
}

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";
        }
    }
}

/************ Array of Buttons to Show on Interior Pages ************/
var sideButton = new Array();
sideButton["techdemo"] = "<a href=\"http://www.raymondjames.com/advisorchoice/library/technologydemo.asp\" onclick=\"window.open(this.href,'_blank','resizable,scrollbars,width=800,height=600'); pageTracker._trackPageview('/outgoing/TechDemo'); return false;\"><img src=\"images/buttons/090512_techDemo.gif\" alt=\"Technology Demo\" width=\"151\" height=\"108\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"090512_techDemo\" /></a>";
sideButton["marketingsupport"] = "<a href=\"marketing.htm\"><img src=\"images/buttons/090512_marketingSupport.gif\" alt=\"Marketing Support\" width=\"151\" height=\"108\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"090512_marketingSupport\" /></a>";
sideButton["commentarypodcast"] = "<a href=\"http://www.raymondjames.com/experts/\" onclick=\"window.open(this.href,'_blank','resizable,scrollbars,width=800,height=600'); pageTracker._trackPageview('/outgoing/podcast'); return false;\"><img src=\"images/buttons/090512_commentaryPodcast.gif\" alt=\"Expert Commentaries\" width=\"151\" height=\"108\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"090512_commentaryPodcast\" /></a>";
sideButton["requestinfo"] = "<a href=\"contact_us.htm\"><img src=\"images/buttons/090512_requestInfo.gif\" alt=\"Request Information\" width=\"151\" height=\"108\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"090512_requestInfo\" /></a>";
sideButton["hovtour"] = "<a href=\"http://www.raymondjames.com/advisorchoice/library/hovt/\" onclick=\"window.open(this.href,'_blank','resizable,scrollbars,width=910,height=575'); pageTracker._trackPageview('/outgoing/HOVT/'); return false;\"><img src=\"images/buttons/090805_HOVtour.gif\" alt=\"Home Office Virtual Tour\" width=\"151\" height=\"108\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"090805_HOVtour\" /></a>";
sideButton["bictop50"] = "<a href=\"pr/100316.htm\"><img src=\"images/buttons/100325_bicTop50.gif\" alt=\"BIC Names Top 50 Advisors\" width=\"144\" height=\"154\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" id=\"100325_bicTop50\" /></a>";
/************ Array of Buttons to Show on Interior Pages ************/

var fileToShow1, fileToShow2;

if (typeof (preSetValue1) == "undefined") {
    fileToShow1 = new Array("techdemo", "commentarypodcast", "hovtour");
}
else {
    fileToShow1 = preSetValue1;
}

if (typeof (preSetValue2) == "undefined") {
    fileToShow2 = new Array("marketingsupport", "requestinfo", "bictop50");
}
else {
    fileToShow2 = preSetValue2;
}


//Method for writting out the sidebar content per page.
if (document.getElementById("banner1")) {
    var objOne = document.getElementById("banner1");
    var numOne = Math.floor(Math.random() * (fileToShow1.length));
    objOne.innerHTML = sideButton[fileToShow1[numOne]];
}

if (document.getElementById("banner2")) {
    var objTwo = document.getElementById("banner2");
    var numTwo = Math.floor(Math.random() * (fileToShow2.length));
    objTwo.innerHTML = sideButton[fileToShow2[numTwo]];
}

/***************** Just set home page buttons ***********************/
var bannerArray = new Array();
bannerArray["annualreport"] = "<a href=\"http://www.raymondjames.com/annualreport/\" target=\"_blank\" onclick=\"pageTracker._trackPageview('/outgoing/AnnualReport09');\"><img src=\"images/buttons/100127_annualReport09.gif\" id=\"100127_annualReport09\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" /></a>";
bannerArray["topfiftybank"] = "<a href=\"pr/100316.htm\"><img src=\"images/buttons/100325_bicTop50.gif\" id=\"100325_bicTop50\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" /></a>";
bannerArray["tomjames_bwtb_20100128"] = "<a href=\"http://www.raymondjames.com/advisorchoice/library/tom_james_bwtb_20100128\" target=\"_blank\" onclick=\"window.open(this.href,'_blank','top=150,left=250,width=990,height=700,resizable'); pageTracker._trackPageview('/outgoing/Tom_James_BWTB_Q109'); return false;\"><img src=\"images/buttons/100310_tj_bwtb_20100128_full.gif\" id=\"100310_tj_bwtb_20100128_full\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" /></a>";
bannerArray["bic201007"] = "<a href=\"pr/100706_1.htm\"><img src=\"images/buttons/100714_fid_bic.gif\" id=\"100714_fid_bic\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" /></a>";
bannerArray["ows201007"] = "<a href=\"pr/100706_2.htm\"><img src=\"images/buttons/100714_fid_ows.gif\" id=\"100714_fid_ows\" onmouseover=\"hovChange(this.id);\" onmouseout=\"hovChange(this.id);\" /></a>";

/*Button 1*/
if (document.getElementById("button1") != null) {
    var obj = document.getElementById("button1");
    var num1 = Math.floor(Math.random() * 3);
    var imgBlock1;

    switch (num1) {
        case 0:
            imgBlock1 = bannerArray["annualreport"];
            break;
        case 1:
            imgBlock1 = bannerArray["bic201007"];
            break;
        default:
            imgBlock1 = bannerArray["bic201007"];
            break;
    }

    obj.innerHTML = imgBlock1;

}

/*Button 2*/
if (document.getElementById("button2") != null) {
    var obj = document.getElementById("button2");
    var num2 = Math.floor(Math.random() * 3);
    var imgBlock2;

    switch (num2) {
        case 0:
            imgBlock2 = bannerArray["topfiftybank"];
            break;
        case 1:
            imgBlock2 = bannerArray["ows201007"];
            break;
        default:
            imgBlock2 = bannerArray["ows201007"];
            break;
    }

    obj.innerHTML = imgBlock2;

}
/***************** Just set home page buttons ***********************/

