//Add JavaScript File from AdvisorChoice main.
document.write(unescape("%3Cscript src=\"/script/main_top.js\" type=\"text/javascript\"%3E%3C/script%3E"));

function setOnLoadEventsECMRJHealthcare(objFunctionName) {
    //Works for NON-IE Browsers
    if (window.addEventListener) {
        window.addEventListener("load", objFunctionName, false);
    }
    else { //Works for IE Browsers versions 6 - 8
        window.attachEvent("onload", objFunctionName);
    }
}

//****** GLOBAL VARIABLES ******//
//Set variable to TRUE to override setting page title based on NAV.
boolPageTitleRun = true;

//Set page title.
var titleText = "HEALTH CARE INVESTMENT BANKING GROUP";
//****** GLOBAL VARIABLES ******//

setOnLoadEventsECMRJHealthcare(setMainNav);
setOnLoadEventsECMRJHealthcare(checkForMainPage);
setOnLoadEventsECMRJHealthcare(setPageSettings);
/*setOnLoadEventsECMRJHealthcare(setFeaturedLinks);*/

var breadcrumbMainNav = "";

function setMainNav() {
    //Set global nav.
    document.getElementById("capitalmarketsAnchor").className = "current";

    //Set bread crumb trail.
    breadcrumbMainNav = " // <a href=\"" + document.getElementById("capitalmarketsAnchor").href + "\" id=\"bctcapitalmarkets\">Capital Markets</a> // <a href=\"/capitalmarkets/investment_banking.htm\" id=\"bctInvestmentBanking\">Investment Banking</a> // <a href=\"/ecm/rjhealthcarebanking\" id=\"bctECMHealthcareSrvc\">Health Care Investment Banking Group</a> ";
}

/* Function CHECK FOR MAIN PAGE DOES NOT WORK */
function checkForMainPage() {
    if (typeof(mainPageBCT) != "undefined") {
        if (mainPageBCT = true) {
            if (document.getElementById("bctECMHealthcareSrvc")) {
                document.getElementById("bctECMHealthcareSrvc").className = "current";
            }
            else {
                setTimeout(checkForMainPage, 50);
            }
        }
    }
    else {
        setTimeout(checkForMainPage, 50);
    }
}

function setFeaturedLinks() {
    if (!document.getElementById("featuredLinks")) {
        setTimeout(setFeaturedLinks, 50)
    }
    else {
        if (document.getElementById("featuredLinks").innerHTML == "&nbsp;") {
            var featuredLinkBlock = document.getElementById("featuredLinks");

            var contentBlock = "<h3>FEATURED LINKS</h3>\n\
                               <a href=\"http://www.rjcommunicationsservices.com\">Communications Services Investment Group</a>\n\
							   <a href=\"http://www.rjgovernmentbanking.com\" target=\"_blank\">Government Services &amp; Technologies Investment Banking Group</a>"

            featuredLinkBlock.innerHTML = contentBlock;
        }
    }
}

function setPageSettings() {

    //Get the specific page name from the URL;
    var locHrefArray = location.href.split("/");
    var currentPage = locHrefArray[locHrefArray.length - 1];

    if (currentPage.indexOf("?") > -1) {
        currentPage = currentPage.slice(0, currentPage.indexOf("?"));
    }


    //If the currentPage is empty move back 1 in the locHrefArray
    if (currentPage == "" || currentPage.indexOf(".") == -1) {
        currentPage = locHrefArray[locHrefArray.length - 2];
    }

    //Button setting options
    var pgBtnDONOTSET = "DO NOT SET";
    var pgBtnSETONPAGE = "SET ON PAGE";
    
    /*
    Use an Array to set the assocaition between
    pgArray[pgCount++] = new Array(FILE NAME, BUTTONS);
    */
    var pgArray = new Array();
    var pgCount = -1;
    pgArray[pgCount++] = new Array("contact.htm", pgBtnDONOTSET, pgBtnDONOTSET);
    /*pgArray[pgCount++] = new Array("equity_research.htm", new Array("banner1", "banner3"), new Array("banner2", "banner4"));*/
	pgArray[pgCount++] = new Array("team.htm", pgBtnDONOTSET, pgBtnDONOTSET);
	pgArray[pgCount++] = new Array("equity_research.htm", pgBtnDONOTSET, pgBtnDONOTSET);
    pgArray[pgCount++] = new Array("services.htm", pgBtnDONOTSET, pgBtnDONOTSET);
    pgArray[pgCount++] = new Array("transactions.htm", pgBtnDONOTSET, pgBtnDONOTSET);

    var item, pageFound;

    pageFound = false;

    for (item in pgArray) {
        if (pgArray[item][0] == currentPage) {
            pageFound = true;
            setSideBarSettings(pgArray[item][1], pgArray[item][2]);
            break;
        }
    }

    if (!pageFound) {
        setSideBarSettings(undefined, undefined);
    }
}

