﻿		function p(v){
			return parseInt(v);
		}	
    var closedSize= 0 // hvor bredt skal elementet være i indskrumpet tilstand (0 hvis det skal helt væk)
		//var openedSize= p(crf * 385)
		var openedSize= 0  
		
		var isMoving=false
		var isClosed =false
		//var rightVal= p(crf * 385) 
		var rightVal= 0

		function g(theElm){
			return document.getElementById(theElm)
		}
		
		function hideStuff() {
			if(!isClosed)
			{
				thetimer = setInterval("decrWidth(20)",10) 
				isMoving=true			
			}
		}
		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 showStuff() {
				if(isClosed)
					{
						thetimer = setInterval("decrWidth(-20)",10) 
						isMoving=true
					}
			}
		
		function decrWidth(decrAmount)// negative for increase of size
		{
			rightVal = rightVal-decrAmount
			
			g('minDiv').style.clip = 'rect(0px '+rightVal+'px 2000px 0px)';
			g('tabellen').style.left = parseInt(g('tabellen').style.left) - decrAmount + "px";
			
			if (rightVal<=closedSize || rightVal>=openedSize)
				{
				isMoving = false
				isClosed = !isClosed
				if (isClosed)
				{
					g('minDiv').style.clip = 'rect(0px ' + rightVal + 'px 2000px 0px)';
					g('tabellen').style.left = parseInt(g('tabellen').style.left) + parseInt(crf) + "px";
					rightVal = 1;
					//window.status="inde ";
					//alert("Lukket");
					justerAfterClosed();
				}
				else{	
					g('tabellen').style.left = rxpos('minDiv')+ 'px';
					//window.status="ude ";
					//alert(rxpos('minDiv'));
				}
					
				clearInterval(thetimer)
				}
		}
		
		function justerAfterClosed(){	
				if (jsres == 0) {
							g('tabellen').style.left = g('tabellen').offsetLeft + p(16*crf)+ "px"; //1024
				} else if (jsres == 1) {
							g('tabellen').style.left = g('tabellen').offsetLeft + p(5*crf)+ "px"; //1280
				} else {
							g('tabellen').style.left = g('tabellen').offsetLeft + p(8*crf)+ "px"; //1600	
				}					
			}
		
		var v=""
		function toggle(v){
			openedSize=parseInt(v.substr(0, v.length-2))
		if(isClosed){
				g('infotab').src = "img/klapindknap" + jsres + ".png";
				showStuff()
				
			}else{
				rightVal=openedSize
				
				g('infotab').src = "img/klapudknap" + jsres + ".png";
				hideStuff()
			}
		}

function printThis(v)
{ 
	if(v!=0)
		document.forms.printform.printboat.value = v;
	
	document.forms.printform.printwhat.value = document.getElementById("contractCell").innerHTML;
	document.forms.printform.submit();
}

function printerfocus()
{
	printframe.focus();
	printframe.print();
}

// Ovenstående er Bjarkes original
// Nedenstående er ny version centrering af siden.


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 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]);

	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((pageSize[0] - g('Site').offsetWidth) / 2) + "px";
	if(p(g('Site').style.left) < 0) {
		g('Site').style.left = "0px";
	}
	
	g('ramme').style.left = rxpos('Site') + "px";
	g('ramme').style.top = rypos('Site')+ p(crf * 68) + "px";

	//g('container').style.left = rxpos('Site') + p(crf * 50) + "px";
	g('container').style.left = rxpos('Site') + p(crf * 40) + "px";
	g('container').style.top = rypos('Site')+ p(crf * 97) + "px";

	g('mlmenu').style.left = rxpos('Site') + "px";
	g('mlmenu').style.top = rypos('Site')+ p(crf * 72) + "px";
	
	g('phone').style.left = rxpos('Site') + p(crf * 744) + "px";
	g('phone').style.top = rypos('Site')+ p(crf * 566) + "px";
	
	g('topmenu').style.left = rxpos('Site') + p(crf * 0) + "px";
	g('topmenu').style.top = rypos('Site')+ p(crf * 10) + "px";	

	g('logo').style.left = rxpos('Site') + p(crf * 815) + "px";
	g('logo').style.top = rypos('Site')+ p(crf * 10) + "px";
	
	if ( jspagenr != 0) {
	g('tabellen').style.left = rxpos('Site') + p(crf * 38) + "px";
	g('tabellen').style.top = rypos('Site')+ p(crf * 96) + "px";	

	g('minDiv').style.left = rxpos('Site') + p(crf * 38) + "px";
	g('minDiv').style.top = rypos('Site')+ p(crf * 96) + "px";	
  }

			
}


///////////////////////////////////////////////////////////////// Vedr. NoFlash
//
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
//
function setCookie(c_name,value,expiredays)
	{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
//
function checkCookie()
{
username=getCookie('username');
if (username!=null && username!="")
  {
  	//alert('Welcome again '+username+'!');
  	//g('flashdialog').style.left = p(crf * 140) + "px";
  	//g('flashdialog').style.top = p(crf * 140) + "px";	
  }
  else 
  {
	  //username=prompt('Please enter your name:',"");
	  username="flashalert"
	  if (username!=null && username!="")
	    {
	    setCookie('username',username,365);
    
	    }
	    // vis Dialog
	   g('flashdialog').style.left = p(crf * 140) + "px";
		 g('flashdialog').style.top = p(crf * 140) + "px";	
			
  }
}

function hideFlashAlert()
{
	g('flashdialog').style.left = -2000 + "px";
	}


///////////////////////////////////////////////////////////////// END Vedr. NoFlash
