/* Layerlib.js                          Version 2.13

   Följande funktioner är skrivna av Johan Johansson
   och är fria att användas så länge som dessa rader
   står kvar i omodifierade.

   http://www.jojoxx.net  -*-  2002-12-02 */

// Browsercheck
var isNetscape=(navigator.appName=="Netscape")?true:false;
var isIE=(navigator.appName=="Microsoft Internet Explorer")?true:false;
// Initiera script
if (document.layers){
	var jxtools=new Packages.java.awt.Toolkit.getDefaultToolkit();
	screen=jxtools.getScreenSize();
}
function moveLayerAbs(Id,x,y){
	if (document.all){
		document.all[Id].style.left = x; document.all[Id].style.top = y;
	} else if (document.layers){
		document.layers[Id].left = x; document.layers[Id].top = y;
	} else if (document.getElementById){
		document.getElementById(Id).style.left = x+'px'; document.getElementById(Id).style.top = y+'px';
	}
}	
function moveLayerDiff(Id,diffX,diffY){
	if (document.all || document.layers || document.getElementById){
		if (document.all){
			var currx = parseInt(document.all[Id].style.left);
			var curry = parseInt(document.all[Id].style.top);
		} else if (document.layers){
			var currx = parseInt(document.layers[Id].left);
			var curry = parseInt(document.layers[Id].top);
		} else if (document.getElementById){
			var currx = parseInt(document.getElementById(Id).style.left);
			var curry = parseInt(document.getElementById(Id).style.top);
		}
		currx+=diffX;
		curry+=diffY;
		moveLayerAbs(Id,currx,curry);
	}
}

function getLayer(Id){
	if (document.all) {
		return document.all[Id];
	} else if (document.layers){
		return document.layers[Id];
	} else if (document.getElementById){
		return document.getElementById(Id);
	}
}

function showLayer(Id){
	if (document.all) {
		document.all[Id].style.visibility = "visible";
	} else if (document.layers){
		document.layers[Id].visibility = "show";
	} else if (document.getElementById){
		document.getElementById(Id).style.visibility = "visible";
	}
}
function hideLayer(Id){
	if (document.all) {
		document.all[Id].style.visibility = "hidden";
	} else if (document.layers){
		document.layers[Id].visibility = "hide";
	} else if (document.getElementById){
		document.getElementById(Id).style.visibility = "hidden";
	}
}
function getLayerWidth(Id){
	if(document.getElementById){ return document.getElementById(Id).offsetWidth }
	if(document.all){ return document.all[Id].offsetWidth }
	if(document.layers){ return document[Id].document.width }
}
function getLayerHeight(Id){
	if(document.getElementById){ return document.getElementById(Id).offsetHeight }
	if(document.all){ return document.all[Id].offsetHeight }
	if(document.layers){ return document[Id].document.height }
}

function setLayerWidth(Id,value){
	if(document.getElementById){ document.getElementById(Id).style.width = value; }
	else if(document.all){ document.all[Id].style.width = value;}
	else if(document.layers){ document[Id].width = value;}
}
function setLayerHeight(Id,value){
	if(document.getElementById){ document.getElementById(Id).style.height = value;}
	else if(document.all){ document.all[Id].style.height = value;}
	else if(document.layers){ document[Id].height = value;}
}

function getClientWidth(){
	if(document.all){ return document.body.clientWidth; }
	if(isNetscape){ return window.innerWidth; }
}
function getClientHeight(){
	if(document.all){ return document.body.clientHeight; }
	if(isNetscape){ return window.innerHeight; }
	return window.innerHeight;
}
function getScreenWidth(){
	if (document.all || isNetscape){ return screen.width; }
}
function getScreenHeight(){
	if (document.all || isNetscape){ return screen.height; }
}
function getBodyHeight(){
	return document.height ? document.height : document.body.scrollHeight;
}
function getBodyWidth(){
	return document.width ? document.width : document.body.scrollWidth;
}
function getScrollX(){
	if(document.all){ return document.body.scrollLeft; }
	if(isNetscape){ return pageXOffset; }
}
function getScrollY(){
	if (document.all){ return document.body.scrollTop; }
	if (isNetscape){ return pageYOffset; }
}
function getLayerX(Id){
	if (document.getElementById){ return isNaN(parseInt(document.getElementById(Id).style.left))?document.getElementById(Id).offsetLeft:parseInt(document.getElementById(Id).style.left); }
	if (document.all){ return parseInt(document.all[Id].style.left); }
	if (document.layers){ return parseInt(document.layers[Id].left); }
}
function getLayerY(Id){
	if (document.getElementById){ return isNaN(parseInt(document.getElementById(Id).style.top))?document.getElementById(Id).offsetTop:parseInt(document.getElementById(Id).style.top); }
	if (document.all){ return parseInt(document.all[Id].style.top); }
	if (document.layers){ return parseInt(document.layers[Id].top); }
}
function scrollLayerTo(Id,x,y,speed){
	if(Math.abs(getLayerX(Id)-x)<speed&&Math.abs(getLayerY(Id)-y)<speed){
		moveLayerAbs(Id,x,y);
	} else {
		if(Math.abs(getLayerY(Id)-y)>Math.abs(getLayerX(Id)-x)){
			var movy=speed;
			var movx=parseInt((Math.abs(getLayerX(Id)-x)/Math.abs(getLayerY(Id)-y))*speed);
		} else {
			var movx=speed;
			var movy=parseInt((Math.abs(getLayerY(Id)-y)/Math.abs(getLayerX(Id)-x))*speed);
		}
		if(getLayerX(Id)>x) movx=-movx;
		if(getLayerY(Id)>y) movy=-movy;
		moveLayerAbs(Id,getLayerX(Id)+movx,getLayerY(Id)+movy);
		eval("setTimeout('scrollLayerTo(\""+Id+"\","+x+","+y+","+speed+")',5);");
	}
}
function writeToLayer(Id,string){
	if(document.layers){
		with (document[Id].document){
			open();
			write(string);
			close();
		}
	} else if (document.all){
		document.all[Id].innerHTML = string;
	} else if (document.getElementById && isNetscape){
		jxdocrange = document.createRange();
		jxdocrange.setStartBefore(document.getElementById(Id));
		while (document.getElementById(Id).hasChildNodes()){
			document.getElementById(Id).removeChild(document.getElementById(Id).lastChild);
		}
		document.getElementById(Id).appendChild(jxdocrange.createContextualFragment(string));
	}
}
function changeStyle(Id,Property,Value){
	if (document.all){
		eval('document.all[Id].style.'+Property+'="'+Value+'"');
	} else if (document.layers){
		eval('document.layers[Id].'+Property+'="'+Value+'"');
	} else if (document.getElementById){
		eval('document.getElementById(Id).style.'+Property+'="'+Value+'"');
	}
}

function fadeInLayer(lager,val){
	showLayer(lager)
	getLayer(lager).style.filter='alpha(opacity='+val+')'
	if (val<95){
		setTimeout("fadeInLayer('"+lager+"',"+eval(val+10)+")",10)}
}
function fadeOutLayer(lager, val){
	getLayer(lager).style.filter='alpha(opacity='+val+')'
	if (val>10){
		setTimeout("fadeOutLayer('"+lager+"',"+eval(val-10)+")",10)}
	else{
		moveLayerAbs(lager,-800,40);
		getLayer(lager).style.filter='alpha(opacity=100)'
		hideLayer(lager)
	}
}