//---------------BROWSER CHECK-----------------------------------------------
var agt=navigator.userAgent.toLowerCase();

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1));
var is_ie   = (agt.indexOf("msie") != -1); 

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ns4)
	return this
}
bw=new checkBrowser()


//---------------GLOBAL VARIABLES--------------------------------------------
var layerRef="null",layerStyleRef="null",styleSwitch="null";
var intervalID, intervalID2

if (is_nav){
	layerStyleRef="layer.";
	layerRef="document.layers";
	styleSwitch="";
}
else{
	layerStyleRef="layer.style.";
	layerRef="document.all";
	styleSwitch=".style";
}


//---------------UTILITY FUNCTIONS-------------------------------------------
// function to return width of object in px
function getObjWidth(obj){
	if(is_nav){
		return obj.clip.width
	}
	else{
		return obj.clientWidth
	}
}

// function to return height of object in px
function getObjHeight(obj){
	if(is_nav){
		return obj.clip.height
	}
	else{
		return obj.clientHeight
	}
}

// function to return the available browser width in px
function getInsideWindowWidth(){
	if(is_nav){
		return window.innerWidth
	}
	else{
		return document.body.clientWidth
	}
}

// function to return the available browser height in px
function getInsideWindowHeight(){
	if(is_nav){
		return window.innerHeight
	}
	else{
		return document.body.clientHeight
	}
}

// function to return the x coordinate of a positionable object
function getObjLeft(obj){
	var myElement = document.getElementById(obj);
	return myElement.style.left;
}

// function to return the y coordinate of a positionable object
function getObjTop(obj){
	var myElement = document.getElementById(obj);
	return myElement.style.top;
}

// function to set visibility to visible
function show(obj){
	var myElement = document.getElementById(obj);
	myElement.style.visibility = "visible"
}

// function to set visibility to hidden
function hide(obj){
	var myElement = document.getElementById(obj);
	myElement.style.visibility = "hidden"
}

// functions to hide and show layers
function showLayer(layerName){
	document.getElementById(layerName).style.visibility="visible";
}
function hideLayer(layerName){
	document.getElementById(layerName).style.visibility="hidden";
}

// function to position an element
function shiftTo(obj, x, y){
	if(is_nav){
		obj.moveTo(x,y)
	}
	else{
		obj.pixelLeft = x
		obj.pixelTop = y
	}
}

// function to move an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY){
	if(is_nav){
		obj.moveBy(deltaX, deltaY)
	}
	else{
		obj.pixelLeft += deltaX
		obj.pixelTop += deltaY
	}
}

// Create clipping functions
function clipValues(obj,which){
	if(is_nav){
		if (which=="t") return obj.clip.top
		if (which=="r") return obj.clip.right
		if (which=="b") return obj.clip.bottom
		if (which=="l") return obj.clip.left
	}
	else{
		var clipv = obj.clip.split("rect(")[1].split(")")[0].split("px")
		if (which=="t") return Number(clipv[0])
		if (which=="r") return Number(clipv[1])
		if (which=="b") return Number(clipv[2])
		if (which=="l") return Number(clipv[3])
	}
}

function clipTo(obj,t,r,b,l){
	if(is_nav){
		obj.clip.top = t
		obj.clip.right = r
		obj.clip.bottom = b
		obj.clip.left = l
	}
	else{
		obj.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
	}
}

function clipBy(obj,t,r,b,l){
	if(is_nav){
		obj.clip.top = clipValues(obj,'t') + t
		obj.clip.right = clipValues(obj,'r') + r
		obj.clip.bottom = clipValues(obj,'b') + b
		obj.clip.left = clipValues(obj,'l') + l
	}
	else{
		obj.clip = "rect("+(this.clipValues(obj,'t')+t)+"px "+(this.clipValues(obj,'r')+r)+"px "+Number(this.clipValues(obj,'b')+b)+"px "+Number(this.clipValues(obj,'l')+l)+"px)"
	}
}