﻿
function checkSoeg(s)  {
  if (document.forms[0].sg.value == "søg") {
  	document.forms[0].sg.value = '';     
  }
}


function g(v) {
	return document.getElementById(v);
}
function p(v) {
	return parseInt(v);
}

function rxpos(v) {
	var obj = g(v);
	var cx = 0;
	if (obj.offsetParent) {
		cx = obj.offsetLeft
		while (obj = obj.offsetParent) {
			cx += obj.offsetLeft
		}
	}
	return cx;
}

function rypos(v) {
	var obj = g(v);
	var cy = 0;
	if (obj.offsetParent) {
		cy = obj.offsetTop
		while (obj = obj.offsetParent) {
			cy += obj.offsetTop
		}
	}
	return cy;
}


function rxposObj(v) {
	var obj = v;
	var cx = 0;
	if (obj.offsetParent) {
		cx = obj.offsetLeft
		while (obj = obj.offsetParent) {
			cx += obj.offsetLeft
		}
	}
	return cx;
}

function ryposObj(v) {
	var obj = v;
	var cy = 0;
	if (obj.offsetParent) {
		cy = obj.offsetTop
		while (obj = obj.offsetParent) {
			cy += obj.offsetTop
		}
	}
	return cy;
}


var intCurrImg = 0;

function nextImage() {
	if(typeof(arrPageImages)!="undefined") {
		intCurrImg += 1;
		if(intCurrImg>=arrPageImages.length) {
			intCurrImg = 0;
		}
		//g('bgImage').src = arrPageImages[intCurrImg];
		g('MainImg').style.backgroundImage = "url(\"" + arrPageImages[intCurrImg] + "\")";
		g('Imgtxt').innerHTML = arrPageImagestxt[intCurrImg];		
	}
}

function prevImage() {
	if(typeof(arrPageImages)!="undefined") {
		intCurrImg -= 1;
		if(intCurrImg<0) {
			intCurrImg = arrPageImages.length - 1;
		}
		//g('bgImage').src = arrPageImages[intCurrImg];
		g('MainImg').style.backgroundImage = "url(\"" + arrPageImages[intCurrImg] + "\")";
		g('Imgtxt').innerHTML = arrPageImagestxt[intCurrImg];
	}
}


var lukstate=2;
function positionlukknap() {	
	if (lukstate == 1) {
		g('lukknap').style.left = rxpos('txtbg') + p(jsRF * 335) + "px";
		lukstate=2;	
	}else{		
		g('lukknap').style.left = rxpos('Site')+ p(jsRF * 200) + "px";
		lukstate=1;
	}
}

