var lastButton = null;
var lastButtonClass = null;
var PrevButton;
var PrevButtonID = "";
var isMac = false;
var ua = navigator.userAgent;

if ((ua.indexOf("Mac") != -1) || (ua.indexOf("Windows 3") != -1)) isMac = true;  

function Hilight(btn) {
	cancelBubble;
	if (btn.tagName != "DIV") return;
	if(window.event.fromElement.tagName == "A") return;
	DoButton(btn,"ldHover");
	if(PrevButtonID != "") {
		if(PrevButtonID != btn.id) {
			DoButton(PrevButton, "ldNormal");
		}
	}
	PrevButton = btn;
	PrevButtonID = btn.id;
}
function UnHilight(btn) {
	cancelBubble;
	if (btn.tagName != "DIV") return;	
	if(window.event.toElement.tagName == "A") return;
	DoButton(btn,"ldNormal");
}

function DoButton(TheObj,TheClass) {
	TheObj.className = TheClass;
    TheObj.children[0].className = TheClass;
}
 
function setBackLast(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lmLink";
	lastButton = null;
}

function setBackLast1(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm1Link";
	lastButton = null;
}

function setBackLast1a(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm1aLink";
	lastButton = null;
}

function setBackLast2(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm2Link";
	lastButton = null;
}

function setBackLast3(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm3Link";
	lastButton = null;
}

function setBackLast3a(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm3aLink";
	lastButton = null;
}

function setBackLast3b(){

	lastButton.className = lastButtonClass;
	lastButton.children[0].className = "lm3bLink";
	lastButton = null;
}

function setBackLastTopMenu(){
	lastButton.className = "tmNormal";
	lastButton.children[0].className = "tmLink";
	lastButton = null;
}

function callSetBackLast(){
	if(lastButton != null && !ButtonTable.contains(window.event.toElement)){
		setBackLast();
	}
}

function callSetBackLast2(){
	if(lastButton != null && !ButtonTable2.contains(window.event.toElement)){
		setBackLast2();
	}
}

function callSetBackLast1(){
	if(lastButton != null && !ButtonTable1a.contains(window.event.toElement)){
		setBackLast1();
	}
}

function callSetBackLast1a(){
	if(lastButton != null && !ButtonTable1a.contains(window.event.toElement)){
		setBackLast1a();
	}
}

function callSetBackLast3(){
	if(lastButton != null && !ButtonTable3.contains(window.event.toElement)){
		setBackLast3();
	}
}

function callSetBackLast3a(){
	if(lastButton != null && !ButtonTable3.contains(window.event.toElement)){
		setBackLast3a();
	}
}

function callSetBackLast3b(){
	if(lastButton != null && !ButtonTable3.contains(window.event.toElement)){
		setBackLast3b();
	}
}

function callSetBackLastTopMenu(){
	if(lastButton != null && !topButtonTable.contains(window.event.toElement)){
		setBackLastTopMenu();
	}
}

function Menu_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lmMouseover";
		bold = A.style.fontWeight;
		A.className = "lmLinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu1_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast1();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm1Mouseover";
		bold = A.style.fontWeight;
		A.className = "lm1LinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu1a_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast1a();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm1aMouseover";
		bold = A.style.fontWeight;
		A.className = "lm1aLinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu2_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast2();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm2Mouseover";
		bold = A.style.fontWeight;
		A.className = "lm2LinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu3_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast3();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm3Mouseover";
		bold = A.style.fontWeight;
		A.className = "lm3LinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu3a_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast3a();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm3aMouseover";
		bold = A.style.fontWeight;
		A.className = "lm3aLinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}

function Menu3b_mo(elem){
	if (document.readyState != "complete" || isMac) return;
	var child, bold, div, A;
	if(lastButton != null){
		setBackLast3b();
	}
	if (elem.children.length == 0) return;
	div = elem.children[0];
	if (div.className == "tmChosen" || elem.children.length == 0) {
		cancelBubble;
		return;
	}
	A = elem.children[0].children[0];
	lastButton = elem.children[0];
	lastButtonClass = elem.children[0].className;
	if(LeftMenutable.contains(elem)){
		div.className = "lm3bMouseover";
		bold = A.style.fontWeight;
		A.className = "lm3bLinkMo";
		A.style.fontWeight = bold;
	}else{
		div.className = "tmMouseover";
		A.className = "tmLinkMo";
	}
	cancelBubble;
}


