/*
	There's a line of code (currently in turnTabOn()) that stores which tab is currently selected.
	If anyone changes these functions around, please also make sure to keep my line of code alive.
	I've already had to fix it twice :-(
	Cheers (Adam 12/11/2001).
*/

/*
code below added by Rhys Williams 8/10/2004
This was formerly in activetab.cfm custom tag.
*/

		// check browsers
		var op = /opera 5|opera\/5/i.test(navigator.userAgent);
		var ie = !op && /msie/i.test(navigator.userAgent);	// preventing opera to be identified as ie
		var mz = !op && /mozilla\/5/i.test(navigator.userAgent);	// preventing opera to be identified as mz
		
		if (ie && document.getElementById == null) {	// ie4
			document.getElementById = function(sId) {
				return document.all[sId];
			};
		}
		 
		if (ie && window.attachEvent) {
			window.attachEvent("onload", function () {
				var scrollBorderColor	=	"#a7a7a7";
				var scrollFaceColor		=	"#a7a7a7";
				with (document.body.style) {
					scrollbarDarkShadowColor	=	"D6D3CE";
					scrollbar3dLightColor		=	"D6D3CE";
					scrollbarArrowColor			=	"black";
					scrollbarBaseColor			=	"D6D3CE";
					scrollbarFaceColor			=	"EDEAE5";
					scrollbarHighlightColor		=	"ffffff";
					scrollbarShadowColor		=	"000000";
					scrollbarTrackColor			=	"D6D3CE";
				}
			});
		}

/*
end of code added by Rhys Williams 8/10/2004
*/

// Grant added 27/12/2001 if statement for netscape but doesn't really know what hes doing and it doesn't work!
/*commented out by Rhys Williams 11/10/2004
if(navigator.appName.indexOf("Netscape") != -1){
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEOVER | Event.MOUSEUP | Event.MOUSEOUT );
	document.onmouseover = TabOver;
	document.onmouseout  = TabOut;
	document.onmousedown = TabDown;
	document.onmouseup   = TabUp;
}else{
	document.onmouseover = TabOver;
	document.onmouseout  = TabOut;
	document.onmousedown = TabDown;
	document.onmouseup   = TabUp;
}
*/


var eOld = null;
var tabLeftOn = '<img src="/shadomx/shado_central/images/tab_left_on.gif" width="13" height="20">'
var tabRightOn = '<img src="/shadomx/shado_central/images/tab_right_on.gif" width="13" height="20">'
var tabLeftOff = '<img src="/shadomx/shado_central/images/tab_left_off.gif" width="13" height="20">'
var tabRightOff = '<img src="/shadomx/shado_central/images/tab_right_off.gif" width="13" height="20">'

function TabOver() {
 var eSrc = window.event.srcElement;
  if (eSrc.className == "tab-button") {
    eSrc.className = "tab-button2";
  }
  if (eSrc.className == "tab-button4") {
    eSrc.className = "tab-button3";
  }
}
function TabOut() {
 var eSrc = window.event.srcElement;
  if (eSrc.className == "tab-button2") {
    eSrc.className = "tab-button";
  }
  if (eSrc.className == "tab-button3") {
    eSrc.className = "tab-button4";
  }
}
function TabDown() {
 var eSrc = window.event.srcElement;
  if (eSrc.className == "tab-button2") {
    eSrc.className = "tab-button3";
	var eTabLeft = eval(eSrc.id + "left")
	var eTabRight = eval(eSrc.id + "right")
	eTabLeft.innerHTML = tabLeftOn;
	eTabRight.innerHTML = tabRightOn;
  }
}

function TabUp() {
 var eSrc = window.event.srcElement;
  if (eSrc.className == "tab-button3") {
    if (eOld != null) {
		turnTabOff(eOld);
    }
    eOld = eSrc;
    turnTabOn(eOld);
  }
}


function setActiveTab(eSrc) {
  eOld = eSrc;
  eOld.className = "tab-button4"
  var eTxt = eval("txt" + eOld.id)
  eTxt.style.display = "";
}


function setTitle(page_name) {
	//top.frames[2].divheadercontent.innerText=page_name;
}

function turnTabOn(anObj) {
	anObj.className = "tab-button4";
	var eTabLeft = eval(anObj.id + "left")
	var eTabRight = eval(anObj.id + "right")
	eTabLeft.innerHTML = tabLeftOn;
	eTabRight.innerHTML = tabRightOn;
	var eTxt = eval("txt" + anObj.id)
	eTxt.style.display = "";
	/* Stores the current tab for both mainwindow and page frames.  Currently used in USERS section, but could be used elsewhere
		If this function is replaced by another, please MOVE the line below into the new function, cheers. (Adam 12/11/2001).
	*/
	switch(window.name){
		case "tree":
			top.frames[0].currentTabMain.title = anObj.id;
			top.frames[0].currentTabPage.title = "tab1"; 	// if they're changing main page, reset the tab
			// alert(top.frames[0].CurrentTabMain.title);	// debug
			break;
	
		case "page":
			top.frames[0].currentTabPage.title = anObj.id;  
			// alert(top.frames[0].CurrentTabPage.title);	// debug
			break;
	}

}

function turnTabOff(anObj) {
	anObj.className = "tab-button";
	var eTabLeft = eval(anObj.id + "left")
	var eTabRight = eval(anObj.id + "right")
	eTabLeft.innerHTML = tabLeftOff;
	eTabRight.innerHTML = tabRightOff;
	var eTxt = eval("txt" + anObj.id)
	eTxt.style.display = "none";
}

