//
// Zoo dHTML API
// 2001
//

var windowWidth;
var windowHeight;
var origWidth;
var origHeight;
var xcenter;
var ycenter;
var prefix;
var suffix;
var leftRef;
var topRef;
var is;


// object zoo_browserCheck();

// In order to use any of the functions in the Zoo dHTML API
// zoo_browserCheck must be called first.

// It prepares all of the variables used to differentiate
// between various browsers' implementations of dHTML

// It also creates the "is" object, which at this writing has
// one of three properties: ie, ns6, or ns4.

// Test for a browser thus: 
// if (is.ns4) do something for netscape 4;

// Call zoo_browserCheck like so:
// is = new zoo_browserCheck();


function zoo_browserCheck() {
	// this is the new stuff
	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.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.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.ns=this.ns4||this.ns6;
	this.is=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);        

	// this is from the old stuff
        this.ns61 = (this.b=="ns" && (navigator.userAgent.indexOf('6.1')>0))
	this.min = (this.v>=4);
	var plat = navigator.platform;
	if (plat == "Win32") this.win = true;
	if (plat == "MacPPC") this.mac = true;

	return this;
}

// FUNCTIONS BEGIN HERE

// zoo_setup()
// zoo_position()
// zoo_getX()
// zoo_setX()
// zoo_getY()
// zoo_setY()
// zoo_getZ()
// zoo_setZ()
// zoo_swapZ()
// zoo_show()
// zoo_hide()
// zoo_getWidth()
// zoo_getHeight()
// zoo_clip()
// zoo_changeImage()
// zoo_getImgX()

// void zoo_getDimensions();
function zoo_setup() {
	if (is.ns4) {
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.';
		suffix = '';
		leftRef = ".pageX";
		topRef = ".pageY";
	}
	if (is.ns6) {
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.getElementById("';
		suffix = '").style';
		leftRef = ".left";
		topRef = ".top";
	}
	if (is.ie) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
    		prefix = 'document.all.';
    		suffix = '.style';
		leftRef = ".pixelLeft";
		topRef = ".pixelTop";
	}
}

// void zoo_position(string id, int x, int y);
function zoo_position(id, x, y){
	zoo_setX(id, x);
	zoo_setY(id, y);
}

// int zoo_getX(string id);
function zoo_getX(id){
	eval("x = "+prefix+id+suffix+leftRef);
	return x;
}

// void zoo_setX(string id, int x);
function zoo_setX(id, x){
	eval (prefix+id+suffix+leftRef+" = "+x);
}

// int zoo_getY(string id);
function zoo_getY(id){
	eval("y = "+prefix+id+suffix+topRef);
	return y;
}

// void zoo_setY(string id, int y);
function zoo_setY(id, y){
	eval (prefix+id+suffix+topRef+" = "+y);
}

// int zoo_getZ(string id);
function zoo_getZ(id){
	eval ("zindex = "+prefix+id+suffix+".zIndex");
	return zindex;
}

// void zoo_setZ(string id, int zindex);
function zoo_setZ(id, zindex){
	eval (prefix+id+suffix+".zIndex = "+zindex);
}

// void zoo_swapZ(string id1, string id2);
function zoo_swapZ(id1, id2){
}

// void zoo_show(string id);
function zoo_show(id){
	eval(prefix+id+suffix+'.visibility = "visible"');
}

// void zoo_hide(string id);
function zoo_hide(id){
	eval(prefix+id+suffix+'.visibility = "hidden"');
}

// string getVisibility(string id)
function getVisibility(id){
	eval("visibility = "+prefix+id+suffix+".visibility");
	if (visibility == "zoo_show"){
		visibility = "visible";
	}
	if (visibility == "zoo_hide"){
		visibility = "hidden";
	}
	return visibility;
}

// int zoo_getWidth(string id);
function zoo_getWidth(id){
	if (is.ns4){
		width = document.layers[id].clip.width;
		}
	else if (is.ns6) { 
		width = document.getElementById(id).offsetWidth;
	} 
	else{
		eval ("width = "+id+".offsetWidth");
		}
	return width;
}

// int zoo_getHeight(string id);
function zoo_getHeight(id){
	if (is.ns4) {
		eval ("height = document.layers."+id+".clip.height");
	} 
	else if (is.ns6) { 
		height = document.getElementById(id).offsetHeight;
	} 
	else {
		eval ("height = "+id+".offsetHeight");
	}
	return height;
}

// void zoo_clip(string id, int top, int right, int bottom, int left);
function zoo_clip(id, top, right, bottom, left){
	if (is.ie || is.ns6) {
		eval(prefix+id+suffix+".clip = 'rect("+top+"px "+right+"px "+bottom+"px "+left+"px)'");
	} 
	else { // ns4
		eval (prefix+id+suffix+".clip.top = "+top);
		eval (prefix+id+suffix+".clip.bottom = "+bottom);
		eval (prefix+id+suffix+".clip.right = "+right);
		eval (prefix+id+suffix+".clip.left = "+left);
	}
}

