function setBodyLoaded(){
	bodyLoaded = true;
}

function callInProgress(http) {
    switch ( http.readyState ) {
        case 1, 2, 3:
		return true;
        break;
        // Case 4 and 0
        default:
            return false;
        break;
    }
}


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(menuNum,obj){
	showMenu = true;
	setTimeout('CanSndReq("'+menuNum+'","'+obj+'")',750);
}

function CanSndReq(menuNum,obj){
	if(showMenu){
		if(bodyLoaded == true){
			 sndReq1(menuNum,obj);
		 }
		 else{
			setTimeout('CanSndReq("'+menuNum+'","'+obj+'")',500);
		 }
	 }
}

function sndReq1(menuNum,obj) {

var timeoutId = window.setTimeout(
    function() {
       if ( callInProgress(http) ) {
           http.abort();
        }
    },
    2000 // the delay in miliseconds
);

    http.open('GET', '/lowes/jsp/menu.jsp?menuNum='+menuNum,true);
    http.onreadystatechange = function(){
    if(http.readyState == 4){

		window.clearTimeout(timeoutId);

		var el = getObj("fomenu") ;
		el.onMouseOut= closeAll();
		el.innerHTML = http.responseText;
		setTimeout('show("'+menuNum+'","'+obj+'")',100);
    }

};

	if ( !callInProgress(http) ) {
		try{
		  http.send(null);}
		  catch(e){
		  	//alert("Please wait, Loading Menu");
		  }
	}


}

var bodyLoaded = false;
var showMenu;
var checkIt;
var DHTML = (document.getElementById || document.all || document.layers);
var useMask = false;
var theMask;

// Turn iFrame mask on for IE 5.5+ / PC only
if (is_ie && !is_mac_ie) {
	if (is_ie5_5up) {
		useMask = true;
	}
	/*else {
		hideSels = true;
	}*/
}

//function show(name,lvl,obj) {
function show(name,obj) {

	if (!DHTML) return;

	closeAll();

	if (name) {
		
		theTable = "table" + name;
		name = "mastheadmenu" + name;
	var x = getObj(name).style;
		if (useMask) {
			theMask = getObj("iMask");
			theMask.style.left = x.left;
		    theMask.style.top = 145;
			theMask.style.width = getObj(theTable).offsetWidth;
		    theMask.style.height = getObj(theTable).offsetHeight - 1;
		}

		var notProject=(name != 'mastheadmenu6');
		x.visibility = 'visible';
		/*if(notProject) {
			document.getElementById("searchType").style.visibility = "hidden";
		} */
	}
	
	
	if (obj.parentNode) y = obj.parentNode;
	else if (obj.parentElement) y = obj.parentElement;
	else return;
	if (y.className) return;
	y.className = 'over';

}

function closeAll() {

	var x, x0, x1, x2, x3, x4, x5 ;

	if(getObj("mastheadmenu0")) x0 = getObj("mastheadmenu0").style;
	if(getObj("mastheadmenu1")) x1 = getObj("mastheadmenu1").style;
	if(getObj("mastheadmenu2")) x2 = getObj("mastheadmenu2").style;
	if(getObj("mastheadmenu3")) x3 = getObj("mastheadmenu3").style;
	if(getObj("mastheadmenu4")) x4 = getObj("mastheadmenu4").style;
	if(getObj("mastheadmenu5")) x5 = getObj("mastheadmenu5").style;
	
	
	if(x0)	x0.visibility = 'hidden';
	if(x1)	x1.visibility = 'hidden';
	if(x2)	x2.visibility = 'hidden';
	if(x3)	x3.visibility = 'hidden';
	if(x4)	x4.visibility = 'hidden';
	if(x5)	x5.visibility = 'hidden';


	if(getObj("fomenu")) x = getObj("fomenu").style;
	if(x)	x.visibility = 'hidden';

	getObj("searchType").style.visibility = "visible";
    
	
	if (useMask) {
		if (theMask) {
	    	theMask.style.top = -600;
		}
	}
}


function checkUserInput() {
	showMenu = false;
	checkIt = setTimeout('closeAll()',200);
}


function getObj(name) {
	if (document.getElementById) {
		return document.getElementById(name);
	} else if (document.all) {
		return document.all[name];
	} else if (document.layers) {
		return document.layers[name];
	} else return false;
}
