// don't want to wait till after the page loads
document.write("<style type='text/css'>#container #app-login label { display: none; }</style>");

// <utilities>
// cf. http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
function addEvent(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}


function pdfpopup(link)
{
	newwin = window.open(link); 
}





// cf. http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
function getElementsByClassName(oElm, strTagName, strClassName) {
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

// cf. http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
function createElement(element) {
	if (typeof document.createElementNS != "undefined") {
		return document.createElementNS("http://www.w3.org/1999/xhtml", element);
	}
	if (typeof document.createElement != "undefined") {
		return document.createElement(element);
	}
	return false;
}
// </utilities>

//// NA_navMain() sets all the events needed for the main nav
//function NA_navMain() {
//	if(document.getElementById("nav-main1")) {
//		// loop through all IMGs
//		var els = document.getElementById("nav-main1").getElementsByTagName("IMG");
//		for (var i=0; i<els.length; i++) {
//			// if this nav is on we don't want to turn it off by mousing off
//			if (els[i].parentNode.parentNode.tagName != "STRONG") {
//				els[i].onmouseover = function() {
//					this.src = this.src.replace("-off", "-over");
//				}
//				els[i].onmouseout = function() {
//					this.src = this.src.replace("-over", "-off");
//				}
//			}
//		}
//	}
//}
//addEvent(window, "load", NA_navMain);

var button_ID = "";

function NA_navMain_public() {
	if(document.getElementById("nav-main1")) {
		// loop through all IMGs
		var els = document.getElementById("nav-main1").getElementsByTagName("IMG");
		for (var i=0; i<els.length; i++) {
			// if this nav is on we don't want to turn it off by mousing off
			if (els[i].parentNode.parentNode.tagName != "STRONG") {
				els[i].onmouseover = function() {
					this.src = this.src.replace("-off", "-over");
				}
				els[i].onmouseout = function() {
					this.src = this.src.replace("-over", "-off");
				}
				if(button_ID != "")
				if(button_ID == els[i].parentNode.parentNode.id)
				{
				    els[i].src = els[i].src.replace("-off", "-over");
				    els[i].onmouseover = "";
				    els[i].onmouseout = ""; 
				    
				}
				    
			}
		}
	}
}
addEvent(window, "load", NA_navMain_public);

// NA_ieChildren() allows IE to compensate for not supporting CSS
function NA_ieChildren(id,tag) {
	if(document.getElementById(id))	{
		var els = document.getElementById(id).getElementsByTagName(tag);
		for (var i=els.length-1; i>=0; i--) {
			els[i].firstChild.className += " first-child";
			els[i].lastChild.className  += " last-child";
		}
	}
}
function NA_ieChildren_init() {
	NA_ieChildren("nav-section","UL");
	NA_ieChildren("siteinfo-legal","UL");
	NA_ieChildren("content","UL");
	NA_ieChildren("content","TR");
	NA_ieChildren("content","TBODY");
}
//addEvent(window, "load", NA_ieChildren_init);

// NA_altRows() allows for zebra stripes in TABLEs
function NA_altRows() {
	var rows;
	var els = document.getElementsByTagName("TBODY");
	for(var i=0; i<els.length; i++) {
		rows = els[i].getElementsByTagName("TR");
		for(var j=0; j<rows.length; j++) {
			if(j % 2) {
				rows[j].className += " odd";
			}
		}
	}
}
//addEvent(window, "load", NA_altRows);

// cf. http://www.456bereastreet.com/archive/200505/transparent_custom_corners_and_borders/
// moddified by http://www.navarts.com/
function NA_roundCorners() {
	if(document.getElementById && document.createTextNode) {
		var divNew, divN, divE, divS, divW, divNW, divNE, divSE, divSW;
		var elm      = "container";
		var tag      = "div";
		var classOld = "round";
		var classNew = "wjs";
		// Find all elements
		var naDivs = getElementsByClassName(document.getElementById(elm), tag, classOld);
		// Loop through the found elements
		for (var i = 0; i < naDivs.length; i++) {
		//  Save the original div for later
			divSW = naDivs[i];
		// 	Create a new div, give it the original div's class attribute, and add "wjs"
		//  This way we know the JS ran, and can adjust styles
			divNew = createElement("div");
			divNew.className  = divSW.className;
			divNew.className += classNew;
		// Change the original div's class name and replace it with the new div
			divSW.className = "sw";
			divSW.parentNode.replaceChild(divNew, divSW);
		// Create two new div elements and insert them into the outermost div
			divN = createElement("div");  divN.className = "n";
			divNew.appendChild(divN);
			divE = createElement("div");  divE.className = "e";
			divN.appendChild(divE);
			divS = createElement("div");  divS.className = "s";
			divE.appendChild(divS);
			divW = createElement("div");  divW.className = "w";
			divS.appendChild(divW);
			divNW = createElement("div"); divNW.className = "nw";
			divW.appendChild(divNW);
			divNE = createElement("div"); divNE.className = "ne";
			divNW.appendChild(divNE);
			divSE = createElement("div"); divSE.className = "se";
			divNE.appendChild(divSE);
		// Insert the original div
			divSE.appendChild(divSW);
		}
	}
}
addEvent(window, "load", NA_roundCorners);

function highlight(tabID)
{
//    tab = document.getElementById(tabID);
//    link = tab.firstChild;
//    //text = link.textContent;
//    //tab.innerHTML = "<strong><a href=" + link + ">" + text + "</a></strong>";
//    highliter = createElement("strong");
//    tab.replaceChild(highliter,link);
//    highliter.appendChild(link);
    tab = document.getElementById(tabID);
    tab.className = "strong";
}

function hilite(tabID)
{

    tab = document.getElementById(tabID);
    link = tab.firstChild;
    highliter = createElement("strong");
    tab.replaceChild(highliter,link);
    highliter.appendChild(link);
}




    
function tab_highlight(toptab)
{
    tab = document.getElementById(toptab);
    tab.className = "on";
}

//get the value of a querystring parameter
//eg. get_querystring_value("symbol") might return "ndaq" or false

function get_querystring_value(parameter)
 {
    string = unescape(String(top.location.search));//grab parameter string
    if(string!="")
    {
        parameter = parameter.toLowerCase();
        string=string.substring(1).split("&"); //separate out into a list
        
        for(var i=0; i<string.length; i++)
        {
            params = string[i].split("=");
            
            if(params[0].toLowerCase() == parameter)
            {   
                
                if(params[1] != "")
                    return params[1]; //parameter found -- return value
                else
                    return false;  //parameter found but no value set
            }
        }
        return false; //querystring parameter not found
         
    }
    else
        return false;//no querystring parameters
 }

//check for the existence of a querystring parameter pair
//eg. check_querystring("symbol=ndaq") might return true

function check_querystring(parameter)
{
    string = unescape(String(top.location.search));//grab parameter string
    if(string!="")
    {
        string=string.substring(1);  //remove ? from the query
        string=string.split("&"); //separate out into a list
        for(var i=0; i<string.length; i++)
        {
            if(string[i].toLowerCase()==parameter.toLowerCase())
            return true;
        }
        return false; //querystring parameter not found
         
    }
    else
        return false;//no querystring parameters
 }
 
 function set_cookie(parameter, value, days)
 {
    paramter = String(parameter);
    if(navigator.cookieEnabled)
    {
        var exdate=new Date();
		exdate.setDate(exdate.getDate()+days);//expires in two weeks
		
        document.cookie = parameter + "=" + value + ";expires=" + exdate;
        return true;
    }    
    else
        return false;//cookies not enabled
 }
 
 function get_cookie(parameter)
 {
    parameter = String(parameter); //convert to string
    if(navigator.cookieEnabled)
    {
        var index = document.cookie.indexOf(parameter); //find first occurence 
        if(index != -1) //cookie exists
        {
            index += parameter.length + 1; //positioned after "="
            var end = document.cookie.indexOf(";", index); //get the ending index            
                if(end == -1) //cookie is last in the list
                    end = document.cookie.length;            
 
            var value = unescape(document.cookie.substring(index,end)); //get the value
            return value;
        }
        else
            return false;//cookie doesnt exist
    }
    else
        return false; //cookies not enabled
 }
 
function popupApp1(url)
{
window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=985, height=725")
}

function popupMSG(url)
{
window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=1024, height=685")
}


