

// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     a >> lib api
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o





// New library object for dynamic layers 
//Global document object
d = window.document
loaded = false;

// repeated below
//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;
	this.showIt = lib_showIt;
	this.hideIt = lib_hideIt;
	return this;
}


function lib_moveIt(x,y){
	if (x){this.x=x; this.css.left = x;}
	if (y){this.y=y; this.css.top = y;}
}

function lib_showIt(){this.css.visibility = "visible"}
function lib_hideIt(){this.css.visibility = "hidden"}

// 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();
	}
}


// X Position Layer relative to anchor image
function get_xPos(object,offset){
	if(d.layers && !d.dom){
		xPos = d.images[object].x
	} else {
		xPos = d.images[object].offsetLeft;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) xPos = xPos + offset;
	return xPos;
}


// Y Position Layer relative to anchor image 
function get_yPos(object,offset){
	if(d.layers && !d.dom){
		yPos = d.images[object].y
	} else {
		yPos = d.images[object].offsetTop;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) yPos = yPos + offset;
	return yPos
}






// logo placement


function place_logo(){
	oDiv = new Array();
	oDiv[0] = new lib_obj('logoa');
	oDiv[1] = new lib_obj('logob');
	oDiv[2] = new lib_obj('logoc');
	oDiv[3] = new lib_obj('logod');
	oDiv[4] = new lib_obj('logoe');
	oDiv[5] = new lib_obj('logof');
	oDiv[6] = new lib_obj('logog');
	oDiv[7] = new lib_obj('logoh');
	oDiv[8] = new lib_obj('logoi');
	for(n=0; n<oDiv.length; n++){
		oDiv[n].moveIt(get_xPos("lnk0",-3),false);
		oDiv[n].showIt();
	}
}

function place_logo_oyo(){
	oDiv = new Array();
	oDiv[0] = new lib_obj('logoaOYO');
	oDiv[1] = new lib_obj('logobOYO');
	oDiv[2] = new lib_obj('logocOYO');
	for(n=0; n<oDiv.length; n++){
		oDiv[n].moveIt(get_xPos("lnk0",-3),false);
		oDiv[n].showIt();
	}
}

function place_whoa(){
	wDiv = new Array();
	wDiv[0] = new lib_obj('whoa');
	for(n=0; n<wDiv.length; n++){
		wDiv[n].moveIt(get_xPos("lnk0",475),get_yPos("lnk0",275));
		wDiv[n].showIt();
	}
}

function m_rollover(which){
	document.images[which].src = mro_ar[which]['on'].src;
}

function m_rollout(which){
	document.images[which].src = mro_ar[which]['off'].src;
}



// menu functions 

function changeActive(which){
	if (loaded){
		clearTimeout(timer);
		mDiv[active].hideIt();
		m_rollout(active);
		active=which;
		mDiv[active].showIt();
		m_rollover(active);
	}
}

function killIt(){
	if (loaded){
		mDiv[active].hideIt();
		m_rollout(active);
	}
}

function killMenu(){
	if (loaded){
		timer = setTimeout("killIt()",delay);
	}
}

function sleep(){
	clearTimeout(timer);
}

function checkEnter(e){ //e is event object passed from function invocation
var characterCode;  //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		//e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
		//e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	//alert("characterCode = "+characterCode);
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
 		return false;
	}
	else{
		return true;
	}

}

//
// Pop-up windows
//

function popUpNav(newURL,sizeW,sizeH,tools,scroll) { 
	var features = 
		'"width=' + sizeW +
        ',height=' + sizeH +
        ',menubar=no' +    
		',toolbar=' + tools +
        ',scrollbars=' + scroll +
        ',resizable=yes' +
       	',screenX=60,screenY=60,top=60,left=60"';
	eval('newWin = window.open("'+newURL+'","popUp",' +features+')');
	newWin.focus();
}


//
// Pop-up windows
//

function HelpPop(pgAnch) { 
	var features = 
		'"width=400' +
		',height=300' +
		',menubar=no' +    
		',toolbar=no' +
        ',scrollbars=yes' +
        ',resizable=yes' +
       	',screenX=60,screenY=60,top=60,left=60"';
	var newURL='/help.htm?pgAnch=' + pgAnch
	eval('HelpWin = window.open("'+newURL+'","HelpPop",' +features+')');
	HelpWin.focus();
}

function print_window(url,winWidth,winHeight) {
	var toolBarParms = "toolbar=0,directories=0,status=0,menubar=0,scrollbars=1";
	toolBarParms = toolBarParms + "resizable=yes,width=" + winWidth + ",height=" + winHeight;
	newWin = window.open(url,"Print",toolBarParms);
	newWin.focus();
	newWin.print();

}
function new_window(url,winWidth,winHeight) {
	var toolBarParms = "toolbar=0,directories=0,status=0,menubar=0,scrollbars=0";
	toolBarParms = toolBarParms + "resizable=1,width=" + winWidth + ",height=" + winHeight;
	newWin = window.open(url,"Excel",toolBarParms);
	newWin.focus();
}

function doc_window(url,winWidth,winHeight) {
	var toolBarParms = "toolbar=1,directories=0,status=0,menubar=0,scrollbars=0";
	toolBarParms = toolBarParms + "resizable=0,width=" + winWidth + ",height=" + winHeight;
	newWin = window.open(url,"Excel",toolBarParms);
	newWin.focus();
}

function popUpNav2(newURL,sizeW,sizeH,tools,scroll,posX,posY) { 
	var features = 
		'"width=' + sizeW +
        ',height=' + sizeH +
        ',menubar=no' +    
		',toolbar=' + tools +
        ',scrollbars=' + scroll +
        ',resizable=yes' +
       	',screenX=' + posX + ',screenY=' + posY + ',top=' + posY + ',left=' + posX + '"';
	eval('window.open("'+newURL+'","popUp",' +features+')');
}	
