//***********************************************************

//window.status = "www.danskehoteller.dk";
//************************************************************
 //bruges i soge javascriptet
	
	//function sog(param1,param2){	
	//alert(document.sogform.stjerne.options[4].value)
	//alert(document.sogform.region.options[1].value)
	//alert(document.sogform.lokalomraade.options[2].text)
	//document.forms[0].valgsog.value = param1;	//saetter en parameter man kan tjekke paa
	//document.navForm.onload = 'initialiser();imageLoad();TjeckTime();'+param2;
	//document.forms['navForm'].java.value = param2;
	//document.navForm.submit()					//for at se hvilken sogning der er foretaget
    //}	 
   function selectbranche(index) {
       document.kombiForm.type.options[index].selected = true;	
   }
	
   function selectstars(index) {
       document.kombiForm.stjerne.options[index].selected = true;	
   }

   function selectregion(index) {
       document.kombiForm.region.options[index].selected = true;
   }
   
   function selectlocal(index) {
       document.kombiForm.lokalomraade.options[index].selected = true;		 
   }
   function selectbooking(index) {
       document.kombiForm.booking.options[index].selected = true;		 
   }
   function selectkapacitet(index) {
       document.kombiForm.kapacitet.options[index].selected = true;		 
   }
   function kategori(index) {
       document.kombiForm.kategori.options[index].selected = true;		 
   }

   function typeselect2(index) {
       document.kombiForm.typeselect.options[index].selected = true;		 
   }
   function kokken2(index) {
       document.kombiForm.kokken.options[index].selected = true;		 
   }
   function pris2(index) {
       document.kombiForm.pris.options[index].selected = true;		 
   }

//*****blokkere javascript fejl saa brugeren aldrig ser en fejlbesked********************************************************************
function blockError(){return true;}
window.onerror = blockError;

//*************************************************************************
//bruges til soegningen
	
	function sogscript(param1,param2,param3,param4){//bruges til kort sogning
		var java;
		selectregion(param1);	
		udskift(param2);	
		//sammensaetter en java variabel som skal bruges i onload
		java = 'selectregion('+param1+');udskift(\''+param2+'\');';
		if (param3 == ""){ 
		}else{
		selectlocal(param3);		
		java = java + 'selectlocal('+param3+');';
		//document.location.href = "search/search.html";
		}
		document.forms['navForm'].java.value = java;		
		//HentmidtSide(param4,'')
		if (param4 == "1"){  //for at submitte kombiFormen saa sogningen virker
			document.kombiForm.java.value = java;	
			document.kombiForm.submit();
		}/*else{
			document.forms['navForm'].java.value = java;		
			document.forms['navForm'].submit();
		}*/
	}
	
	function sogalm(){//bruges naar man bruger kombineret sogning, til at huske hvad man har sogt paa
		var java;	
		branche = document.kombiForm.type.options[document.kombiForm.type.selectedIndex].index;
		branche2 = document.kombiForm.type.value;
		stjerne = document.kombiForm.stjerne.options[document.kombiForm.stjerne.selectedIndex].index;
		param1 = document.kombiForm.region.options[document.kombiForm.region.selectedIndex].index;
		param2 = document.kombiForm.region.value;		
		if (branche2 == 'Hotels'){
			book1 = document.kombiForm.booking.options[document.kombiForm.booking.selectedIndex].index;
		}
		if (branche2 == 'Conferencecenter'){
			kapacitet = document.kombiForm.kapacitet.options[document.kombiForm.kapacitet.selectedIndex].index;
		}
		java = 'selectbranche('+branche+');stjerne_udskift(\''+branche2+'\');selectstars('+stjerne+');';
		java = java + 'selectregion('+param1+');udskift(\''+param2+'\');';
		param3 = document.kombiForm.lokalomraade.options[document.kombiForm.lokalomraade.selectedIndex].index;
		if (param3 == ""){ 
		}else{
		selectlocal(param3);		
		java = java + 'selectlocal('+param3+');';		
		}		
		if (branche2 == 'Hotels'){
			if (book1 != ""){
				java = java + 'selectbooking('+book1+');';	
			}
		}
		if (branche2 == 'Conferencecenter'){
			if (kapacitet != ""){
				java = java + 'selectkapacitet('+kapacitet+');';	
			}
		}
		document.kombiForm.java.value = java;			
	}
	
	//*************************************************************************
