var blnFirstRun = false;

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;
}

var ie5; var ns6;
function startup() {
	ie5=document.all&&document.getElementById;
	ns6=document.getElementById&&!document.all;
}

var TextVisible = false;
function positionThings() {
	
	if(blnGalleryContents  || blnIsFront) {
		
		if(!blnFirstRun) {
//			TextVisible=getCookie('TextVisible');
//			//alert('svaret fra cookie: '+TextVisible);
//			if(TextVisible == ''){TextVisible = 'true'}
//			//if(blnIsFront){TextVisible = 'false'}
//				if(TextVisible == 'true'){
//					toggleDescription(jsLang, jsres);
//				}else{
//					toggleDescription(jsLang, jsres);
//					toggleDescription(jsLang, jsres);
//				}
				
				toggleDescription(jsLang, jsres);
				toggleDescription(jsLang, jsres);
		
		} //blnFirstRun
	} //blnGalleryContents
	
	
	if(navigator.appVersion.indexOf("Mac")<1) {
		g('textDivBG').style.MozOpacity = .75;
	}
	g('addressDiv').style.left = rxpos('menuTD') + p(crf*15) + "px";
	g('addressDiv').style.top = p(rypos('menuTD') + g('menuTD').offsetHeight - g('addressDiv').offsetHeight) - p(crf*15) + "px";
	
	g('reklameDiv').style.left = rxpos('menuTD') + p(crf*7) + "px";
	g('reklameDiv').style.top = p(rypos('menuTD') + g('menuTD').offsetHeight - g('addressDiv').offsetHeight) - p(crf*40) + "px";
	
	//g('menuTable').style.width = g('menuTD').style.width;
	//alert(g('topRightTD').offsetWidth);
	g('textDivBG').style.left = rxpos('mainTD') + "px";
	g('textDivBG').style.top = rypos('mainTD') + "px";
	g('textDivBG').style.width = p(crf*240) + "px";
	g('textDivBG').style.height = p(crf*427) + "px";

	g('masterContainer').style.left = p(g('textDivBG').style.left) + p(crf*10) + "px";
	g('masterContainer').style.top = p(g('textDivBG').style.top) + p(crf*30) + "px";
	
	if (g('BookingCompuweb')){
		g('BookingCompuweb').style.left = p(g('textDivBG').style.left) + p(crf*0) + "px";
		g('BookingCompuweb').style.top = p(g('textDivBG').style.top) + p(crf*23) + "px";				
		}

	if (g('iCalender')){
		g('iCalender').style.left = p(g('textDivBG').style.left) + p(crf*0) + "px";
		g('iCalender').style.top = p(g('textDivBG').style.top) + p(crf*23) + "px";				
		}


	if (g('btnBookingCompuweb')){
	g('btnBookingCompuweb').style.left = rxpos('menuTD') + p(crf*30) + "px";
	g('btnBookingCompuweb').style.top = p(rypos('menuTD') + g('menuTD').offsetHeight - g('addressDiv').offsetHeight) - p(crf*100) + "px";
	}
	
	
	g('langDiv').style.left = rxpos('topTD') + p(crf*680-200) + "px";
	g('langDiv').style.top = p(crf*5) + "px";




	//g('divAddThis').style.left = rxpos('topTD') + p(crf*850) + "px";
	g('divAddThis').style.top = rypos('topTD') + p(crf*22) + "px";	
	g('divAddThis').style.left = rxpos('tbl_main') + g('tbl_main').offsetWidth - g('divAddThis').offsetWidth + "px";
	
	//g('divFacebookLinks').style.left = rxpos('topTD') + p(crf*885) + "px";
	g('divFacebookLinks').style.top = rypos('topTD') + p(crf*42) + "px";	
	g('divFacebookLinks').style.left = rxpos('tbl_main') + g('tbl_main').offsetWidth - g('divFacebookLinks').offsetWidth + "px";


	//g('divSilkeborgCampingLink').style.left = rxpos('topTD') + p(crf*820) + "px";
	g('divSilkeborgCampingLink').style.left = rxpos('tbl_main') + g('tbl_main').offsetWidth - p(crf*153) + "px";
	g('divSilkeborgCampingLink').style.top =  p(crf*1) + "px";


	//g('topLinkHomePrintTip').style.left = rxpos('topTD') + p(crf*770) + "px";
	g('topLinkHomePrintTip').style.left = rxpos('divSilkeborgCampingLink') - g('topLinkHomePrintTip').offsetWidth + "px";
	g('topLinkHomePrintTip').style.top = rypos('topTD') + p(crf*1) + "px";

	//g('langDiv').style.left = rxpos('topTD') + p(crf*680-200) + "px";
	g('langDiv').style.left = rxpos('topLinkHomePrintTip') - g('langDiv').offsetWidth + "px";
	g('langDiv').style.top = p(crf*5) + "px";


	g('div_dk_kort').style.left = rxpos('topTD') + p(crf*780+30) + "px";
	g('div_dk_kort').style.top = p(crf*30) + "px";

	g('div_top_logo').style.left = rxpos('topTD') + p(crf*300) + "px";
	g('div_top_logo').style.top = p(crf*10) + "px";

	g('div_turenGaarTil').style.left = rxpos('topTD') + p(crf*790) + "px";
	g('div_turenGaarTil').style.top = p(crf*125) + "px";

	if (g('div_forsideTeaser')){
		g('div_forsideTeaser').style.left = rxpos('topTD') + p(crf*280) + "px";
		g('div_forsideTeaser').style.top = p(crf*473) + "px";
	}

	
	g('topLinkOffer').style.left = rxpos('topTD') + p(crf*855) + "px";
	g('topLinkOffer').style.top = p(crf*160) + "px";
	
	g('topLinkCalendar').style.left = p(g('topLinkOffer').style.left) - p(crf*0) + "px";
	g('topLinkCalendar').style.top = p(g('topLinkOffer').style.top) + p(crf*25) + "px";
	
	g('topLinkNews').style.left = p(g('topLinkCalendar').style.left) - p(crf*0) + "px";
	g('topLinkNews').style.top = p(g('topLinkCalendar').style.top) + p(crf*25) + "px";
	
	
	
	
	
	



	//if(g('textInOut')) {
	g('textInOut').style.left = rxpos('menuTD') + g('menuTD').offsetWidth - g('textInOut').offsetWidth + p(crf*30) + "px";
	g('textInOut').style.top = rypos('menuTD') - p(crf*1) + "px";
	//}
	
	if(blnLageContents) {
		//alert("Test1");
		g('textDivBG').style.width = p(g('textDivBG').style.width) + p(crf*150) + "px";
		if(!blnFirstRun) {
			g('masterContainer').style.width = p(g('masterContainer').style.width) + p(crf*150) + "px";
			blnFirstRun = true;
		}
	}


	if(blnXLageContents) {
		//alert("Test");
		g('textDivBG').style.width = p(g('textDivBG').style.width) + p(crf*403) + "px";
		if(!blnFirstRun) {
			g('masterContainer').style.width = p(g('masterContainer').style.width) + p(crf*403) + "px";
			blnFirstRun = true;
		}
	}
	
//alert(blnGalleryContents);

	if(blnGalleryContents) {
		//alert(blnGalleryContents);
		g('textDivBG').style.width = p(g('textDivBG').style.width) + p(crf*398) + "px";
		g('textDivBG').style.left = rxpos('menuTD') + g('menuTD').offsetWidth+ p(crf*5) + "px";
		
	g('textDivBG2').style.left = rxpos('mainTD') + "px";
	g('textDivBG2').style.top = rypos('mainTD') + "px";
	g('textDivBG2').style.width = p(crf*240) + "px";
	g('textDivBG2').style.height = p(crf*427) + "px";		
		
		if(!blnFirstRun) {
			//alert(blnGalleryContents);
			
			
			g('masterContainer2').style.left = p(g('textDivBG').style.left) + p(crf*10) + "px";
			g('masterContainer2').style.top = p(g('textDivBG').style.top) + p(crf*30) + "px";
			g('masterContainer2').style.width = p(g('masterContainer2').style.width) + p(crf*30) + "px";
			g('masterContainer2').style.left = rxpos('menuTD') + g('menuTD').offsetWidth+ p(crf*5) + "px";

	
			g('masterContainer').style.width = p(g('masterContainer').style.width) + p(crf*398) + "px";
			g('masterContainer').style.left = rxpos('menuTD') + g('menuTD').offsetWidth+ p(crf*5) + "px";
			
			//g('documentContainer').style.width = p(g('masterContainer').style.width) - p(crf*50) + "px";
			
			blnFirstRun = true;
		}
	}	
	
	
	g('imageArrowsContainer').style.left = rxpos('masterContainer') + g('masterContainer').offsetWidth + "px";
	g('imageArrowsContainer').style.top = rypos('masterContainer') + "px";
	
	//g("imgLogoRight").style.left = rxpos("topRightTD") + ( g("topRightTD").offsetWidth /2  - g("imgLogoRight").offsetWidth / 2) + "px";
	//g("imgLogoRight").style.top  = rypos("topRightTD") + g("topRightTD").offsetHeight - g("imgLogoRight").offsetHeight + "px";
	
	return;
	
}

