// USGBC.ORG Global Javascript

//MAIN NAV
//WORK AROUND FOR IE HOVER
sfHover = function() 
	{
		var test = document.getElementById("main_nav");
		if (test != null)
		{
				var sfEls = document.getElementById("main_nav").getElementsByTagName("li");
				for (var i=0; i<sfEls.length; i++) 
				{
					sfEls[i].onmouseover=function() {
						this.className+=" sfhover";
					}
					sfEls[i].onmouseout=function() {
						this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
					}
				}
		}
	}
if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
}

//NAV SEARCH MENU
function search_menu() {
	var state = getStyle(document.getElementById("search_menu"), "left");
	if (state=="auto" || parseInt(state) > 0){
		document.getElementById('search_menu').style.left="-999em";
		document.getElementById('search_menu_btn').style.backgroundPosition="0 0";
	} else {
		document.getElementById('search_menu').style.left="auto";
		document.getElementById('search_menu_btn').style.backgroundPosition="0 -56px";
	}
}

function set_search(dir,order) {
	document.forms.search_form.search_dir.value = dir;
	
	var smOpt = document.getElementById("search_menu").getElementsByTagName("li");
	
	for (var i=0; i<smOpt.length; i++) {	
	
		if (i==order) {
			smOpt[i].className="select";
		} else {
			smOpt[i].className="";
		}
	}
}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}



