var GLOBAL_URL_STATIC = "http://static.ferroalloynet.com/";
var GLOBAL_URL_WWW = "http://www.ferroalloynet.com/";

function emailThisPage(){
	var url=window.location.href;
	window.open(GLOBAL_URL_WWW+"pages/sendemail.html?sendurl="+escape(url));
}
function addToFavorite(url,title){
	if(!url || url==null) url = window.location.href;
	if(!title || title==null) title = document.title;
	if(title==null) title = "";
	window.external.AddFavorite(url,title);
}
function printThisPage(){
	window.print();
}

function trim(inputString) {
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	}
	return retValue;
}

function gosearch(isclick,keyobj){
	if(!isclick){
		var key;
		if(window.event)
			key = window.event.keyCode; //IE
		else
			key = e.which; //firefox
        if (key != 13){
			return;
		}
	}
	if(!document.getElementById(keyobj)) return;
	var _validkeys = /[^a-zA-Z0-9]/g;
	var _txtobj = document.getElementById(keyobj);
	var _key = _txtobj.value.replace(_validkeys," ");
	_key = trim(_key);
	_key = _key.toLowerCase();
	_txtobj.value = _key;
	if(_key==""){
		alert("Please input a search term.");
		_txtobj.focus();
		return;
	}
	
	window.location=GLOBAL_URL_WWW+"search/"+_key.replace(/ /g,"+")+".html";
}

function menuFix() {
	if(!document.getElementById("Global_Icon_Right_Container_UL")) return;
	var sfEls = document.getElementById("Global_Icon_Right_Container_UL").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className="sfhover";
			}
			sfEls[i].onMouseDown=function() {
				this.className="sfhover";
			}
			sfEls[i].onMouseUp=function() {
				this.className="sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className = "sfouthover";
			}
			
//			sfEls[i].onmouseover=function() {
//				this.className+=(this.className.length>0? " ": "") + "sfhover";
//			}
//			sfEls[i].onMouseDown=function() {
//				this.className+=(this.className.length>0? " ": "") + "sfhover";
//			}
//			sfEls[i].onMouseUp=function() {
//				this.className+=(this.className.length>0? " ": "") + "sfhover";
//			}
//			sfEls[i].onmouseout=function() {
//				//this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
//			}
	}
}
window.onload=menuFix;