var path = "http://www.fhlbsf.com/images/navs/";
var currentImage ="menu0";

if (document.images) {
	menu1Off = new Image();
	menu1Off.src = path + "home.gif";
	menu1Hi = new Image();
	menu1Hi.src = path + "home2.gif";

	menu2Off = new Image();
	menu2Off.src = path + "login.gif";
	menu2Hi = new Image();
	menu2Hi.src = path + "login2.gif";

	menu3Off = new Image();
	menu3Off.src = path + "contact.gif";
	menu3Hi = new Image();
	menu3Hi.src = path + "contact2.gif";

	menu4Off = new Image();
	menu4Off.src = path + "sitemap.gif";
	menu4Hi = new Image();
	menu4Hi.src = path + "sitemap2.gif";

	menu5Off = new Image();
	menu5Off.src = path + "termsofuse.gif";
	menu5Hi = new Image();
	menu5Hi.src = path + "termsofuse2.gif";

	menu6Off = new Image();
	menu6Off.src = path + "privpolicy.gif";
	menu6Hi = new Image();
	menu6Hi.src = path + "privpolicy2.gif";

	toolbar1Off = new Image();
	toolbar1Off.src = path + "about.gif";
	toolbar1Hi = new Image();
	toolbar1Hi.src = path + "about2.gif";

	toolbar2Off = new Image();
	toolbar2Off.src = path + "membership.gif";
	toolbar2Hi = new Image();
	toolbar2Hi.src = path + "membership2.gif";

	toolbar3Off = new Image();
	toolbar3Off.src = path + "products.gif";
	toolbar3Hi = new Image();
	toolbar3Hi.src = path + "products2.gif";

	toolbar4Off = new Image();
	toolbar4Off.src = path + "ci.gif";
	toolbar4Hi = new Image();
	toolbar4Hi.src = path + "ci2.gif";

	toolbar5Off = new Image();
	toolbar5Off.src = path + "cofi.gif";
	toolbar5Hi = new Image();
	toolbar5Hi.src = path + "cofi2.gif";


}

function switchOn(imgName) {
	if (document.images) {
		if (imgName != currentImage) {
			imgHi = eval(imgName + "Hi.src");
			document [imgName].src = imgHi;
		}
	}
}

function switchOff(imgName) {
	if (document.images) {
		if (imgName != currentImage) {
			imgOff = eval(imgName + "Off.src");
			document [imgName].src = imgOff;
		}
	}
}

//TOP NAVIGATION MENU CODE
//NN4 browser not supported

//Global vars
var menu, timer;
    
function OpenMenu(eImg, Id) {
	//Open menu by showing layer
	ClearDelay();
	CloseMenu();
	var eMenu = document.getElementById('divMenu' + Id);

	//Only show DIV if it exists
	if (eMenu) {
		var offset = -5; //compensates for div margins on menu
		//With XHTML DOM you have to specify units
		eMenu.style.left = (findPosX(eImg) + offset) + "px";
		eMenu.style.top = 83;
		eMenu.style.visibility = "visible";
		menu = Id;
	}
}

function CloseMenu() {
	//Close menu by hiding layer
	if (menu) {
		var eMenu = document.getElementById('divMenu' + menu);
		eMenu.style.visibility = "hidden";
		menu = null;
	}
}

function DelayClose() {
	//Delay menu close to move between elements
	timer = setTimeout('CloseMenu()', 100);
}

function ClearDelay() {
	//Dismiss predefined timer to close menu
	if (timer) {
		clearTimeout(timer);
		timer = null;
	}
}

function findPosX(obj) {
	//Absolute horizontal position of element
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft = obj.x;

	//With XHTML DOM we need body margin for IE
	if (document.compatMode == "CSS1Compat")
	  curleft += document.body.offsetLeft;

	return curleft;
}
