var windowWidth;
var windowHeight;
var origWidth;
var origHeight;
var xcenter;
var ycenter;
var prefix;
var suffix;
var leftRef;
var topRef;
var is;


// object browserCheck();


function 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

// setup()
// position()
// getX()
// setX()
// getY()
// setY()
// getZ()
// setZ()
// swapZ()
// show()
// hide()
// getWidth()
// getHeight()
// clip()
// changeImage()
// getImgX()

// void getDimensions();

function setup() {
	if (is.ns4) {
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.';
		suffix = '';
		leftRef = ".pageX";
		topRef = ".pageY";
	} else if (is.ns6) {
		windowWidth=window.innerWidth;
		windowHeight=window.innerHeight;
		prefix = 'document.getElementById("';
		suffix = '").style';
		leftRef = ".left";
		topRef = ".top";
	} else if (is.ie4) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
    	prefix = 'document.all.';
    	suffix = '.style';
		leftRef = ".pixelLeft";
		topRef = ".pixelTop";
	} else {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
		prefix = 'document.getElementById("';
    	suffix = '").style';
		leftRef = ".left";
		topRef = ".top";
	}
}

// void position(string id, int x, int y);
function position(id, x, y){
	setX(id, x);
	setY(id, y);
}

// int getX(string id);
function getX(id){
	eval("x = "+prefix+id+suffix+leftRef);
	return parseInt(x);
}

// void setX(string id, int x);
function setX(id, x){
	eval (prefix+id+suffix+leftRef+" = "+x);
}

// int getY(string id);
function getY(id){
	eval("y = "+prefix+id+suffix+topRef);
	return parseInt(y);
}

// void setY(string id, int y);
function setY(id, y){
	//alert(id + " " + y);
	eval (prefix+id+suffix+topRef+" = "+y);
}

// int getZ(string id);
function getZ(id){
	eval ("zindex = "+prefix+id+suffix+".zIndex");
	return zindex;
}

// void setZ(string id, int zindex);
function setZ(id, zindex){
	eval (prefix+id+suffix+".zIndex = "+zindex);
}

// void swapZ(string id1, string id2);
function swapZ(id1, id2){
}

// void show(string id);
function show(id){
	eval(prefix+id+suffix+'.visibility = "visible"');
}

// void hide(string id);
function hide(id){
	eval(prefix+id+suffix+'.visibility = "hidden"');
}

// string getVisibility(string id)
function getVisibility(id){
	eval("visibility = "+prefix+id+suffix+".visibility");
	if (visibility == "show"){
		visibility = "visible";
	}
	if (visibility == "hide"){
		visibility = "hidden";
	}
	return visibility;
}

// int getWidth(string id);
function getWidth(id){
	if (is.ns4){
		width = document.layers[id].clip.width;
		}
	else if (is.ns6 || is.ie6) { 
		width = document.getElementById(id).offsetWidth;
	} 
	else{
		width = document.all[id].offsetWidth;
		}
	return width;
}

// int getHeight(string id);
function 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;
}

function setHeight(id, height) {
	eval(prefix+id+suffix+'.height = '+height);
}

function setWidth(id, width) {
	eval(prefix+id+suffix+'.width = '+width);
}

// void clip(string id, int top, int right, int bottom, int left);
function 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 changeImage(string id, string imgname, string imgobj);
function changeImage(id, imgname, imgobj){
	if (is.ns4){
		eval ("document.layers."+id+".document."+imgname+".src = "+imgobj+".src");
	} else if (is.ie6) {
		eval ("document.getElementById('"+imgname+"').src = "+imgobj+".src");
	} else if (is.ie) {
		eval ("document.all."+imgname+".src = "+imgobj+".src");
	} else {
		eval ("document."+imgname+".src = "+imgobj+".src");
	}
}


function setImgHeight(imgname,parentlayer,num) {
	if (is.ns4) return;
	else eval('document.images["'+imgname+'"].height = '+num);
}

