// Special handling for CSS-P redraw bug in Navigator 4
function handleResize() {
    if (isNN4) {
        // causes extra re-draw, but gotta do it to get banner object color drawn
        location.reload();
    } else {
		initMenus();
    }
}

function getPos(el,sProp) {
	var iPos = 0
	var alertTxt = ""
		while (el!=null) {
			alertTxt+="el: " + el + "\n"
			alertTxt+="el.offsetWidth: " + el.offsetWidth + "\n" + "el.offsetHeight: " + el.offsetHeight + "\n"
			alertTxt+="el.offset" + sProp + ": " + el["offset" + sProp] + "\n"
			alertTxt+="el." + sProp + ": " + el[sProp] + "\n"
			alertTxt+="el.style." + sProp + ": " + el["style." + sProp] + "\n"
			iPos+=el["offset" + sProp]
			el = el.offsetParent
		}
	alertTxt+="iPos = " + parseInt(iPos) + "\n"
	//alert(alertTxt)
	return iPos
}

/* Create the navigation arrays */
menus = new Array('worldwideOffices','aboutUs','franklinGraham','ourWork','giving','knowingGod','OCC', 'WMM', 'CHP', 'PFH'); // used for the initMenus() and hideAll() functions.
//have drop down on all tabs
menuSectionID = new Array('');
//no drop down on active tab
/*menuSectionID = new Array('','40','41','42','44','45');

/* check browser */
var myBrowser = navigator.userAgent;
function checkBrowser(){
	ns4 = (document.layers) ? true : false;
	ie4 = (document.all && !document.getElementById) ? true : false;
	ie5 = (document.all && document.getElementById) ? true : false;
	ns6 = (!document.all && document.getElementById) ? true : false;
	isMac = false;
	if(myBrowser.indexOf('Mac') > -1){isMac = true;}
}

/* This Function gives you an object back by passing it an id - used in menu functions only */
function checkIn(id) {
	if(ie4){return document.all[id].style;}
	if(ie5 || ns6){return document.getElementById(id).style;}
	else{return document[id];}
}

/* change layer visibility */
function changeVisibility() {
	var status = arguments[0];
	var endInc = arguments.length;
	for(i=1; i<arguments.length; i++){
		obj = checkIn(arguments[i]);
		obj.visibility = status;
	}
}

/* Hides all layers in the navigation */
function hideAll(){
	for(i=0; i<menus.length; i++){
		//then proceed to turn off the layer.
		obj = checkIn(menus[i]);
		clearTimeout(obj.timer);
		expression = "changeVisibility('hidden','"+ menus[i] +"')";
		obj.timer = setTimeout(expression,150);
	}
	
}

/* Shows a certain layer with a timer */
function showNavMenu(id){
	p = eval(id + ".parent");
	obj = checkIn(id);
	clearTimeout(obj.timer);
	expression = "changeVisibility('visible','"+ id +"')";
	for (i=0; i<menus.length; i++) {
		if (menus[i] == id) {
			//alert("thisPageSubSectionID: " + thisPageSubSectionID);
			if (menuSectionID[i] != thisPageSectionID || (thisPageSubSectionID >= 21 && thisPageSubSectionID <= 24) || !blnSubNavOn) { //blnSubNavOn set by ASP in SP_HTML_Header.asp
				if (!isSafari) {
					obj.timer = setTimeout(expression,150);
				}
			}
		}
	}
	//obj.timer = setTimeout(expression,150);
	/*if(p != "main"){
		//then turn it on.
		expression = "changeVisibility('visible','"+ p +"')";
		p = checkIn(p);
		clearTimeout(p.timer);
		p.timer = setTimeout(expression,150);
	}*/
}

//////////////////////////////////////////////////////////////
// Initialize Menus
//////////////////////////////////////////////////////////////
var macIE = {left:0, top:0};
var isSafari = false;
if (navigator.userAgent.indexOf("MSIE 5.2") != -1) macIE = {left:-3, top:-8};
if (navigator.userAgent.indexOf("Safari") != -1) { macIE = {left:1, top:33};
	isSafari = true;
}
function initMenus(){
	//alert("initMenus");
	for(i=0; i<menus.length; i++) {
		parentObj = getRawObject(menus[i] + '_main');
		menuObj = getRawObject(menus[i]);
		//alert("left: " + getPos(parentObj,"Left") + "\n" + "top: " + getPos(parentObj,"Top"))
		if (!isSafari) {
			sTLeft = getPos(parentObj,"Left") + macIE.left;
			if (menus[i] == 'worldwideOffices') {
				sTTop = (getPos(parentObj,"Top") + 13);
			} else {
				sTTop = (getPos(parentObj,"Top") + 29) + macIE.top;
			}
			shiftTo(menuObj, sTLeft, sTTop);
		} else {
			/*
			objCenterPos = Math.round((getInsideWindowWidth()/2));
			intRightShift = 0;
			intTopShift = 0;
			if (objCenterPos > 0) {
				switch(menus[i]) {
					case 'worldwideOffices':
						intRightShift = 0;
						intTopShift = 13;
						break;
					case 'aboutUs':
						intRightShift = -315;
						intTopShift = 101;
						break;
					case 'franklinGraham':
						intRightShift = 0;
						intTopShift = 0;
						break;
					case 'ourWork':
						intRightShift = 0;
						intTopShift = 0;
						break;
					case 'giving':
						intRightShift = 0;
						intTopShift = 0;
						break;
					case 'knowingGod':
						intRightShift = 0;
						intTopShift = 0;
						break;
					default:
						intRightShift = 0;
						intTopShift = 0;
				}
				//alert("objCenterPos+intRightShift: " + (objCenterPos + intRightShift) + "\n" + "intTopShift: " + intTopShift);
				shiftTo(menuObj, (objCenterPos + intRightShift), intTopShift);
			}
			*/
		}
	}
}

checkBrowser();
