//
// 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() {

	var b = navigator.appName;
	
	if (b == "Netscape"){
		this.b = "ns";
	}
	else if (b == "Microsoft Internet Explorer"){
		this.b = "ie";
	}
	else{
		this.b = b;
	}
	
	this.v = parseFloat(navigator.appVersion);
	
	// Netscape 4
	if ((this.b=="ns") && (this.v>=4) && (this.v<5)){
		this.ns4 = true;
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.';
		suffix = '';
		leftRef = ".pageX";
		topRef = ".pageY";
	}
	
	// Netscape 6
	else if ((this.b=="ns") && (this.v>=5)){
		this.ns6 = true;
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.getElementById("';
		suffix = '").style';
		leftRef = ".left";
		topRef = ".top";
	}
	
	// Explorer
	else {
		this.ie = true;
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
    	prefix = 'document.all.';
    	suffix = '.style';
		leftRef = ".pixelLeft";
		topRef = ".pixelTop";
	}
	
	this.min = (this.v>=4);
	
	var plat = navigator.platform;
	
	if (plat == "Win32")
		this.win = true;
	
	if (plat == "MacPPC")
		this.mac = true;
}

// FUNCTIONS BEGIN HERE

// 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()

// 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");
	}
}


// Special Rollover for images in DIVs
function turnOn(link,parentlayer) {
	if (is.ns4) eval('document.'+parentlayer+'.document.'+link+'.src = '+link+'on.src'); 
	if (is.ie || is.ns6) eval('document.'+link+'.src = '+link+'on.src'); 
}

// Special Rollout for images in DIVs
function turnOff(link,parentlayer) {
	if (is.ns4) eval('document.'+parentlayer+'.document.'+link+'.src = '+link+'off.src');
	if (is.ie || is.ns6) eval('document.'+link+'.src = '+link+'off.src');
}

function show_menu(unavname) {
	if (whoshows == '') { 
		zoo_show('menu'+unavname);
		whoshows = unavname;
	} else if (whoshows == unavname) {
		clearTimeout(timeoutID);
	} else {
		clearTimeout(timeoutID);
		hide_menu(whoshows);
		zoo_show('menu'+unavname);
		whoshows = unavname;
	}
}

function hide_menu(unavname) {
	zoo_hide('menu'+unavname);
	rollout(unavname);
	whoshows = '';
}

function show_menu_pipeline(unavname) {
	if (whoshows == '') { 
		zoo_show('menu'+unavname);
		whoshows = unavname;
	} else if (whoshows == unavname) {
		clearTimeout(timeoutID);
	} else {
		hide_menu_pipeline(whoshows);
		zoo_show('menu'+unavname);
		whoshows = unavname;
	}
}

function hide_menu_pipeline(unavname) {
	zoo_hide('menu'+unavname);
	whoshows = '';
}

function getImgX(imgName) {
	imgX = 0;
		if (is.ie) {	// IE 
                eval('containerLeft = document.all.'+imgName+'.offsetParent.offsetLeft');
                eval('imgX = document.all.'+imgName+'.offsetLeft');
                imgX += containerLeft;
				imgX += (windowWidth - 678)/2;
		}
        else if (is.ns4) eval('imgX = document.'+imgName+'.x'); // for ns 4
		else if (is.ns) {  // if it's a version of netscape greater than 4
                eval('imgX = document.'+imgName+'.offsetLeft');
        } 
        else  {	
			eval('imgX = document.'+imgName+'.offsetLeft');
        }
	//	alert ('img x = '+imgX);
        return imgX;
} // ends getImgX()

var eParElement;
var nTopPos;
//function getImgXnew(imgName,parentlayer) {
function getImgXnew(imgName) {
	if (is.ns4) {
		eval('imgX = document.'+imgName+'.x'); 
	} else if (is.ns6) {
		eval('imgX = document.'+imgName+'.offsetLeft');
		// 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('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 offsetTop 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;
}

function getImgY(imgName) {
        if (is.ie)  {
                //eval('containerTop = document.all.'+imgName+'.offsetParent.offsetTop');
                eval('imgY = document.all.'+imgName+'.offsetTop');
               // imgY += containerTop;
				//imgY += (windowWidth - 678)/2;
        }
        else if (is.ns4) eval('imgY = document.'+imgName+'.y'); 
        else if (is.ns) {  // if it's a version of netscape greater than 4
                eval('imgY = document.'+imgName+'.offsetTop');
        } else {
                eval('imgY = document.'+imgName+'.offsetTop');
        }
        return imgY;
} // ends getImgX()