function placeObjectBelowLeft(toAlignTo, moveObj, padHori, padVert) {
	g(moveObj).style.left = parseInt(g(toAlignTo).style.left) + padHori + "px";
	g(moveObj).style.top = parseInt(g(toAlignTo).style.top) + g(toAlignTo).offsetHeight + padVert + "px";
}

function placeObjectBelowRight(toAlignTo, moveObj, padHori, padVert) {
	g(moveObj).style.left = parseInt(g(toAlignTo).style.left) + g(toAlignTo).offsetWidth - g(moveObj).offsetWidth + padHori + "px";
	g(moveObj).style.top = parseInt(g(toAlignTo).style.top) + g(toAlignTo).offsetHeight + padVert + "px";
}

function alignElementCentersHori(toAlignTo, moveObj, padding) {
	var toCenterPoint = 0;
	toCenterPoint = parseInt(g(toAlignTo).style.left);
	toCenterPoint = toCenterPoint + parseInt(g(toAlignTo).offsetWidth / 2);
	g(moveObj).style.left = toCenterPoint - parseInt(g(moveObj).offsetWidth / 2) + padding + "px";
}

function alignElementTop(toAlignTo, moveObj, padding) {
	var toTopPoint = 0;
	toTopPoint = parseInt(g(toAlignTo).style.top);
	g(moveObj).style.top = toTopPoint + padding + "px";
}