function setSideBarSettings(buttonOne, buttonTwo) {

    var sideBarBlock;

    if (document.getElementById("sideBar")) {
        sideBarBlock = document.getElementById("sideBar");
    }
    else {
        sideBarBlock = "";
    }

    if (buttonOne != "DO NOT SET" && buttonOne != "SET ON PAGE") {
        var bannerOneDIV = document.createElement("div");
        bannerOneDIV.setAttribute("id", "bannerOneBlock");
        bannerOneDIV.className = "banner";
        if (sideBarBlock != "") {
            sideBarBlock.appendChild(bannerOneDIV);
        }
    }

    if (buttonTwo != "DO NOT SET" && buttonTwo != "SET ON PAGE") {
        var bannerTwoDIV = document.createElement("div");
        bannerTwoDIV.setAttribute("id", "bannerTwoBlock");
        bannerTwoDIV.className = "banner";
        if (sideBarBlock != "") {
            sideBarBlock.appendChild(bannerTwoDIV);
        }
    }

    //ReSet Page Layout;
    setContentBlockClass();

    if (document.getElementById("bannerOneBlock")) {
        //can be changed later on once we have MORE buttons
        setSideBarImages(buttonOne, buttonTwo);
    }
}

/* IMAGES FOR SIDE BAR */
var sideButton = new Array();
sideButton["banner1"] = "<div align=\"center\"><a href=\"http://www.raymondjames.com/pr/100427.htm\" target=\"_blank\"><img src=\"http://www.raymondjames.com/ecm/library/btn_buyouts.gif\" id=\"btn_buyouts\" alt=\"Buyouts Magazine Name Raymond James Top Mid-Market Investment Bank\" border=\"0\" class=\"changeOnHover\" /></a></div>";
sideButton["banner2"] = "<div align=\"center\"><a href=\"accolades.asp\"><img src=\"/ecm/library/btn_accolades.gif\" width=\"151\" height=\"151\" alt=\"ECM Accolades\" border=\"0\" id=\"btn_accolades\" class=\"banner changeOnHover\" /></a></div>";
sideButton["banner3"] = "";
sideButton["banner4"] = "";

function setSideBarImages(preSetValue1, preSetValue2) {

    var fileToShow1, fileToShow2;

    // Create DEFAULT ARRAY of buttons if no button is set.
    // Top Button
    if (typeof (preSetValue1) == "undefined") {
        fileToShow1 = new Array("banner1");
    }
    else {
        fileToShow1 = preSetValue1;
    }

    // Bottom Button
    if (typeof (preSetValue2) == "undefined") {
        fileToShow2 = new Array("banner2");
    }
    else {
        fileToShow2 = preSetValue2;
    }

    //Method for writting out the sidebar content per page.
    if (document.getElementById("bannerOneBlock") && document.getElementById("bannerOneBlock").innerHTML == "") {
        var objOne = document.getElementById("bannerOneBlock");
        var numOne = Math.floor(Math.random() * (fileToShow1.length));
        objOne.innerHTML = sideButton[fileToShow1[numOne]];
    }

    if (document.getElementById("bannerTwoBlock") && document.getElementById("bannerTwoBlock").innerHTML == "") {
        var objTwo = document.getElementById("bannerTwoBlock");
        var numTwo = Math.floor(Math.random() * (fileToShow2.length));
        objTwo.innerHTML = sideButton[fileToShow2[numTwo]];
    }

    setHovChangeByClass();
}
