var bNetscape4 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4" && navigator.appVersion.substring(0,1) < "5");

var bNetscape5 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "5");

var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

//==============================================================================
// Global variable to keep track of wheather or not the mouse pointer is on top 
// of a menu button.
//==============================================================================
var bMouseOnMenu = true;
//==============================================================================
// Global variable used for the setTimeout and clearTimeout functions.
//==============================================================================	
var nTimerID = 0;
var nPageTopSave = 0;
var bTop = 1;

function img_over(imgName, objName, imgDir, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/" + imgDir + "/" + imgName
		if (imgType == 1)
			sTemp += "_on.gif";
		else
			sTemp += "_on.jpg";
		
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_out(imgName, objName, imgDir, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/" + imgDir + "/" + imgName
		if (imgType == 1)
			sTemp += ".gif";
		else
			sTemp += ".jpg";
			
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_over_res(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/residential/" + imgName
		if (imgType == 1)
			sTemp += "_on.gif";
		else
			sTemp += "_on.jpg";
		
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_out_res(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/residential/" + imgName
		if (imgType == 1)
			sTemp += ".gif";
		else
			sTemp += ".jpg";
			
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_over_com(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/commercial/" + imgName
		if (imgType == 1)
			sTemp += "_on.gif";
		else
			sTemp += "_on.jpg";
		
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_out_com(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/commercial/" + imgName
		if (imgType == 1)
			sTemp += ".gif";
		else
			sTemp += ".jpg";
			
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_over_mp(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/masterPlanning/" + imgName
		if (imgType == 1)
			sTemp += "_on.gif";
		else
			sTemp += "_on.jpg";
		
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function img_out_mp(imgName, objName, imgType) {
	var sTemp;
	if (document.images)  {
		sTemp = "/images/masterPlanning/" + imgName
		if (imgType == 1)
			sTemp += ".gif";
		else
			sTemp += ".jpg";
			
		if (bNetscape4)
			document.layers['fg'].document.images[objName].src = sTemp;
		else
			document [objName].src = sTemp;
	}
}

function fnNavBar()
{
	var nWidth = fnInsideWindowWidth() - 750;
	if (nWidth < 0)
		nWidth = 0;
	else
		nWidth /= 2;
		
	if ( bNetscape4 ) {
		
		document["navBar"].left = nWidth + 196;
		//document["navBar"].top = top.pageYOffset + 20;
		document["navBar"].visibility = "visible";
		
		
	}
	else if (bNetscape5) {

		document.getElementById("navBar").style.left = nWidth + 196;
		document.getElementById("navBar").style.visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		
		navBar.style.left = nWidth + 198;
		//bg.style.top = document.body.scrollTop;
		navBar.style.visibility = "visible";
	}
	
	// initializing UI update timer
	//fnCheckUIElements();
	return true;
}

//==============================================================================
// fnMenu2
//		This function displays or hides a secondary navigation menu bar.
//
//    Input:  objName (string) - The object name of the menu layer.
//            bShow (bool) - display menu if true otherwise hide.
//            nArrowY (int) - The arrow pointer Y access position.
//            nMenuY (int) - The menu Y access position.
//
//    Output:  None
//
//  Date      Who  Description
//  --------  ---  ------------------------------------------------------------
//  01/03/01  BRW  Function Created
//
//==============================================================================
function fnMenu2(objName, bShow)
{
	var nY;
	
	if ( bNetscape4 ) {
		if (bShow) {
			fnNavBar();
			//nY = window.pageYOffset;
			//document["arrow"].top = nArrowY + nY;
			//document[objName].top = nMenuY + nY;
			document[objName].visibility = "visible";
			//document["arrow"].visibility = "visible";
		}
		else {
			document[objName].visibility = "hidden";
			//document["arrow"].visibility = "hidden";
		}
	}
	else if (bNetscape5) {
		if (bShow) {
			fnNavBar();
			//nY = window.pageYOffset;
			//document.getElementById("arrow").style.top = (nArrowY + nY) + "px";
			//document.getElementById(objName).style.top = (nMenuY + nY) + "px";
			document.getElementById(objName).style.visibility = "visible";
			//document.getElementById("arrow").style.visibility = "visible";
		}
		else {
			document.getElementById(objName).style.visibility = "hidden";
			//document.getElementById("arrow").style.visibility = "hidden";
		}
	}
	else if ( bExplorer4plus ) {
		if (bShow) {
			fnNavBar();
			//nY = document.body.scrollTop;
			//arrow.style.top = nArrowY + nY;
			//eval(objName + ".style.top = " + (nMenuY + nY));
			eval(objName + ".style.visibility = 'visible'");
			//arrow.style.visibility = 'visible';
		}
		else {
			//arrow.style.visibility = 'hidden';
			eval(objName + ".style.visibility = 'hidden'");
		}
	}

	return true;
}

//==============================================================================
// fnCloseMenu2
//		This function hides the passed secondary menu layer and then removes
//      the highlight from the primary navigation bar.
//
//    Input:  objName (string) The object name of the secondary menu layer.
//
//    Output:  None
//
//  Date      Who  Description
//  --------  ---  ------------------------------------------------------------
//  01/03/01  BRW  Function Created
//
//==============================================================================
function fnCloseMenu2(objName) 
{
	var sImgName;
	
	if (!bMouseOnMenu) {
		fnMenu2(objName, 0)
		
		// Primary nav bar image name is the same as the name of the secondary menu
		// layer object less the last character.
		//sImgName = objName.slice(0, -1);	
		//fnReplaceImg(sImgName);
	}
}

//==============================================================================
// fnCloseMenu
//		This function hides the passed secondary menu layer after the passed
//      number of seconds have elapsed.
//
//    Input:  objName (string) The object name of the secondary menu layer.
//            nWaitSec (int) The number of seconds to wait before hiding menu.
//
//    Output:  None
//
//  Date      Who  Description
//  --------  ---  ------------------------------------------------------------
//  01/03/01  BRW  Function Created
//
//==============================================================================
function fnCloseMenu(objName, nWaitSec) 
{
	var sTemp;
	var nWaitMS = 0;
	
	if (nWaitSec > 0)
		nWaitMS = nWaitSec * 1000;
		
	clearTimeout(nTimerID);
	sTemp = "fnCloseMenu2('" + objName + "')";
	//alert(sTemp);
	nTimerID = setTimeout(sTemp, nWaitMS);
	
	

}

//============================================================================
// Returns the available content width space in browser window
//============================================================================
function fnInsideWindowWidth() {
	if (bNetscape4 || bNetscape5) {
		return window.innerWidth
	} else {
		return document.body.clientWidth
	}
}

//============================================================================
// Returns the available content height space in browser window
//============================================================================
function fnInsideWindowHeight() {
	if (bNetscape4 || bNetscape5) {
		return window.innerHeight
	} else {
		return document.body.clientHeight
	}
}

//============================================================================
// Position an element at a specific x,y location
//============================================================================
function fnShiftTo(sObjName, obj, x, y) {
	if (bNetscape4) 
		obj.moveTo(x,y)
	else if (bNetscape5) {
		document.getElementById(sObjName).style.left = x + "px";
		document.getElementById(sObjName).style.top = y + "px";
	}
	else {
		obj.pixelLeft = x
		obj.pixelTop = y
	}
}

//============================================================================
// Center the passed image object in the current window/frame, and show it
//============================================================================
function fnCenterIt(sObjName, nObjWidth, nY) {
	var coll = "";
	var styleObj = "";
	var nWidth = 0;
	var nMinSize = 750;
	if (bExplorer4plus) {
		coll = "all.";
		styleObj = ".style";
	}
	
	//alert("document." + coll + sObjName + styleObj);
	// 'obj' is the positionable object
	var obj = eval("document." + coll + sObjName + styleObj)
	//alert(obj);
	// 'contentObj' is the element content, necessary for IE4 to return the
	//   true current width
	var contentObj = eval("document." + coll + sObjName)
	nWidth = fnInsideWindowWidth();
	if (nWidth < nMinSize) {
		if (bExplorer4plus) 
			nWidth = nMinSize + 24;
		else
			nWidth = nMinSize + 18;
	}
	var x = Math.round((nWidth/2) + 375 - nObjWidth)
	if (bExplorer4plus)
		x -= 11;
	else
		x -= 9;
		
	var y = Math.round((fnInsideWindowHeight()/2) - 400/2)

	fnShiftTo(sObjName, obj, x, nY)
	if (bNetscape5)
		document.getElementById(sObjName).style.visibility = "visible";
	else
		obj.visibility = "visible";

}

//============================================================================
// Center the passed image object in the current window/frame, and show it
//============================================================================
function fnPosLeft(sObjName, nObjWidth, nY) {
	var coll = "";
	var styleObj = "";
	var nWidth = 0;
	var nMinSize = 750;
	if (bExplorer4plus) {
		coll = "all.";
		styleObj = ".style";
	}
	
	//alert("document." + coll + sObjName + styleObj);
	// 'obj' is the positionable object
	var obj = eval("document." + coll + sObjName + styleObj)
	//alert(obj);
	// 'contentObj' is the element content, necessary for IE4 to return the
	//   true current width
	var contentObj = eval("document." + coll + sObjName)
	nWidth = fnInsideWindowWidth();
	if (nWidth < nMinSize) {
		if (bExplorer4plus) 
			nWidth = nMinSize + 24;
		else
			nWidth = nMinSize + 18;
	}
	var x = Math.round((nWidth/2) - 375)
	if (bExplorer4plus)
		x -= 10;
	else
		x -= 7;
		
	var y = Math.round((fnInsideWindowHeight()/2) - 400/2)

	fnShiftTo(sObjName, obj, x, nY)
	if (bNetscape5)
		document.getElementById(sObjName).style.visibility = "visible";
	else
		obj.visibility = "visible";

}
