//General.js by Mattias Hising, Framfab A142.

function preload(imgObj,imgSrc) {
// preloada föra tt minska antalet requests till servern
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}


function changeImage(layer,imgName,imgObj) {
// onmouseover script
	if (document.images) {
		if (ns4 && layer!=null) 
			eval('document.layers.container.document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
		else{
			document.images[imgName].src = eval(imgObj+".src");
		}
	}
}

function changeProdImage(layer,imgName,imgObj) {
// onmouseover script
	if (document.images) {
		if (ns4 && layer!=null) 
			eval("document.layers.container.document."+layer+".document.images[\"" +imgName+ "\"].src = \"" + imgObj + "\"");
		else{
			document.images[imgName].src = imgObj;
		}
	}
}

var winW, winH, obj;

function init(){
	// Hitta mitten på skärmen för alla lager
	if (ie){
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
		obj = document.all.container.style
	} else if(ns4){

		winW = window.innerWidth;
		winH = window.innerHeight;
		obj = document.layers.container
	} else {
		// alla andra browsers, NS6, IE5, Opera m.m.
		winW = window.innerWidth;
		winH = window.innerHeight;
		obj = document.getElementById('container').style
	}
	alignWindow();
	return;
}

function popEndorsement(url){
	popWindow=window.open(url,'popup','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=700,height=405');
}

winCnt = new Array()
function popUp(src, w, h){
	var l;
	var t;
	if(ns4 || gecko) {
		//Values 5 and 24 are hardcoded values that represent the border and statusbar on netscape
		l = (window.screenX+5) + ((window.innerWidth/2) - (w/2))-5
		if(ns4){ t = (window.screenY + ((window.outerHeight-24) - window.innerHeight)) + (window.innerHeight/2)-(h/2)}
		else if(gecko) { t = (window.screenY + (window.outerHeight-window.innerHeight) - 36) + ((window.innerHeight-18)/2)-(h/2)}
	} else if(mac && ie) {
		l = event.screenX - event.clientX+10; //macie5 only
		t = event.screenY - event.clientY+10; //macie5 only
	} else {
		l = window.screenLeft + (document.body.offsetWidth/2) - w/2
		t = window.screenTop + (document.body.offsetHeight/2) - h/2
	}
	winName = "popup" + winCnt.length
	winProps = "toolbar=no,location=topleft,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + "screenX=" + l + "screenY=" + t
	winCnt[winCnt.length] = window.open(src, winName, winProps)
}