var ie5;
var ns6;
function startup() {
	ie5=document.all&&document.getElementById;
	ns6=document.getElementById&&!document.all;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function delayPositionThings() {
		setTimeout("positionThings()", 500);
}

function positionThings() {

	var pageSize = getPageSize();
	var pageHeight = (ie5 ? pageSize[1] : pageSize[3]);
	var pageWidth = (ie5 ? pageSize[0] : pageSize[2]);


	g('Site').style.top = p((pageHeight - g('Site').offsetHeight) / 2) + "px";
	if(p(g('Site').style.top) < 0) {
		g('Site').style.top = "0px";
	}
	
	g('Site').style.left = p((pageWidth - g('Site').offsetWidth) / 2) + "px";
	if(p(g('Site').style.left) < 0) {
		g('Site').style.left = "0px";
	}

	g('print_pdf').style.left = rxpos('Site')+ g('Site').offsetWidth - 22 + "px";
	g('print_pdf').style.top = rypos('Site')+ g('Site').offsetHeight + 1 + "px";
	
	g('Sitetop').style.left = rxpos('Site') + 1+ "px";
	g('Sitetop').style.top = rypos('Site') + 1 + "px";

	g('Logo').style.left = rxpos('Site') + p(jsRF * 20)+ "px";
	g('Logo').style.top = rypos('Site') + p(jsRF * 20) + "px";


	g('top').style.left = rxpos('Site')+ 1 + "px";
	g('top').style.top = rypos('Site')+ p(jsRF * 90) + "px";
	
	g('bottom').style.left = rxpos('Site')+ 1 + "px";
	g('bottom').style.top = rypos('Site')+ p(jsRF * 535) + "px";	









	if ( bolForside == true) {	
		g('flash').style.left =  rxpos('Site')+ g('bottomLeft').offsetWidth + 1 + "px";
		g('flash').style.top = rypos('Site')+ p(jsRF * 115) + "px";


	}else{
		g('MainImg').style.left = rxpos('Site')+ g('bottomLeft').offsetWidth + 1 + "px";
		g('MainImg').style.top = rypos('Site')+ p(jsRF * 115) + "px";	
		
		g('bottomLeft').style.left = rxpos('Site')+ 1 + "px";
		g('bottomLeft').style.top = rypos('Site')+ p(jsRF * 535) + "px";	
	
		g('bottomRight').style.left = rxpos('Site')+ g('Site').offsetWidth - g('bottomRight').offsetWidth  + "px";
		g('bottomRight').style.top = rypos('Site')+ p(jsRF * 535) + "px";		
	
		g('FanerImg').style.left = rxpos('Site')+ g('bottomLeft').offsetWidth + 1 + "px";
		g('FanerImg').style.top =  rypos('Site')+ p(jsRF * 90) + "px";
	
		g('FanerInfo').style.left = rxpos('Site')+ g('Site').offsetWidth - g('bottomRight').offsetWidth  + "px";
		g('FanerInfo').style.top =  rypos('Site')+ p(jsRF * 90) + "px";	
		
		g('submenu').style.left = rxpos('Site')+ p(jsRF * 15) + "px";
		g('submenu').style.top = rypos('Site')+ p(jsRF * 142) + "px";
		
		g('Imgtxt').style.left = rxpos('Site')+ g('bottomLeft').offsetWidth + 1 + "px";
		g('Imgtxt').style.top =   rypos('Site')+ p(jsRF * 535) + "px";
		
		g('home_print').style.left = rxpos('Site')+ p(jsRF * 20) + "px";
		g('home_print').style.top = rypos('Site')+ p(jsRF * 538) + "px";			
		
	}	

	if (arrPageImages.length > 1) {
		g('imgArrowRight').style.left = rxpos('bottomRight')- g('imgArrowRight').offsetWidth -p(jsRF * 10) + "px";
		g('imgArrowRight').style.top = rypos('Site')+ p(jsRF * 538) + "px";
	
		g('imgArrowLeft').style.left = rxpos('imgArrowRight')- g('imgArrowLeft').offsetWidth -p(jsRF * 5) + "px";
		g('imgArrowLeft').style.top = rypos('Site')+ p(jsRF * 538) + "px";
	}

	
	g('hovedmenu').style.left = rxpos('Site') + g('Site').offsetWidth - g('hovedmenu').offsetWidth - p(jsRF * 20) + "px";
	g('hovedmenu').style.top = rypos('Site') + p(jsRF * 70) + "px";
	

	g('sprog').style.left = rxpos('Site')+ g('Site').offsetWidth - g('sprog').offsetWidth - p(jsRF * 150) + "px";
	g('sprog').style.top = rypos('Site')+ p(jsRF * 22) + "px";

	g('soeg').style.left = rxpos('Site')+ g('Site').offsetWidth - g('soeg').offsetWidth - p(jsRF * 20) + "px";
	g('soeg').style.top = rypos('Site')+ p(jsRF * 20) + "px";




	

if ( bolBredSide) {
	
		g('txtbg').style.left = rxpos('Site')+ g('bottomLeft').offsetWidth + 1 + "px";
		g('txtbg').style.top = rypos('Site')+ p(jsRF * 115) + "px";	
		
			g('txtbg').style.width = g('txtbg').offsetWidth+g('MainImg').offsetWidth + "px";
		
		g('masterContainer1').style.left = rxpos('txtbg')+ p(jsRF * 1) + "px";
		g('masterContainer1').style.top = rypos('txtbg')+ p(jsRF * 4) + "px";
	
			g('masterContainer1').style.width = g('masterContainer1').offsetWidth+g('MainImg').offsetWidth + "px";
	
		g('arrowContainer1').style.left = rxpos('masterContainer1')+ g('masterContainer1').offsetWidth - p(jsRF * 20) + "px";
		g('arrowContainer1').style.top = rypos('masterContainer1') + p(jsRF * 20) + "px";
	
	}else{
		
		if ( bolForside == true) {	
		g('txtbg').style.left = rxpos('Site')+ p(jsRF * 1) + "px";
		g('txtbg').style.top = rypos('Site')+ p(jsRF * 115) + "px";
			
			g('txtbg').style.width = jsRF * 163 + "px";
			
			g('masterContainer1').style.left = rxpos('txtbg')+ p(jsRF * 1) + "px";
			g('masterContainer1').style.top = rypos('txtbg')+ p(jsRF * 4) + "px";
			
			g('masterContainer1').style.width = jsRF * 163 + "px";
		
			g('arrowContainer1').style.left = rxpos('masterContainer1')+ g('masterContainer1').offsetWidth - p(jsRF * 20) + "px";
			g('arrowContainer1').style.top = rypos('masterContainer1') + p(jsRF * 20) + "px";	
	
	
		}else{
			g('txtbg').style.left = rxpos('Site')+ p(jsRF * 705) + "px";
			g('txtbg').style.top = rypos('Site')+ p(jsRF * 115) + "px";
			
			g('masterContainer1').style.left = rxpos('txtbg')+ p(jsRF * 1) + "px";
			g('masterContainer1').style.top = rypos('txtbg')+ p(jsRF * 4) + "px";
		
			g('arrowContainer1').style.left = rxpos('masterContainer1')+ g('masterContainer1').offsetWidth - p(jsRF * 20) + "px";
			g('arrowContainer1').style.top = rypos('masterContainer1') + p(jsRF * 20) + "px";	
		
		}	
}


	

		





	
}