function cancelBubble(){
	window.event.cancelBubble = true;
}
//needed for legacy
function mouseoverlink(link) {
}
function mouseoutlink(link) {
}

////////////////////////////////
var oLastBtn=0;

function RaiseButton(){
	
	window.event.cancelBubble=true;
	oBtn = window.event.srcElement;
	if(oLastBtn && oLastBtn != oBtn){
		HideButton();
	}
	if(oBtn.buttonType){
		oBtn.className = oBtn.buttonType + "Up";
		oLastBtn=oBtn;
	}
	else
		oLastBtn = 0;
	
	
}


function DepressButton(){
	window.event.cancelBubble=true;
	oBtn = window.event.srcElement;
	if(oBtn.buttonType){
		oBtn.className = oBtn.buttonType + "Down"; 
	}
}


function HideButton(){
	oLastBtn.className = oLastBtn.buttonType + "Off";
}

function MakeBGBlue(oRegion) {
	oRegion.style.backgroundColor="#99CCFF";	
	oRegion.style.cursor="hand";		
}

function MakeBGWhite(oRegion) {
	var oToEl = window.event.toElement;
	if ((oToEl && !oRegion.contains(oToEl))||!oToEl) {
	oRegion.style.backgroundColor="#FFFFFF";	
	}		
}

function ToolbarRed() {
	oSrcEl = window.event.srcElement;
	if (oSrcEl.tagName == "IMG") {
		oSrcEl.src = oSrcEl.src.substring(0,(oSrcEl.src.indexOf(".gif"))) + "-red.gif";
		window.event.cancelBubble = true;
	}
}
function ToolbarWhite() {
	oSrcEl = window.event.srcElement
	if (oSrcEl.tagName == "IMG") {
		oSrcEl.src = oSrcEl.src.substring(0,(oSrcEl.src.indexOf("-red.gif"))) + ".gif";
		window.event.cancelBubble = true;
	}
}

//*****************************************	 
//Global caps function.  Use g_bc in all pages
//to access the browser info
//*****************************************	 
function globalCaps(){
	var A=navigator.userAgent, t=true, p="", v="";
	p=A.indexOf("MSIE");
	if (p!=-1){
    	this.ie=true;
		v=A.charAt(p+5);
		(v=="2")?this.ie2=true:this.ie2=false;
		(v=="3")?this.ie3=true:this.ie3=false;
		(v=="4")?this.ie4=true:this.ie4=false;
		(v=="5")?this.ie5=true:this.ie5=false;
	} else {
		this.ie=false;
		this.ie2=false;
		this.ie3=false;
		this.ie4=false;
		this.ie5=false;	
	}
	(this.ie4||this.ie5)?this.IE4RelOrNewer=true:this.IE4RelOrNewer=false;
	(A.indexOf("Mozilla") != -1 && A.indexOf("compatible")==-1)?this.nav=true:this.nav=false;
	(A.indexOf("Windows 95")>0||A.indexOf("Win95")!=-1||A.indexOf("Win98")!=-1||A.indexOf("Windows 98")!=-1||A.indexOf("Windows NT")!=-1)?this.win32=true:this.win32=false;
	(A.indexOf("Windows 3.1")!=-1||A.indexOf("Win16")!=-1)?this.win16=true:this.win16=false;
	(A.indexOf("Mac")!=-1)?this.anymac=true:this.anymac=false;
	(A.indexOf("SunOS")!=-1||A.indexOf("HP-UX")!=-1||A.indexOf("X11")!=-1)?this.unix=true:this.unix=false;
	(A.indexOf("Windows CE")!=-1)?this.wince=true:this.wince=false;
}

//*****************************************
//Global browser info object
//*****************************************
var gbc=new globalCaps();





