function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
		
	}
	
	blanket_height = document.body.parentNode.scrollHeight;// + document.body.parentNode.scrollTop;
	//alert(document.body.parentNode.scrollTop + " " + document.body.parentNode.clientHeight);
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	
	var popUpDiv = document.getElementById(popUpDivVar);
	var pop_height = popUpDiv.style.height.toString();
	var le = pop_height.length;
	pop_height = pop_height.substring(0,le-2);

	popUpDiv_height=(document.body.parentNode.clientHeight/2)-(pop_height/2) + document.body.parentNode.scrollTop;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	var pop_width = popUpDiv.style.width.toString();
	var le = pop_width.length;
	pop_width = pop_width.substring(0,le-2);
	window_width=window_width/2-(pop_width/2);//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

function sjekk()
{
var pass1 = document.getElementById('pass1').value;
var pass2 = document.getElementById('pass2').value;

if(pass1 != pass2)
{
document.getElementById('passfeil').innerHTML = "Passordene er ikke like! Vennligst forsøk igjen.";
return false;
}else if(pass1 = pass2)
{
return true;
}
return false;
}

function showimg(img)
{

document.getElementById('popUpDiv').innerHTML ='<div id="popuptekst"><a href="#" onClick="popup(\'popUpDiv\');return false;">Lukk</a>          ' + img[1] +  '</div><img id="shownimg" onLoad="resize()" src="' +img[0] + '" />';

}

function resize()
{
popup('popUpDiv');
var i = document.getElementById('shownimg');

var h = i.height;
var w = i.width;
document.getElementById('popUpDiv').style.height = h +20 + "px";
document.getElementById('popUpDiv').style.width = w +20 + "px";

	var popUpDiv = document.getElementById('popUpDiv');
	var pop_height = popUpDiv.style.height.toString();
	var le = pop_height.length;
	pop_height = pop_height.substring(0,le-2);

	popUpDiv_height=(document.body.parentNode.clientHeight/2)-(pop_height/2) + document.body.parentNode.scrollTop;//150 is half popup's height
	if(popUpDiv_height<0){popUpDiv_height=20;}
	popUpDiv.style.top = popUpDiv_height + 'px';
	
	var pop_width = popUpDiv.style.width.toString();
	var le = pop_width.length;
	pop_width = pop_width.substring(0,le-2);
	var window_width=document.body.parentNode.clientWidth/2-(pop_width/2);//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
//setTimeout("alert(document.getElementById('shownimg').height)",1000)
}