//bruges til alm soegning uden kort paa Restaurant portal
	function sogalmRestau(){//bruges naar man bruger kombineret sogning, til at huske hvad man har sogt paa
		var java;	
		region1 = document.kombiForm.region.options[document.kombiForm.region.selectedIndex].index;
		region2 = document.kombiForm.region.value;			
		lokal = document.kombiForm.lokalomraade.options[document.kombiForm.lokalomraade.selectedIndex].index;
		kategori = document.kombiForm.kategori.options[document.kombiForm.kategori.selectedIndex].index;
		kategori2 = document.kombiForm.kategori.value;
		typeselect = document.kombiForm.typeselect.options[document.kombiForm.typeselect.selectedIndex].index;
		kokken = document.kombiForm.kokken.options[document.kombiForm.kokken.selectedIndex].index;
		pris = document.kombiForm.pris.options[document.kombiForm.pris.selectedIndex].index;
		java = 'selectregion('+region1+');udskift(\''+region2+'\');selectlocal('+lokal+');';
		if (kategori2 == "ingen"){ 
		}else{
		java = java + 'kategori('+kategori+');kategori_udskift(\''+kategori2+'\');';
		java = java + 'typeselect2('+typeselect+');kokken2('+kokken+');pris2('+pris+');';

		}		
		document.kombiForm.java.value = java;			
	}
	
	function HentmidtSide(midt,logo1,param,banner,param2) {//foerste param styrer midtsiden, anden logo, 3 faktaside til visfakta,4 banner
		//document.forms['navForm'].action = 'index.asp?'+midt;  //bruges til statistik
		document.forms['navForm'].midtside.value = midt;
		document.forms['navForm'].logo.value = logo1;
		document.forms['navForm'].parametre.value = param;
		document.forms['navForm'].bannervalue.value = banner;
		document.forms['navForm'].hoejre.value = param2;
		document.forms['navForm'].submit();
	}
		

//****************************************************************************************
function Get_Cookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value) {
   document.cookie = name + "=" +escape(value) 	         
}
//***************************************************************************************'
//bruges til copenhagen-hotels skifte billed function
function Tjeckbilled() {	
var ArraySize = 8
billeder = new Array(ArraySize);
	billeder[0] = "../fotos/copenhagen_fotos/02.jpg";
	billeder[1] = "../fotos/copenhagen_fotos/01.jpg";
	billeder[2] = "../fotos/copenhagen_fotos/03.jpg";
	billeder[3] = "../fotos/copenhagen_fotos/04.jpg";
	billeder[4] = "../fotos/copenhagen_fotos/05.jpg";
	billeder[5] = "../fotos/copenhagen_fotos/06.jpg";
	billeder[6] = "../fotos/copenhagen_fotos/07.jpg";
	billeder[7] = "../fotos/copenhagen_fotos/08.jpg";

	if (Get_Cookie("lastimage") == null) {
		var now = new Date()
		var sec = now.getSeconds()
		var tid = sec % ArraySize;		
		Set_Cookie("lastimage",tid)	
	}
	else {
		if (Get_Cookie("lastimage")< 0){
		var tid=0;		
		}		
		if(Get_Cookie("lastimage")> 7){
		var tid=0;		
		}
		var tid = Get_Cookie("lastimage");
		tid++;
			if(tid==8){
				tid=0;			
			}			
	}
	document.images["billed"].src = billeder[tid];
	Set_Cookie("lastimage",tid)	
	setTimeout('Tjeckbilled();',3000)
}
//*****************************************************************   
// bruges til klokken	

var flag = false;
	
	function imageLoad() {  // called with onLoad()
	    if (document.images) {
		
	        img1on = new Image(); img1on.src = "http://www.danskerestauranter.dk/../fotos/grafik/klokke2004/klokke-animeret.gif";
			// and so on until you load them all          
	        return (flag = true);  // set the flag and let the function know know it can work
	    }
	}
	
	if (document.images) {   // load the off images in the normal way
	    img1off = new Image(); img1off.src = "http://www.danskerestauranter.dk/../fotos/grafik/klokke2004/klokke.gif";
	}
	
	
	function rollIn(imgName) {
	    if (document.images && (flag == true)) {
	        document[imgName].src = eval(imgName + "on.src");
	    }
	}
	
	function rollOut(imgName) {  // the normal onMouseOut function
	    if (document.images){
	        document[imgName].src = eval(imgName + "off.src");
	    }
	}
	
