//Login Menu Code Start
function hideLayerQB(whichLayer) {
        if (document.getElementById) {
                // this is the way the standards work
                document.getElementById(whichLayer).style.visibility = "hidden";
        }
        else if (document.all) {
                // this is the way old msie versions work
                document.all[whichlayer].style.visibility = "hidden";                
        }
        else if (document.layers) {
                // this is the way nn4 works
                document.layers[whichLayer].visibility = "hidden";
        }
}

function showLayerQB(whichLayer) {
        if (document.getElementById) {
                // this is the way the standards work
                document.getElementById(whichLayer).style.visibility = "visible";
        }
        else if (document.all) {
                // this is the way old msie versions work
                document.all[whichlayer].style.visibility = "visible";
        }
        else if (document.layers) {
                // this is the way nn4 works
                document.layers[whichLayer].visibility = "visible";
        }
}

function handleClick(whichClick) {
        if (whichClick == "hide it") {
                // then the user wants to hide the layer
                hideLayerQB("boxthing");
        }
        else if (whichClick == "show it") {
                // then the user wants to show the layer
                showLayerQB("boxthing");
        }
        if (whichClick == "hide error") {
                // then the user wants to hide the layer
                hideLayerQB("errorthing");
        }
        else if (whichClick == "show error") {
                // then the user wants to show the layer
                showLayerQB("errorthing");
        }
}
//Login Menu Code End


// Navigation Image Swap Javascript Start
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// Navigation Image Swap Javascript End


//Simple Show Layer Function
function showLayer(theLayer)
{
        document.getElementById(theLayer).style.display = "block"
}

//Simple Show Layer Function
function hideLayer(theLayer)
{
        document.getElementById(theLayer).style.display = "none"
}

function hideExpandables(){
        document.getElementById('individuals').style.display = 'none';
        if (document.getElementById('smallmidsized')){
                document.getElementById('smallmidsized').style.display = 'none';
        }
        //document.getElementById('smallmidsized').style.display = 'none';
        document.getElementById('institutions').style.display = 'none';
        document.getElementById('financial').style.display = 'none';
}

function removeVspace(){
        document.expandind.vspace= 0;
        if (document.getElementById('expandsmall')){
                document.expandsmall.vspace= 0;
        }
        //document.expandsmall.vspace= 0;
        document.expandinst.vspace= 0;
        document.expandfin.vspace= 0;                
}

function addVspace(){
        turnUpArrows();
        document.expandind.vspace= 5;
        if (document.getElementById('expandsmall')){
                document.expandsmall.vspace= 5;
        }
        //document.expandsmall.vspace= 5;
        document.expandinst.vspace= 5;
        document.expandfin.vspace= 5;                
}

function turnUpArrows(theImage)
{
 /*
        if (theImage != 'ind') {
                document.expandind.src = "src/expandable_nav_ind_off.gif";
        }
        if (document.getElementById('expandsmall')){
                if (theImage != 'small') {
                        document.expandsmall.src = "src/expandable_nav_small_off.gif";
                }
        }
        //document.expandsmall.src = "src/expandable_nav_small_off.gif";
        if (theImage != 'inst') {
                document.expandinst.src = "src/expandable_nav_inst_off.gif";
        }
        if (theImage != 'fin') {
                document.expandfin.src = "src/expandable_nav_fin_off.gif";                
        }
 */
}

function turnDownArrow(theImage)
 {
  //        eval("document.expand" + theImage + ".src = 'src/expandable_nav_" + theImage + "_on.gif'");
  //       turnUpArrows(theImage);
 }

