function Toggle(ImageName) {
	if (document.images[ImageName]) {
		if(document.images[ImageName].src.indexOf("_i.gif") > -1) {
			var NewImage = document.images[ImageName].src.substring(document.images[ImageName].src.indexOf("images/") + 7,document.images[ImageName].src.indexOf("_i.gif")) + "_a.gif";
			document.images[ImageName].src = "images/" + NewImage;
		}
		else if (document.images[ImageName].src.indexOf("_a.gif") > -1) {
			var NewImage = document.images[ImageName].src.substring(document.images[ImageName].src.indexOf("images/") + 7,document.images[ImageName].src.indexOf("_a.gif")) + "_i.gif";
			document.images[ImageName].src = "images/" + NewImage;
		}
	}
}

var LastHdr = "";
var DefHdr;
var DefaultMenu;
var Delay = 500;
var hide_timer;

function HdrOver(HdrName) {
	// Stop the clock!
	clearTimeout(hide_timer);
	
	// If it's the default header - make sure it's turned on
	if (HdrName == DefHdr && DefHdr != "") {
		ResetMenu(DefaultMenu);
	}
	
	// If we're going back over a header that is already open - do nothing
	else if (HdrName == LastHdr) {
		return;
	}
	
	// If there is no default header but it's passed our other tests
	else if (DefHdr == "") {
	// turn on the new one
		ShowRow2(HdrName + "_2");
		Toggle(HdrName);
		LastHdr=HdrName;
	}
	
	// So it must be a new header that isn't the default
	else {
	// hide the default
		LastHdr = DefHdr;
		HdrOut();
	// turn on the new one
		ShowRow2(HdrName + "_2");
		Toggle(HdrName);
		LastHdr=HdrName;
	}
}

function HdrOut() {
	
	// Stop the clock!
	clearTimeout(hide_timer);
	
	if(LastHdr != "" && document.images[LastHdr]) {
	
		if (document.images[LastHdr].src.indexOf("_a.gif") > -1) {
			Toggle(LastHdr);
		}
		HideRow2(LastHdr + "_2");
	}
	
	// If we're turning off another header to show the default
	if (LastHdr != DefHdr) {
		LastHdr = "";
		hide_timer = setTimeout('ResetMenu(DefaultMenu)',800);
	}
}

NN4 = (document.layers) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;
WWWCOK = (document.getElementById)?true:false;

function setVar(theObject) {
	if (WWWCOK) {
		theName = document.getElementById(theObject).style;
	}
	else if (IE4) {
		theName = document.all(theObject).style;
	}
	else if (NN4) {
		theName = document.layers[theObject];
	}
	return theName;
}

function ShowRow2(DivName) {
	ThisDiv=setVar(DivName);
	ThisDiv.visibility = "visible";

}

function HideRow2(DivName) {
	ThisDiv=setVar(DivName);
	ThisDiv.visibility = "hidden";
}

function ResetMenu(MenuName) {
	if (MenuName) {
		DefHdr="hdr_" + MenuName.substring(0,MenuName.indexOf('_'));
		ShowRow2(DefHdr + "_2");
		// We only want to swap the header if it's turned off
		if (document.images[DefHdr].src.indexOf("_i.gif") > -1) {
			Toggle(DefHdr);
		}
		// only try to change the submenu if necessary - so we'll check the placement of the first _
		if (eval(MenuName.indexOf("_")+1) != MenuName.length) {
			// document.images["sm_" + MenuName].src = "images/sm_" + MenuName + "_s.gif";
			var SelectedMenu = setVar("sm_" + MenuName);
			SelectedMenu.color = "#000000";
			SelectedMenu.fontWeight = "bold";
		}
	}
	else {
		DefHdr = "";
	}
}


// Preload Rollover Images
function PreloadImages() {
	for (var i=0; i<document.images.length; i++) {
		if(document.images[i].src.indexOf("_i.gif") > -1) {
			var RolloverName = document.images[i].src.substring(document.images[i].src.indexOf("images/") + 7,document.images[i].src.indexOf("_i.gif")) + "_a.gif";
			var ThisImage = new Image;
			ThisImage.src = "images/" + RolloverName;
		}
	}
}