//========================================================================================================================
// Common
//========================================================================================================================

	document.onerror = function() {	return };

	var mouseEventDisabled = true;
	
	var range1;
	var range2;
	var styleObj;
	var isNS;

//========================================================================================================================
// Browser validation (NS6 - NS4 - IE4 - IE5)
//========================================================================================================================

	if(navigator.appName.indexOf("Netscape")!= -1){
		if(navigator.userAgent.indexOf("Netscape6")!= -1){
			// Netscape version 6
			range1 	 = "getElementById('";
			range2 	 = "')";
			styleObj = ".style";
			isNS 	 = false;
		}
		else {
			// Netscape - INTE version 6
			range1 	 = "layers.";
			range2 	 = "";
			styleObj = "";
			isNS = true;
		}
	}
	else {
		// INTE Netscape - Förhoppningsvis Internet Explorer >4 ;-)
		range1 	 = "all.";
		range2 	 = "";
		styleObj = ".style";
		isNS 	 = false;
	}
	
//========================================================================================================================
// Layer functions
//========================================================================================================================

	// getObj('lager1,lager2',true) <--- Detta blir ett och samma objekt i alla browsers

	function getLayerObj(divs,haveStyle) {
		var tmpObj = "";
		var arrObj = divs.split(",");
		if ((isNS) && arrObj.length > 1) {
			for (var i=0; i < arrObj.length-1; i++) {
				tmpObj += "document."+ range1 + arrObj[i] +".";
			}
		}
		var mainTarget = arrObj[arrObj.length-1];
		delete arrObj;
	
		if (typeof divs == "string") {
			if ((haveStyle) &! (isNS)) {
				tmpObj = eval("document." + range1 + mainTarget + range2 + styleObj)
			}
			else {
				tmpObj = eval(tmpObj +"document." + range1 + mainTarget + range2);
			}
		}
		else {
			tmpObj = obj;
		}
		
		return tmpObj;
	}

	function clipLayer(obj,t,r,b,l) {
		if (t==null) t = obj.clipValues('t')
		if (r==null) r = obj.clipValues('r')
		if (b==null) b = obj.clipValues('b')
		if (l==null) l = obj.clipValues('l')
		if (isNS) {
			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 writeLayer(obj,content) {
		if (isNS) {
			obj.document.open();
			obj.document.write(""+ content);
			obj.document.close();
		}
		else {
			obj.innerHTML = ""+ content;
		}
	}

	function moveLayer(obj,top,left) {
		obj.top  = top;
		obj.left = left;
	}

	function getLayerWidth(obj) {
		var tmpObj = (isNS) ? obj.document.width : obj.offsetWidth;
		//alert("width: "+ tmpObj)
		return parseInt(tmpObj);
	}

	function getLayerHeight(obj) {
		var tmpObj = (isNS) ? obj.document.height : obj.offsetHeight;
		//alert("height: "+ tmpObj)
		return parseInt(tmpObj);
	}

	function setLayerProperties(obj,width,height,left,top,vis) {
		obj.width	= objWidth;
		obj.height 	= objHeight;
		obj.left 	= objLeft;
		obj.top 	= objTop;
		obj.visibility = vis;
	}

//========================================================================================================================
// Mouse Event
//========================================================================================================================
	
	if (!mouseEventDisabled) {
		document.onmousedown = mouseDown
		document.onmousemove = mouseMove
		document.onmouseup = mouseUp
		if (isNS) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
	
		function mouseDown(e) {
			var x = (isNS)? e.pageX : event.x+document.body.scrollLeft
			var y = (isNS)? e.pageY : event.y+document.body.scrollTop
		}
		function mouseMove(e) {
			var x = (isNS)? e.pageX : event.x+document.body.scrollLeft
			var y = (isNS)? e.pageY : event.y+document.body.scrollTop
		}
		function mouseUp(e) {
			var x = (isNS)? e.pageX : event.x+document.body.scrollLeft
			var y = (isNS)? e.pageY : event.y+document.body.scrollTop
		}
	}