function expandableMenu(category){
isCurrentBlocked = eval("document.getElementById('" + category + "').style.display");
        if(isCurrentBlocked == "block"){
                isCurrentBlocked = true;
        }
        else{
                isCurrentBlocked = false;
        }
        switch(category)
        {
                case "individuals":
                hideExpandables();
                if(isCurrentBlocked){
                        addVspace();
                        hideLayer(category);
                }
                else{
                        turnDownArrow('ind');                        
                        removeVspace();
                        showLayer(category);                        
                }
                break;
                case "smallmidsized":
                hideExpandables();
                if(isCurrentBlocked){
                        addVspace();
                        hideLayer(category);
                }
                else{
                        turnDownArrow('small');                        
                        removeVspace();

                        showLayer(category);
                }                                
                break;
                case "institutions":
                hideExpandables();
                if(isCurrentBlocked){
                        addVspace();
                        hideLayer(category);
                }
                else{
                        removeVspace();
                        turnDownArrow('inst');                        
                        showLayer(category);
                }                
                break;
                case "commercial":
                hideExpandables();
                if(isCurrentBlocked){
                        addVspace();
                        hideLayer(category);
                }
                else{
                        removeVspace();
                        showLayer(category);
                }
                break;

                case "financial":
                hideExpandables();
                if(isCurrentBlocked){
                        addVspace();                
                        hideLayer(category);
                }
                else{
                        removeVspace();
                        turnDownArrow('fin');                        
                        showLayer(category);
                }                
                break;                
        }
}


function togglesite(sName) {

        if (sName == 'US') {
                document.getElementById('USSite').src = '/cms/src/us_site_on.gif'; 
                document.getElementById('IntSite').src = '/cms/src/international_site_off.gif'; 
                document.getElementById('OBInt').style.display = 'none'; 
                document.getElementById('OBDom').style.display = 'inline';
                document.getElementById('smallmidsized').parentElement.parentElement.style.display = 'inline';
        }
        else {
                document.getElementById('USSite').src = '/cms/src/us_site_off.gif'; 
                document.getElementById('IntSite').src = '/cms/src/international_site_on.gif'; 
                document.getElementById('OBInt').style.display = 'inline'; 
                document.getElementById('OBDom').style.display = 'none';
                document.getElementById('smallmidsized').parentElement.parentElement.style.display = 'none';
        }
                
}


/*Esp code drops in here*/
/*rel_tools.js*/
function switchSelecta(onId, offId) {
        document.getElementById(offId).style.display = 'none';
        document.getElementById(onId).style.display = 'inline';
        return true;
}


/*tab_tastic.js*/


//*** This library is copyright 2004 by Gavin Kistner, gavin@refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code mostly satisfies the conditions.)

//*** Tabtastic -- see http://phrogz.net/JS/Tabstatic/index.html
//*** Version 1.0    20040430   Initial release.
//***         1.0.2  20040501   IE5Mac, IE6Win compat.
//***         1.0.3  20040501   Removed IE5Mac/Opera7 compat. (see http://phrogz.net/JS/Tabstatic/index.html#notes)
//***         1.0.4  20040521   Added scroll-back hack to prevent scrolling down to page anchor. Then commented out :)
/* SCRIPT TO CHANGE ROW COLORS ON MARKET INDICES */
var prevRow = null;  

function checkHash() {
        if(location.hash) {
                var sEl = document.getElementById("tr" + location.hash.substr(1));
                prevRow = sEl;
                for(i=sEl.firstChild; i; i=i.nextSibling) { 
                        if(i.nodeType == 1) i.style.backgroundColor = "#EFE7CF";  
                        if(i.className == "Symbolsm") i.className = "SymHiLite";
                }
        } else {
                //prevRow = document.getElementById("trDJIA");
                //prevRow.style.backgroundColor = "#EFE7CF";  
                for(i=prevRow.firstChild; i; i=i.nextSibling) { 
                        if(i.nodeType == 1) i.style.backgroundColor = "#EFE7CF";  
                        if(i.className == "Symbolsm") i.className = "SymHiLite";
                }
        }
}

function highlightRow(elName) { 
        //reset prevRow's color
        if(prevRow) {
                for(i=prevRow.firstChild; i; i=i.nextSibling) { 
                        if(i.nodeType == 1) i.style.backgroundColor = "";  
                        if(i.className == "SymHiLite") i.className = "Symbolsm";
                }
        }

        //highlight new row
        var e = document.getElementById(elName);
        for(i=e.firstChild; i; i=i.nextSibling) { 
                if(i.nodeType == 1) i.style.backgroundColor = "#EFE7CF";
                if(i.className == "Symbolsm") i.className = "SymHiLite";
        }
        prevRow = e;
}