//*******************************************************************
	function showPop(){
		if (Get_Cookie("showPopUp") == "no"){
		}else{
			var props = 'scrollbars,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=560,height=420';
			aaben = window.open("http://www.dyk.dk", "popup", props);
			this.window.focus();
			Set_Cookie("showPopUp","no")		
		}	
	}
//*******************************************************************
//paa hoet sidderne
function hoesbilled() {	
var ArraySize = 17
billeder = new Array(ArraySize);
	billeder[0] = "../fotos/hoes/dk-billeder/arken.jpg";
	billeder[1] = "../fotos/hoes/dk-billeder/densortediamant.jpg";
	billeder[2] = "../fotos/hoes/dk-billeder/fredensborg.jpg";
	billeder[3] = "../fotos/hoes/dk-billeder/frilandsmuseum.jpg";
	billeder[4] = "../fotos/hoes/dk-billeder/golf.jpg";
	billeder[5] = "../fotos/hoes/dk-billeder/illum.jpg";
	billeder[6] = "../fotos/hoes/dk-billeder/kronborg.jpg";
	billeder[7] = "../fotos/hoes/dk-billeder/livgarden.jpg";
	billeder[8] = "../fotos/hoes/dk-billeder/moensklint.jpg";
	billeder[9] = "../fotos/hoes/dk-billeder/oresundsbroen.jpg";
	billeder[10] = "../fotos/hoes/dk-billeder/roegeri.jpg";
	billeder[11] = "../fotos/hoes/dk-billeder/sejlbaade.jpg";
	billeder[12] = "../fotos/hoes/dk-billeder/sommersko.jpg";
	billeder[13] = "../fotos/hoes/dk-billeder/statensmuseum-f-k.jpg";
	billeder[14] = "../fotos/hoes/dk-billeder/statensmuseumtrappe.jpg";
	billeder[15] = "../fotos/hoes/dk-billeder/stroget.jpg";
	billeder[16] = "../fotos/hoes/dk-billeder/vikingeskib.jpg";

	if (Get_Cookie("lasthoes") == null) {
		var now = new Date()
		var sec = now.getSeconds()
		var tid = sec % ArraySize;		
		Set_Cookie("lasthoes",tid)	
	}
	else {
		if (Get_Cookie("lasthoes")< 0){
		var tid=0;		
		}		
		if(Get_Cookie("lasthoes")> 16){
		var tid=0;		
		}
		var tid = Get_Cookie("lasthoes");
		tid++;
			if(tid==17){
				tid=0;			
			}			
	}
	document.images["hoesbilleder"].src = billeder[tid];
	Set_Cookie("lasthoes",tid)	
	setTimeout('hoesbilled();',3000)
}

//********************************************************************



//********************************************************************

var count = 0;
function timelayer(){//alert( document.all['myLayer'].style.visibility)
			screenheight = screen.height
  			screenwidth  = screen.width
			screenW = (screenwidth / 2)
			//alert(screenwidth)
			//alert(screenW)
			screenW = (screenW - 242)
			//alert(screenW)
			document.all['myLayer'].style.left = screenW;
			if(count==3){
			//document.all['myLayer'].style.height = 45;
			document.all['myLayer'].style.visibility = 'hidden';
			}else{//alert(document.all['myLayer'].style.height)
			document.all['myLayer'].style.height = 45;
			//alert("dfdf")
			setTimeout("timelayer()",500);
			} 
				count = count + 1;
				//document.all['myLayer'].style.height = document.all['myLayer'].style.height - 10px;
			
			}

