//opera Netscape 6 Netscape 4x Mozilla Safari

	function checkdocsize(){
		if (window.innerWidth || window.innerHeight){ 
			document.getElementById('content').style.height = window.innerHeight;
			//För menyn tar upp 185
			document.getElementById('content').style.width = window.innerWidth -185;			
		} 
//IE Mozilla 
		if (document.body.clientWidth || document.body.clientHeight){ 
			document.getElementById('content').style.height = document.body.clientHeight; 
			//För menyn tar upp 185
			document.getElementById('content').style.width = document.body.clientWidth -185; 			
		} 
	}

//Sidor utan meny!!!
//opera Netscape 6 Netscape 4x Mozilla Safari

	function checkdocsizeWithout(){
		if (window.innerWidth || window.innerHeight){ 
			document.getElementById('content').style.height = window.innerHeight;
			//För menyn tar upp 185
			document.getElementById('content').style.width = window.innerWidth;            
		} 
//IE Mozilla 
		if (document.body.clientWidth || document.body.clientHeight){ 
			document.getElementById('content').style.height = document.body.clientHeight-20; 
			//För menyn tar upp 185
			document.getElementById('content').style.width = document.body.clientWidth-20; 			
		} 
	}

// Popupfunktion
function imagePopup(xx) {
	window.open(xx, "popup", "menubar=0,status=0,scrollbars=0,resizable=0,toolbar=0,location=0,width=465,height=352")
						}
						
function windowPopup(page, width, height)
{
    var windowW = 0;
    var windowH = 0;
    var left = 0;
    var top = 0;
    var bottomMargin = 50;
    if (window.screen.width || window.screen.height) 
    {
        windowW = window.screen.width;
        windowH = window.screen.height;
    }
    left = (windowW > width) ? ((windowW/2) - (width/2)) : 0;
    top = (windowH > (height + bottomMargin)) ? ((windowH/2) - (height/2) - bottomMargin) : 0;
    //alert("left: " + left + "\n" + "top: " + top + "\n" + "w: " + windowW + "\n" + "h: " + windowH + "\n" + "w2: " + width + "\n" + "h2: " + height + "\n");
    var wstyle = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes";
    wstyle = wstyle + ",left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;
    window.open(page, "Vaderstad", wstyle);
}

//*********************************************************************************							
// För att bestämma storlek på fönster utifrån bild						
var isNav4, isIE4;
				if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
				isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
				isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
				}
				function fitWindowSize() {
				if (isNav4) {
				window.innerWidth = document.layers[0].document.images[0].width;
				window.innerHeight = document.layers[0].document.images[0].height;
				}
				if (isIE4) {
				window.resizeTo(500, 500);
				width = 500 - (document.body.clientWidth -  document.images[0].width);
				height = 500 - (document.body.clientHeight -  document.images[0].height);
				window.resizeTo(width, height);
				}
				}
//*********************************************************************************		

//*********************************************************************************	
// Aktivera button med enter
//För att aktivera "form"-wide
//<body onkeydown="return fnTrapKD(document.frmSearchMedia.btnSearch, event)" onload="this.focus()">

function fnTrapKD(frm, btnName, event){
	for(var i=0; i < frm.elements.length; i++) {
		if(frm.elements[i].name != null) {
			if(frm.elements[i].name.indexOf(btnName) > 1) {			

				if (document.all){
					if (event.keyCode == 13){
						event.returnValue=false;
						event.cancel = true;
						frm.elements[i].click();
					} 
				}
				else if (document.getElementById){
					if (event.which == 13){
						event.returnValue=false;
						event.cancel = true;
						frm.elements[i].click();
					}
				} else if(document.layers){
					if(event.which == 13){
						event.returnValue=false;
						event.cancel = true;
						frm.elements[i].click();
					}
				}
			}
		}
	}
}

//*********************************************************************************
// History back med cancel
//<body onkeydown="return fnTrapCancelBack(event)" onload="this.focus()">

function fnTrapCancelBack(page, event){

	if (document.all){
		if (event.keyCode == 27){
			window.location.href = page;
		}
	}
	else if (document.getElementById){
		if (event.keyCode == 27){
			window.location.href = page;
		}
	} else if(document.layers){
		if (event.keyCode == 27){			
			window.location.href = page;
		}
	}
}

//*********************************************************************************	

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture) 
{
    if (elm.addEventListener){
        elm.addEventListener(evType, fn, useCapture);
        return true;
    } else if (elm.attachEvent){
        var r = elm.attachEvent("on"+evType, fn);
        return r;
    }
}