/* END SCRIPT TO CHANGE ROW COLORS ON MARKET INDICES */
AttachEvent(window,'load',function(){
        var tocTag='ul',tocClass='tabset_tabs',tabTag='a',contentClass='tabset_content';


        function FindEl(tagName,evt){
                if (!evt && window.event) evt=event;
                if (!evt) return DebugOut("Can't find an event to handle in DLTabSet::SetTab",0);
                var el=evt.currentTarget || evt.srcElement;
                while (el && (!el.tagName || el.tagName.toLowerCase()!=tagName)) el=el.parentNode;
                return el;
        }

        function SetTabActive(tab){
                if (tab.tabTOC.activeTab){
                        if (tab.tabTOC.activeTab==tab) return;
                        KillClass(tab.tabTOC.activeTab,'active');
                        if (tab.tabTOC.activeTab.tabContent) KillClass(tab.tabTOC.activeTab.tabContent,'tabset_content_active');
                        //if (tab.tabTOC.activeTab.tabContent) tab.tabTOC.activeTab.tabContent.style.display='';
                        if (tab.tabTOC.activeTab.prevTab) KillClass(tab.tabTOC.activeTab.previousTab,'preActive');
                        if (tab.tabTOC.activeTab.nextTab) KillClass(tab.tabTOC.activeTab.nextTab,'postActive');
                }
                AddClass(tab.tabTOC.activeTab=tab,'active');
                if (tab.tabContent) AddClass(tab.tabContent,'tabset_content_active');                                
                //if (tab.tabContent) tab.tabContent.style.display='block';
                if (tab.prevTab) AddClass(tab.prevTab,'preActive');
                if (tab.nextTab) AddClass(tab.nextTab,'postActive');
        }
        function SetTabFromAnchor(evt){
                //setTimeout('document.body.scrollTop='+document.body.scrollTop,1);
                SetTabActive(FindEl('a',evt).semanticTab);
        }

        
        function Init(){
                window.everyTabThereIsById = {};
                
                var anchorMatch = /#([a-z][\w.:-]*)$/i,match;
                var activeTabs = [];
                
                var tocs = document.getElementsByTagName(tocTag);
                for (var i=0,len=tocs.length;i<len;i++){
                        var toc = tocs[i];
                        if (!HasClass(toc,tocClass)) continue;

                        var lastTab;
                        var tabs = toc.getElementsByTagName(tabTag);
                        for (var j=0,len2=tabs.length;j<len2;j++){
                                var tab = tabs[j];
                                if (!tab.href || !(match=anchorMatch.exec(tab.href))) continue;
                                if (lastTab){
                                        tab.prevTab=lastTab;
                                        lastTab.nextTab=tab;
                                }
                                tab.tabTOC=toc;
                                everyTabThereIsById[tab.tabID=match[1]]=tab;
                                tab.tabContent = document.getElementById(tab.tabID);
                                
                                if (HasClass(tab,'active')) activeTabs[activeTabs.length]=tab;
                                
                                lastTab=tab;
                        }
                        AddClass(toc.getElementsByTagName('li')[0],'firstchild');
                }

                for (var i=0,len=activeTabs.length;i<len;i++){
                        SetTabActive(activeTabs[i]);
                }

                for (var i=0,len=document.links.length;i<len;i++){
                        var a = document.links[i];
                        if (!(match=anchorMatch.exec(a.href))) continue;
                        if (a.semanticTab = everyTabThereIsById[match[1]]) AttachEvent(a,'click',SetTabFromAnchor,false);
                }
                
                if ((match=anchorMatch.exec(location.href)) && (a=everyTabThereIsById[match[1]])) SetTabActive(a);
                
                //Comment out the next line and include the file directly if you need IE5Mac or Opera7 support.
                //AddStyleSheet('tab_tabtastic.css',0);
        }
        Init();
},false);

//*** This code is copyright 2003 by Gavin Kistner, gavin@refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)


//***Cross browser attach event function. For 'evt' pass a string value with the leading "on" omitted
//***e.g. AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);

