// class: expandingLogin

// method: open - switches from closed login state to open login state
function expandingLogin_open() {
	
	// set the margin height (between header and left rail)
	document.getElementById(this.spacerLogin).style.height = this.openMargin;
	// hide the closed login state div
	document.getElementById(this.closedLogin).style.visibility = "hidden";
	// show the open login state div
	document.getElementById(this.openLogin).style.visibility = "visible";
}

// method: close - switches from open login state to closed login state
function expandingLogin_close() {
	
	// hide the open login state div
	document.getElementById(this.openLogin).style.visibility = "hidden";
	// show the closed login state div
	document.getElementById(this.closedLogin).style.visibility = "visible";
	// set the margin height (between header and left rail)
	document.getElementById(this.spacerLogin).style.height = this.closedMargin;
}

// constructor:
function expandingLogin() {
	
	// set the div id for the closed login state
	this.closedLogin = "formLoginClosed";
	// set the div id for the open login state
	this.openLogin = "formLoginOpen";
	// set the div id for the login spacer
	this.spacerLogin = "genLoginSpacer";
	
	// set the margin (between header and left rail) for the open login state
	this.openMargin = "89px";
	// set the margin (between header and left rail) for the closed login state
	this.closedMargin = "11px";

	// method: open - switches from closed login state to open login state
	this.open = expandingLogin_open;
	// method: close - switches from open login state to closed login state
	this.close = expandingLogin_close;
}



// function: left nav rollover
// controls rollover for second level left nav items

function navRoll(item) {
	
	// if the nav item is not defaulted to the rollover state then change the nav item class
	if(item.parentNode.className != 'navHot')
		// if the nav item is in the hover state change it to the default state
		if(item.parentNode.className == 'navHover')
			item.parentNode.className = '';
		// if the navitem is not in the hover state change it to the hover state
		else
			item.parentNode.className = 'navHover';
}



// function: promo switcher
// displays a given homepage promo div and hides all other promo divs

function showPromo(index) {

	// loop through all homepage promo divs
	for(i=1; i<5; i++) {
		
		// if the promo div number matches the index parameter then show it
		if(i == index)
			document.getElementById('hpPromoBar'+i).style.visibility = "visible";
		// if the promo div number does not match the index parameter then hide it
		else
			document.getElementById('hpPromoBar'+i).style.visibility = "hidden";
	}
}



// function: anchor link dropdown linker
// drops down the current page to a specified indexed anchor link

function gotoAnchorLink(index) {

	// if the index paramater is not empty
	if(index != null && index != "") {
		
		// get the current document url
		var locationString = document.location.href;
		var locationArray = new Array();

		// parse the current document url
		locationArray = locationString.split('#');
		// set the dcoument url to the current document url + the index to the specified anchor link
		document.location.href = locationArray[0] + "#" + index;
	}
}



// function: NE style sheet corrector
// corrects for the difference in box model implementation between IE and NE

// the browser is not IE
if(!window.showHelp) {

	// loop through all css style sheets
	for(i=0; i<document.styleSheets.length; i++) {
		
		// loop through all ccs style rules
		for(j=0; j<document.styleSheets[i].cssRules.length; j++) {
			
			// get the width, height and padding attributes of the current css rule
			w = document.styleSheets[i].cssRules[j].style.width;
			h = document.styleSheets[i].cssRules[j].style.height;
			p = document.styleSheets[i].cssRules[j].style.padding;
			
			// ignore all rules applied only to img tags
			if(document.styleSheets[i].cssRules[j].cssText.indexOf("img") != -1)
				img = true;
			else
				img = false;

			// parse the current css rule to obtain the top, right, bottom and left padding values
			pt = -1;
			pr = -1;
			pb = -1;
			pl = -1;

			if(p != "" && p != "0px" && p != "0px 0px 0px 0px") {
				
				pa = p.split(" ");

				if(pa.length == 4) {
					
					pt = pa[0].substr(0,pa[0].length-2);
					pr = pa[1].substr(0,pa[1].length-2);
					pb = pa[2].substr(0,pa[2].length-2);
					pl = pa[3].substr(0,pa[3].length-2);
				}
			}

			// if the rule has a width attribute and right or left padding
			if(!img && (w.indexOf('px') != -1) && (pr != -1 && pl != -1)) {
				
				// adjust width value to work with NE box model
				w = w.substr(0,w.length-2);
				w = w - pr - pl;
				
				// alert(document.styleSheets[i].cssRules[j].cssText);
				
				// set the width attribute to the adjusted value
				document.styleSheets[i].cssRules[j].style.width = w+"px";
			}
			
			// if the rule has a height attribute and top or bottom padding
			if(!img && (h.indexOf('px') != -1) && (pt != -1 && pb != -1)) {

				// adjust the height value to work with the NE box model
				h = h.substr(0,h.length-2);
				h = h - pt - pb;
				
				//alert(document.styleSheets[i].cssRules[j].cssText);

				// set the height attribute to the adjusted value
				document.styleSheets[i].cssRules[j].style.height = h+"px";
			}
		}
	}
}




// this function is used to open a new window with a close button

function openWin(url,name,w,h,scroll) {
   var att = 'width='+ w +',height='+ h +',left=50,top=50,scrollbars='+ scroll +',resizable=yes'
   window.open(url,name,att);	
   self.name="Main";
}

// this sets the childwin declaration for help

childwin = null

// this will open a context-sensitive help window

function openHelp(url,e){
w = screen.width-470
h = screen.height-370
x = e.screenX
y = e.screenY
	if(x > w){
		x = x-470
		}
	if(y > h){
		y = y-370
		}
childwin=window.open(url, "childwin", "width=470,height=370,top="+y+",left="+x+",scrollbars=yes,resizable=yes")
}

// this will open a pop-up help window

function openHelp2(url,e,v){
w = screen.width-470
h = screen.height-v
x = e.screenX
y = e.screenY
	if(x > w){
		x = x-470
		}
	if(y > h){
		y = y-v
		}
childwin=window.open(url, "childwin", "width=470,height="+v+",top="+y+",left="+x+",scrollbars=yes,resizable=yes")
}