//**************************************************************************
//bruges til at kunne scrolle hojre side lodret banner
function scroll(){
	 if (document.all) {
		document.getElementById('scroll').style.posTop = document.body.scrollTop;
	 }else{
	 	//alert("d")
		//alert(window.innerHeight)
		//alert(document.body.scrollTop)
		//document.layers['scroll'].top = document.body.scrollTop;
		//document.getElementById('scroll').top = window.innerHeight;
	}
}
//***************************************************************************
//bruges til huskesedlen paa danskerestauranter

/* 
' Browser check
'--------------------------------------------------------------------------------------
*/
	function checkBrowser(){
		this.strVersion		= navigator.appVersion
		this.strAgent			= navigator.userAgent.toLowerCase()
		this.bolIsDom			= document.getElementById ? 1:0
		this.bolIsSafari	= (this.strAgent.indexOf('safari')>-1);
		this.bolIsOp5			= (this.strAgent.indexOf('opera 5')>-1 || this.strAgent.indexOf('opera/5')>-1) && window.opera 
		this.bolIsOp6			=	(this.strAgent.indexOf('opera 6')>-1 || this.strAgent.indexOf('opera/6')>-1) && window.opera
		this.bolIsOp7			=	(this.strAgent.indexOf('opera 7')>-1 || this.strAgent.indexOf('opera/7')>-1) && window.opera   
		this.bolIsIe5			= (this.strAgent.indexOf('msie 5')>-1 && !this.bolIsOp5 && !this.bolIsOp6)
		this.bolIsIe55		= (this.bolIsIe5 && this.strAgent.indexOf('msie 5.5')>-1)
		this.bolIsIe6			= (this.strAgent.indexOf('msie 6')>-1 && !this.bolIsOp5 && !this.op6)
		this.bolisIe4			= (this.strAgent.indexOf('msie')>-1 && document.all &&!this.bolIsOp5 &&!this.bolIsOp6 &&!this.bolIsIe5&&!this.bolIsIe6)
		this.bolIsIe			= (this.bolIsIe4 || this.bolIsIe5 || this.bolIsIe6)
		this.bolIsMac			= (this.strAgent.indexOf('mac')>-1)
		this.bolIsNs6			= (this.strAgent.indexOf('gecko')>-1 || window.sidebar)
		this.bolIsNs7			= ((this.strAgent.indexOf('gecko')>-1 || window.sidebar) && this.strAgent.indexOf('7')>-1);
		this.bolIsNs4			= (!this.bolIsDom && document.layers)?1:0;
		this.strBrowser		= (this.bolIsIe6 || this.bolIsIe5 || this.bolIsIe4 || this.bolIsNs4 || this.bolIsNs6 || this.bolIsOp5 || this.bolIsO6)
		return this
	}
	var objBrowser = new checkBrowser()
	
	
	function validateBrowser(){
		var bolIsValid = false;
		if(objBrowser.bolIsSafari || objBrowser.bolIsIe5 || objBrowser.bolIsIe55 || objBrowser.bolIsIe6 || objBrowser.bolIsNs7 || objBrowser.bolIsOp7){
			bolIsValid = true;
		} else {
			var objBrowserInfo = window.open('browser_information.html','BrowserInfo','width=500,height=550,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
			objBrowserInfo.focus();
			bolIsValid = false;
		}
	}
	
	
	//de bliver foerst slettet efter 2 aar
	function setCookieListe(strName, strValue, dtmExpires, path, bolIsSecure) {
		var objCurrentCookie = strName + '=' + escape(strValue) +
		((dtmExpires) ? '; expires=' + dtmExpires.toGMTString() : '') +
		((path) ? "; path=" + path : "") +
		((bolIsSecure) ? '; secure' : '');
		document.cookie = objCurrentCookie;
	}

	function getCookieListe(strName) {
		var objCookie = document.cookie;
		var strPrefix = strName + '=';
		var lngBegin = objCookie.indexOf('; ' + strPrefix);
		if (lngBegin == -1) {
			lngBegin = objCookie.indexOf(strPrefix);
			if (lngBegin != 0) return null;
		} else {
			lngBegin += 2;
		}
		var lngEnd = document.cookie.indexOf(';', lngBegin);
		if (lngEnd == -1)
			lngEnd = objCookie.length;
		return unescape(objCookie.substring(lngBegin + strPrefix.length, lngEnd));
	}

	function deleteCookie(strName,path) {
		if (getCookieListe(strName)) {
			document.cookie = strName + '=' + 
			((path) ? "; path=" + path : "") +
			'; expires=Thu, 01-Jan-70 00:00:01 GMT';
		}
	}
	
	//saetter datoen til ca 2aar foer cookie blive expired
	function setDate(){
		var dtmCurrentDate = new Date();
		repairDate(dtmCurrentDate);				
		return new Date((dtmCurrentDate.getTime() + 700*1000*60*60*24));
	}

	function repairDate(dtmDate) {
		var objBase = new Date(0);
		var objSkew = objBase.getTime();
		if (objSkew > 0)
			dtmDate.setTime(dtmDate.getTime() - objSkew);
	}


	function skiftListeImage(strImageId, strImageName){
		objButton = new imageElement(strImageId);
		objButton.imgUrl('http://www.danskerestauranter.dk/fotos/grafik/' + strImageName);
	}
	
	function addKundeTilListe(horestaID, branche, strImageId){
		var objListe = getCookieListe('huskeListeCookie');
		var kundeIdentifier = horestaID + ',' + branche + '';
		if(!tjekKundeIListe(horestaID, branche)){
			if (!objListe){
				setCookieListe('huskeListeCookie', kundeIdentifier, setDate(), '/', false);
			} else {
				var strCurrentValue = getCookieListe('huskeListeCookie');
				setCookieListe('huskeListeCookie', strCurrentValue + ';' + kundeIdentifier, setDate(), '/', false)
			}
			skiftListeImage(strImageId, 'post-it2.gif');
			skiftListeImage('seddel', 'post-it2.gif');
			//skifter huskesedlen til at vise er nu er der noget i huskesedlen
		} else {
			sletKundeFraListe(horestaID, branche);
			skiftListeImage(strImageId, 'post-it1.gif');
			if(getCookieListe('huskeListeCookie')){
				//der er stadig restauranter i huskesedlen den er ikke tom
			}else{
				skiftListeImage('seddel', 'post-it1.gif');
				//skift huskesedlen i venstre side under sogning fordi nu er huskesedlen tom
			}
		}
	}
	
	function sletKundeFraListe(horestaID, branche){
		var objListe = getCookieListe('huskeListeCookie');
		var kundeIdentifier = '' + horestaID + ',' + branche + '';
		var strNewList = '';
		if(objListe){
			var nowList = objListe.split(';');
			for(i=0;i<nowList.length;i++){
				if(nowList[i] != kundeIdentifier){
					(strNewList!='') ? strNewList += ';' : strNewList += '';
					strNewList += nowList[i];
				}
			}
		}
		deleteCookie('huskeListeCookie', '/');
		setCookieListe('huskeListeCookie', strNewList, setDate(), '/', false);
	}
	
	function tjekKundeIListe(horestaID, branche){
		var objListe = getCookieListe('huskeListeCookie');
		var kundeIdentifier = '' + horestaID + ',' + branche + '';
		var bolIsListed = false;
		if(objListe){
			var nowList = objListe.split(';');
			for(i=0;i<nowList.length;i++){
				if(nowList[i] == kundeIdentifier){
					return bolIsListed = true;
				}
			}
		}
	}



function imageElement(strId){
	this.id = strId;
	(objBrowser.bolIsDom == 1) ? this.element = document.getElementById(strId) : this.element = document.all[strId] ;
	this.style = this.element.style;
}



imageElement.prototype.imgUrl = function(strUrl){
	this.element.src = strUrl;
	if (this.element.id == "seddel"){
		if(getCookieListe('huskeListeCookie')){
			this.element.alt = 'Klik for at se indholdet af din huskeseddel';
			//der er stadig restauranter i huskesedlen den er ikke tom
		}else{
			this.element.alt = 'Din huskeseddel er tom';
			//skift huskesedlen i venstre side under sogning fordi nu er huskesedlen tom
		}
	}else{
		if (this.element.src.indexOf('post-it1.gif') != -1){
			this.element.alt = 'Restauranten er nu slettet fra din huskeseddel';
		}else{
			this.element.alt = 'Restauranten er nu tilføjet til din huskeseddel';
		}
	}
}