function AttachEvent(obj,evt,fnc,useCapture){
        if (!useCapture) useCapture=false;
        if (obj.addEventListener){
                obj.addEventListener(evt,fnc,useCapture);
                return true;
        } else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
        else{
                MyAttachEvent(obj,evt,fnc);
                obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
        }
} 

//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
        if (!obj.myEvents) obj.myEvents={};
        if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
        var evts = obj.myEvents[evt];
        evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
        if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
        var evts = obj.myEvents[evt];
        for (var i=0,len=evts.length;i<len;i++) evts[i]();
}
//*** This code is copyright 2002-2003 by Gavin Kistner, gavin@refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)

// Add a new stylesheet to the document;
// url [optional] A url to an external stylesheet to use
// idx [optional] The index in document.styleSheets to insert the new sheet before
function AddStyleSheet(url,idx){
        var css,before=null,head=document.getElementsByTagName("head")[0];

        if (document.createElement){
                if (url){
                        css = document.createElement('link');
                        css.rel  = 'stylesheet';
                        css.href = url;
                } else css = document.createElement('style');
                css.media = 'all';
                css.type  = 'text/css';

                if (idx>=0){
                        for (var i=0,ct=0,len=head.childNodes.length;i<len;i++){
                                var el = head.childNodes[i];
                                if (!el.tagName) continue;
                                var tagName = el.tagName.toLowerCase();
                                if (ct==idx){
                                        before = el;
                                        break;
                                }
                                if (tagName=='style' || tagName=='link' && (el.rel && el.rel.toLowerCase()=='stylesheet' || el.type && el.type.toLowerCase()=='text/css') ) ct++;
                        }
                }
                head.insertBefore(css,before);

                return document.styleSheets[before?idx:document.styleSheets.length-1];
        } else return alert("I can't create a new stylesheet for you. Sorry.");
}
// e.g. var newBlankSheetAfterAllOthers = AddStyleSheet(); 
// e.g. var newBlankSheetBeforeAllOthers = AddStyleSheet(null,0);
// e.g. var externalSheetAfterOthers = AddStyleSheet('http://phrogz.net/JS/Classes/docs.css');
// e.g. var externalSheetBeforeOthers = AddStyleSheet('http://phrogz.net/JS/Classes/docs.css',0);


// Cross-browser method for inserting a new rule into an existing stylesheet.
// ss       - The stylesheet to stick the new rule in
// selector - The string value to use for the rule selector
// styles   - The string styles to use with the rule
function AddRule(ss,selector,styles){
        if (!ss) return false;
        if (ss.insertRule) return ss.insertRule(selector+' {'+styles+'}',ss.cssRules.length);
        if (ss.addRule){
                ss.addRule(selector,styles);
                return true;
        }
        return false;
}

// e.g. AddRule( document.styleSheets[0] , 'a:link' , 'color:blue; text-decoration:underline' );
// e.g. AddRule( AddStyleSheet() , 'hr' , 'display:none' );
//*** This code is copyright 2002-2003 by Gavin Kistner and Refinery; www.refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)

//***Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj && (obj.className+=(obj.className.length>0?' ':'')+cName); }

//***Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),'')); }

//***Returns true if the object has the class assigned, false otherwise.
function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }



function expandnavover(sId, sImg, sOver, sShort) {

/*
        var oElement = document.getElementById(sId);
        var oCell = document.getElementById(sId + 'cell');
        var oImage = document.getElementById(sImg);
        
        if (oElement.style.display == 'none') {
                oCell.style.backgroundColor = sOver
                oImage.src = 'src/expandable_nav_' + sShort + '_over.gif';
        }
*/

}

function expandnavout(sId, sImg, sOut, sShort) {

/*
        var oElement = document.getElementById(sId);
        var oCell = document.getElementById(sId + 'cell');
        var oImage = document.getElementById(sImg);


        if (oElement.style.display == 'none')
        {
            oCell.style.backgroundColor = sOut
            oImage.src = 'src/expandable_nav_' + sShort + '_off.gif';
                
        }
*/
}

