// New library object for dynamic layers 
//Global document object
d = window.document
active = 0;
delay=2500;
timer = null;
init_done = false;	 // Added 10/11/01 cd

//Preload rollover images
function Linkload(img) {
	this.off=new Image();this.off.src="/SBImages/lk_"+img+".gif";
	this.on=new Image();this.on.src="/SBImages/lk_"+img+"-a.gif";
}

lnkArr = new Array();
lnkArr[0]= new Linkload("bob");
lnkArr[1]= new Linkload("bp");
lnkArr[2]= new Linkload("cc");
lnkArr[3]= new Linkload("b");
lnkArr[4]= new Linkload("as");
lnkArr[5]= new Linkload("pr");
lnkArr[6]= new Linkload("cu");


if(d.layers){
	origWidth=innerWidth;
	origHeight=innerHeight;
}
// Browser detection object
function lib_bwCheck(){
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom = document.getElementById?1:0
	this.opera5 = this.agent.indexOf("Opera 5")>-1
	this.ie5 = (this.agent.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0
	this.ie6 = (this.agent.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0
	this.ie = this.ie4||this.ie5||this.ie6
	this.mac = this.agent.indexOf("Mac")>-1
	this.ns6 = (this.dom && parseInt(this.ver)>=5)?1:0
	this.ns4 = (document.layers && !this.dom)?1:0
	this.bw = (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
	return this
}
bw = new lib_bwCheck() // Browser object

function lib_obj(obj){
	this.el = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval('document.' + obj):0
	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0
	this.moveIt = lib_moveIt
	return this
}

function lib_moveIt(x,y){
	this.x=x;this.y=y;this.css.left = x;this.css.top = y;
}

lib_obj.prototype.hideIt = function(){this.css.visibility = "hidden"}
lib_obj.prototype.showIt = function(){this.css.visibility = "visible"}

function changeActive(num){
		if (!init_done)	  // Added 10/11/01 cd
			init();		  // cd
		clearTimeout(timer);
		oDiv[active].hideIt()
        active=num
	    oDiv[active].showIt()
		for (n=0; n<lnkArr.length; n++) {
			document.images["lnk"+n].src=lnkArr[n].off.src;
		}
		document.images["lnk"+num].src=lnkArr[num].on.src;
}

function killIt(){
	oDiv[active].hideIt()
	for (n=0; n<lnkArr.length; n++) {
		document.images["lnk"+n].src=lnkArr[n].off.src;
	}
}

function killMenu(){
	timer = setTimeout("killIt()",delay)
}

function sleep(){
	clearTimeout(timer);
}

// DHTML fix detection for Netscape browser resize
if (d.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=DHTMLfix;
}
		
// DHTML fix for Netscape browser resize
function DHTMLfix() {
	if (origWidth != innerWidth || origHeight != innerHeight) {
		location.reload();
	}
}

function fixNav(){
	if(d.all)history.go(0)
	if (d.layers) {
		DHTMLfix();
	}
}
/*
function get_xPos(){
	if(d.layers && !d.dom){
		xPos = d.layers['aObj'].pageX
	} else {
		xPos = d.all['aObj'].offsetLeft;
		tempEl = d.all['aObj'].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	return xPos
}
*/
function get_xPos(n){
	if(d.layers && !d.dom){
		xPos = d.images["lnk"+n].x
	} else {
		xPos = d.images["lnk"+n].offsetLeft;
		tempEl = d.images["lnk"+n].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	xPos = xPos+95
	return xPos
}


function get_yPos(n){
	if(d.layers && !d.dom){
		yPos = d.images["lnk"+n].y
	} else {
		yPos = d.images["lnk"+n].offsetTop;
		tempEl = d.images["lnk"+n].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	return yPos
}

function init(){
	if(!init_done) {	// Added 10/11/01 cd
		bw = new lib_bwCheck() // Browser object
		oDiv = new Array()
		oDiv[0] = new lib_obj('sub0')
		oDiv[1] = new lib_obj('sub1')
		oDiv[2] = new lib_obj('sub2')
		oDiv[3] = new lib_obj('sub3')
		oDiv[4] = new lib_obj('sub4')
		oDiv[5] = new lib_obj('sub5')
		oDiv[6] = new lib_obj('sub6')
		
		for(n=0; n<oDiv.length; n++){
			oDiv[n].moveIt(get_xPos(n),get_yPos(n))
		}
		init_done = true;	// Added 10/11/01 cd
	}
}