function alignElementBottoms(toAlignTo, moveObj, padding) {
	var toBottomPoint = 0;
	toBottomPoint = parseInt(g(toAlignTo).style.top);
	toBottomPoint = toBottomPoint + parseInt(g(toAlignTo).offsetHeight);
	g(moveObj).style.top = toBottomPoint - parseInt(g(moveObj).offsetHeight) + padding + "px";
}




//************************************* Cookie


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 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 "";
}

//************************************* END Cookie



function toggleDescription(lng, reso) {
	
	//alert(blnGalleryContents);

	if(blnGalleryContents) {


		if(g('textDivBG2').style.visibility == "visible") {
			g('textDivBG2').style.visibility = "hidden";
			g('masterContainer2').style.visibility = "hidden";
			//g('documentContainer').style.display = "none";
			//g('imageArrowsContainer').style.visibility = "hidden";
			g('textInOut').src = "img/textOut_" + lng + "_" + reso + ".png";
			//setCookie('TextVisible',false,1);

		}
		else {
			g('textDivBG2').style.visibility = "visible";
			g('masterContainer2').style.visibility = "visible";
			//g('documentContainer').style.display = "block";
			//g('imageArrowsContainer').style.visibility = "visible";
			g('textInOut').src = "img/textIn_" + lng + "_" + reso + ".png";
			//setCookie('TextVisible',true,1);
		}

			g('textDivBG').style.visibility = "visible";
			g('masterContainer').style.visibility = "visible";
			g('documentContainer').style.display = "block";
			g('imageArrowsContainer').style.visibility = "visible";
			//g('textInOut').src = "img/textIn_" + lng + "_" + reso + ".jpg";

	}else{
		
		if(g('textDivBG').style.visibility == "visible") {
			g('textDivBG').style.visibility = "hidden";
			g('masterContainer').style.visibility = "hidden";
			g('documentContainer').style.display = "none";
			g('imageArrowsContainer').style.visibility = "hidden";
			g('textInOut').src = "img/textOut_" + lng + "_" + reso + ".png";
		}
		else {
			g('textDivBG').style.visibility = "visible";
			g('masterContainer').style.visibility = "visible";
			g('documentContainer').style.display = "block";
			g('imageArrowsContainer').style.visibility = "visible";
			g('textInOut').src = "img/textIn_" + lng + "_" + reso + ".png";
		}
	
	}	
	preparescroller();
	
	
}

var a1 = 0; var a2 = 0; var a3 = 0;
var activeImgSet = 0;
var firstMove = false
var temp;


function resizeDiv()
{
	var obj = document.getElementById("contTable");
	if(parseInt(obj.offsetHeight)>448) {
		document.getElementById("contDiv").style.width = 734 + "px";
	}
}

function printThis(v) { 
	document.forms.printform.printwhat.value = document.getElementById("documentContainer").innerHTML;
	document.forms.printform.submit();
}

function printThisCal(v) { 
	document.forms.printform.printwhat.value = document.getElementById(v).innerHTML;
	document.forms.printform.submit();
}

function printerfocus() {
	printframe.focus();
	printframe.print();
}

function expandDiv(no) {
	if(g('news' + no + 'contents').style.display == "none") {
		g('news' + no + 'contents').style.display = "block";
	}
	else {
		g('news' + no + 'contents').style.display = "none";
	}
	preparescroller();
}