// void zoo_changeImage(string id, string imgname, string imgobj);
function zoo_changeImage(id, imgname, imgobj){
	if (is.ns4){
		eval ("document.layers."+id+".document."+imgname+".src = "+imgobj+".src");
	}
	else{
		eval ("document."+imgname+".src = "+imgobj+".src");
	}
}

// int zoo_getImgX(string imgName)
// IE code from DHTML Lab http://www.webreference.com/dhtml/diner/realpos1/index.html
var nLeftPos;
var eParElement;
function getImgX(imgName,parentlayer) {

	if (is.ns4) {
		if (parentlayer==null) eval('imgX = document.'+imgName+'.x');        // X REL TO LAYER
		else eval('imgX = document.'+parentlayer+'.document.'+imgName+'.x');        // Y REL TO LAYER
	} else if (is.ns) {
		eval('imgX = document.'+imgName+'.offsetLeft');
		// identify first offset parent element
		eParElement = imgName+".offsetParent";

		// move up through parent element hierarchy
		// appending offsetLeft for each parent
		// until no more offset parents exist
		while (eval('document.'+eParElement) != null) {
			eval('imgX += document.'+eParElement+'.offsetLeft');
			eParElement = eParElement+".offsetParent";
		}
	} else {
		// initialize var to store calculations
		eval('imgX = document.all.'+imgName+'.offsetLeft');

		// identify first offset parent element
		eParElement = imgName+".offsetParent";

		// move up through parent element hierarchy
		// appending offsetLeft for each parent
		// until no more offset parents exist
		while (eval('document.all.'+eParElement) != null) {
			eval('imgX += document.all.'+eParElement+'.offsetLeft');
			eParElement = eParElement+".offsetParent";
		}
	}
	// return sum of element and parent offsets
	return imgX;
}

// getImgY
var nTopPos;
function getImgY(imgName,parentlayer) {
	if (is.ns4) {
		if (parentlayer==null) eval('imgY = document.'+imgName+'.y');
		else eval('imgY = document.'+parentlayer+'.document.'+imgName+'.y');        // Y REL TO LAYER
	} else if (is.ns) {
		eval('imgY = document.'+imgName+'.offsetTop');
		// identify first offset parent element
		eParElement = imgName+".offsetParent";

		// move up through parent element hierarchy
		// appending offsetTop for each parent
		// until no more offset parents exist
		while (eval('document.'+eParElement) != null) {
			eval('imgY += document.'+eParElement+'.offsetTop');
			eParElement = eParElement+".offsetParent";
		}
	} else {
		// initialize var to store calculations
		eval('imgY = document.all.'+imgName+'.offsetTop');

		// identify first offset parent element
		eParElement = imgName+".offsetParent";

		// move up through parent element hierarchy
		// appending offsetTop for each parent
		// until no more offset parents exist
		while (eval('document.all.'+eParElement) != null) {
			eval('imgY += document.all.'+eParElement+'.offsetTop');
			eParElement = eParElement+".offsetParent";
		}
	}
	// return sum of element and parent offsets
	return imgY;
}


function setImgHeight(imgname,parentlayer,num) {
	if (is.ns4) return;
	else eval('document.images["'+imgname+'"].height = '+num);
}

function rollover(link,parentlayer) {
	// do not use 'is.ns4' since this fcn might be used in absence of 'is' object
	if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4 && parentlayer) eval ('document.'+parentlayer+'.document.'+link+'.src = '+link+'on.src');
	else eval('document.'+link+'.src = '+link+'on.src');
}

function rollout(link,parentlayer) {
	// do not use 'is.ns4' since this fcn might be used in absence of 'is' object
	if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4 && parentlayer) eval ('document.'+parentlayer+'.document.'+link+'.src = '+link+'off.src');
	else eval('document.'+link+'.src = '+link+'off.src');
}

var timeoutID = 0;
var whoshows = '';

function show_menu(unavname) 
{
	if (unavname=='') return;
	if (whoshows == '') 
	{
		zoo_show('menu'+unavname);
		whoshows = unavname;
	} 
	else if (whoshows == unavname) 
	{
		clearTimeout(timeoutID);
	} 
	else 
	{
		hide_menu(whoshows);
		clearTimeout(timeoutID);
		zoo_show('menu'+unavname);
		whoshows = unavname;
	}
}

function hide_menu(unavname) 
{
	zoo_hide('menu'+unavname);
	rollout(unavname);
	whoshows = '';
	//if (current_page!='') { rollover(current_page); show_menu(current_page); }
}

var whoshows_pipeline = '';
var current_page_pipeline = '';
function show_menu_pipeline(unavname) {
	if (unavname=='') return;
	if (whoshows_pipeline == '') {
		zoo_show('menu'+unavname);
		whoshows_pipeline = unavname;
	} else if (whoshows_pipeline == unavname) {
		clearTimeout(timeoutID);
	} else {
		clearTimeout(timeoutID);
		hide_menu_pipeline(whoshows_pipeline);
		zoo_show('menu'+unavname);
		whoshows_pipeline = unavname;
	}
}
function hide_menu_pipeline(unavname) {
	zoo_hide('menu'+unavname);
	whoshows_pipeline = '';
}


