/*

This is a cross-browser layer library. There are some important

restrictions. Layers should not be nested into other layers.

Putting layers into a table is also not recommended.

Library programmed by Sabah Karaali (Last modified: 03-15-2002)



Following functions are included:



Browser-Function:



	checkBrowser()				Determines browser in use



Layer-Functions:



	getlayer(divname) 			Returns object of layer

	getlayerstyle(divname)		   "	style of layer

	getlayertop(divname)		   "	top position of layer

	getlayerleft(divname)		   "	left position of layer

	getlayerheight(divname)		   "	height of layer

	getlayerwidth(divname)		   "	width of layer

	

	setlayertop (divname,pos)	Sets 	Y position of layer

	setlayerleft (divname,pos)	   " 	X position of layer

	setpos (divname,posx,posy)	   "	X & Y position of layer

	

	setvisible (divname)		Sets	Layer visible

	setinvisible (divname)		Sets	Layer invisible

	

Other-Functions:



	getwindowheight ()			Returns height of browser window

	getwindowwidth ()			   "	width of browser window

	

*/



////////// BROWSER-FUNCTION: ///////////



	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.ie4mac=this.ie4 && navigator.userAgent.indexOf("Mac")>-1

		this.ns4mac=this.ns4 && navigator.appVersion.indexOf("Mac")>-1

		this.ie5mac=this.ie5 && navigator.userAgent.indexOf("Mac")>-1

		this.ie55=(this.ver.indexOf("MSIE 5.5")>-1 && this.dom)?1:0; 

		this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0; 



		this.bw=( this.dom ||  this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie5mac)

		return this;

	}

	bw = new checkBrowser();



////////// LAYER-FUNCTIONS: ///////////



	// Returns object of layer

	function getlayer(divname) {

		if(bw.dom) return document.getElementById(divname);

		if(bw.ie4) return document.all[divname];

		if(bw.ns4) return document[divname];

		return null;

	}



	// Returns style of layer

	function getlayerstyle(divname) {

		if(bw.dom || bw.ie4) {

			if (getlayer(divname)) {

				tmpObj = getlayer(divname);

				return tmpObj.style;

			}

		}

		if(bw.ns4) {

			if (getlayer(divname)) return getlayer(divname);

		}

		return null;

	}



	// Returns top position of layer

	function getlayertop(divname) {

		if(bw.dom) {

			if(bw.ns5) {

				if(getlayerstyle(divname)) {

					tmpObj = getlayerstyle(divname);

					return parseInt(tmpObj.top);

				}

			}

			else {

				if(getlayerstyle(divname)) {

				tmpObj = getlayerstyle(divname);

				return tmpObj.posTop;

				}

			}

		}

		if(bw.ie4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.posTop;

			}

		}

		if(bw.ns4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.top;

			}

		}

		return null;

	}

	

	// Returns left position of layer

	function getlayerleft(divname) {

		if(bw.dom) {

			if(bw.ns5) {

				if(getlayerstyle(divname)) {

				tmpObj = getlayerstyle(divname);

				return parseInt(tmpObj.left);

				}

			}

			else {

				if(getlayerstyle(divname)) {

				tmpObj = getlayerstyle(divname);

				return tmpObj.posLeft;

				}

			}

		}

		if(bw.ie4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.posLeft;

			}

		}

		if(bw.ns4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.left;

			}

		}

		return null;

	}

	

	// Returns height of layer

	function getlayerheight(divname) {

		if(bw.dom || bw.ie4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.offsetHeight;

			}

		}

		if(bw.ns4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname)

			return tmpObj.document.height;

			}

		}

		return null;

	}

	

	// Returns width of layer

	function getlayerwidth(divname) {

		if(bw.dom || bw.ie4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.offsetWidth;

			}

		}

		if(bw.ns4) {

			if(getlayer(divname)) {

			tmpObj = getlayer(divname);

			return tmpObj.document.width;

			}

		}

		return null;

	}



	// Sets Y position of layer

	function setlayertop (divname,pos) {

        obj = getlayer(divname);

		if(bw.dom && bw.ns5) obj.style.top = pos;

		if(bw.dom && !bw.ns5) obj.style.posTop = pos;

		if(bw.ie4) obj.posTop=pos;

		if(bw.ns4) obj.pageY=pos;

	}



	// Sets X position of layer

	function setlayerleft (divname,pos) {

	    obj = getlayer(divname);

		if(bw.dom && bw.ns5) obj.style.left = pos;

		if(bw.dom && !bw.ns5) obj.style.posLeft = pos;

		if(bw.ie4) obj.posLeft=pos;

		if(bw.ns4) obj.pageX=pos;

	}



	// Sets X,Y position of layer

	function setpos (divname, posx,posy) {

		setlayerleft (divname,posx);

		setlayertop (divname,posy);

	}



	// Sets Layer visible

	function setvisible (divname) {

		if(getlayerstyle(divname)) {

			tmpObj = getlayerstyle(divname);

			//tmpObj.visibility="visible";
			
			tmpObj.display = "block";

		}

	}

	

	// Sets Layer invisible

	function setinvisible (divname) {

		if(getlayerstyle(divname)) {

			tmpObj = getlayerstyle(divname);

			//tmpObj.visibility="hidden";
			tmpObj.display = "none";
			
		}

	}



////////// OTHER-FUNCTIONS: ///////////



	//Returns height of browser window

	function getwindowheight () {

		if(bw.dom) {

			 windowheight= document.body.offsetHeight;

			 if( bw.ns5) windowheight= window.innerHeight;

		}

		if(bw.ie4) windowheight= document.body.offsetHeight;

		if(bw.ns4) windowheight= window.innerHeight;

		return windowheight;

	}

		

	//Returns width of browser window

	function getwindowwidth () {

		if(bw.dom) {

			 windowwidth= document.body.offsetWidth;

			 if( bw.ns5) windowwidth= window.innerWidth;

		}

		if(bw.ie4) windowwidth= document.body.offsetWidth;

		if(bw.ns4) windowwidth= window.innerWidth;

		return windowwidth;

	}