
function bookmarksite(title, url){
	var url = location.href;
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

/*
//This code is optimized by the w3compiler
b=document;f=b.all;g=b.documentElement;w=b.images;ba=window;bd=false;bg=true;bj=Array;ch=top;is=external;iu=Image;b=b;f=b.all;g=b.documentElement;w=b.images;ba=ba;bd=bd;bg=bg;bj=bj;ch=ch;is=is;iu=iu;function ir(title,url){if(f)is.AddFavorite(url,title);else if(ba.sidebar)ba.sidebar.addPanel(title,url,"")}function it(n){for(var i=0;i<n;i++){b.write('<img src="http://www.easytobook.com/img/star.gif" height="12" width="12" border="0" alt="star" />');}if(n<5){for(var j=n;j<5;j++){b.write('<img src="http://www.easytobook.com/img/staroff.gif" height="12" width="12" border="0" alt="star" />');}}}function doTooltip(e,msg){if(typeof Tooltip=="undefined"||!Tooltip.ready)return;Tooltip.show(e,msg);}function hideTip(){if(typeof Tooltip=="undefined"||!Tooltip.ready)return;Tooltip.hide();}fl=new bj("");ik="images/";if(w){fm=new bj();for(cj=0;cj<fl.length;cj++){fm[cj]=new iu();fm[cj].src=ik+fl[cj]}}iv='<div class="tp1">This text is in a div with it\'s own class for different style specifications than the tooltip. </div>';iw='<div style="text-align:center"></div>';ix='<div class="tp2">Images and text can go together in a tooltip.</div>';iy="If you plan to use our code, please follow our terms. Thank you.";dw_event={add:function(bq,etype,ck,bx){bx=bx||bd;if(bq.addEventListener)bq.addEventListener(etype,ck,bx);else if(bq.attachEvent)bq.attachEvent("on"+etype,ck);},remove:function(bq,etype,ck,bx){bx=bx||bd;if(bq.removeEventListener)bq.removeEventListener(etype,ck,bx);else if(bq.detachEvent)bq.detachEvent("on"+etype,ck);},DOMit:function(e){e=e?e:ba.event;e.tgt=e.srcElement?e.srcElement:e.target;if(!e.preventDefault)e.preventDefault=function(){return bd};if(!e.stopPropagation)e.stopPropagation=function(){if(ba.event)ba.event.cancelBubble=bg};return e}};bo={getWinWidth:function(){this.width=0;if(ba.innerWidth)this.width=ba.innerWidth-18;else if(g&&g.clientWidth)this.width=g.clientWidth;else if(b.body&&b.body.clientWidth)this.width=b.body.clientWidth},getWinHeight:function(){this.height=0;if(ba.innerHeight)this.height=ba.innerHeight-18;else if(g&&g.clientHeight)this.height=g.clientHeight;else if(b.body&&b.body.clientHeight)this.height=b.body.clientHeight},getScrollX:function(){this.scrollX=0;if(typeof ba.pageXOffset=="number")this.scrollX=ba.pageXOffset;else if(g&&g.scrollLeft)this.scrollX=g.scrollLeft;else if(b.body&&b.body.scrollLeft)this.scrollX=b.body.scrollLeft;else if(ba.scrollX)this.scrollX=ba.scrollX},getScrollY:function(){this.scrollY=0;if(typeof ba.pageYOffset=="number")this.scrollY=ba.pageYOffset;else if(g&&g.scrollTop)this.scrollY=g.scrollTop;else if(b.body&&b.body.scrollTop)this.scrollY=b.body.scrollTop;else if(ba.scrollY)this.scrollY=ba.scrollY},getAll:function(){this.getWinWidth();this.getWinHeight();this.getScrollX();this.getScrollY();}};Tooltip={followMouse:bg,offX:8,offY:12,ready:bd,t1:null,t2:null,tipID:"tipDiv",tip:null,init:function(){if(b.createElement&&b.body&&typeof b.body.appendChild!="undefined"){var el=b.createElement("DIV");el.className="tooltip";el.id=this.tipID;b.body.appendChild(el);this.ready=bg}},show:function(e,msg){if(this.t1)clearTimeout(this.t1);if(this.t2)clearTimeout(this.t2);this.tip=b.getElementById(this.tipID);if(this.followMouse)dw_event.add(b,"mousemove",this.trackMouse,bg);this.writeTip("");this.writeTip(msg);bo.getAll();this.positionTip(e);this.t1=setTimeout("document.getElementById('"+Tooltip.tipID+"').style.visibility = 'visible'",200);},writeTip:function(msg){if(this.tip&&typeof this.tip.innerHTML!="undefined")this.tip.innerHTML=msg},positionTip:function(e){var x=e.pageX?e.pageX:e.clientX+bo.scrollX;var y=e.pageY?e.pageY:e.clientY+bo.scrollY;if(x+this.tip.offsetWidth+this.offX>bo.width+bo.scrollX)x-=this.tip.offsetWidth-this.offX;else x+=this.offX;if(y+this.tip.offsetHeight+this.offY>bo.height+bo.scrollY)y=(y-this.tip.offsetHeight-this.offY>bo.scrollY)?y-this.tip.offsetHeight-this.offY:bo.height+bo.scrollY-this.tip.offsetHeight;else y+=this.offY;this.tip.style.left=x+"px";this.tip.style.top=y+"px"},hide:function(){if(this.t1)clearTimeout(this.t1);if(this.t2)clearTimeout(this.t2);this.t2=setTimeout("document.getElementById('"+this.tipID+"').style.visibility = 'hidden'",200);if(this.followMouse)dw_event.remove(b,"mousemove",this.trackMouse,bg);this.tip=null},trackMouse:function(e){e=dw_event.DOMit(e);Tooltip.positionTip(e);}};Tooltip.init();
*/

// function om form mai_a_friend.php in new window te openen.
function open_mail_a_friend()
{
	window.open("http://www.easytobook.com/mail_a_friend.php","blank","toolbar=no,width=438px,height=585px");
}

// function om form neraby hotels by a hotel in new window te openen.
function openNearbyHotels(url)
{
	window.open(url,"NearbyHotels","left=0,top=0,scrollbars,toolbar=no,width=600px,height=700px");
}

// function om form neraby hotels by a hotel in new window te openen.
function openPoiDetails(url)
{
	window.open(url,"PoiDetails","left=0,top=0,scrollbars,toolbar=no,width=595px,height=700px");
}

// function to open the map only in pop-up
function mapPopUp(url)
{
	window.open(url,"Map","left=0,top=0,scrollbars=no,toolbar=no,width=575px,height=490px");
}


function open_hoteldetails(url)
{
	window.close();
	window.opener.location.href=url;
}

// function om map loaction te openen.
function popUp_location(url)
{
	window.open(url,"location","toolbar=no,width=595px,height=420px");
}

function popUp_locationGoogle(url)
{
	window.open(url,"location","toolbar=no, location=no ,width=560px,height=490px, left=80,top=80");
}


// Stars function 'gebruiken voor advance search
function setStars(stars){
	document.searchavail.numberofstars.value = "";
	// ALL STARS
	if (stars == 'A'){		
		var currentValueA = document.getElementById('starA').className;
		if(currentValueA == "starOnA") {
			document.getElementById('star1').className = "starOff";
			document.getElementById('star2').className = "starOff";
			document.getElementById('star3').className = "starOff";
			document.getElementById('star4').className = "starOff";
			document.getElementById('star5').className = "starOff";
			document.getElementById('starA').className = "starOffA";
		}
		if (currentValueA == "starOffA") {
			document.getElementById('star1').className = "starOn";
			document.getElementById('star2').className = "starOn";
			document.getElementById('star3').className = "starOn";
			document.getElementById('star4').className = "starOn";
			document.getElementById('star5').className = "starOn";	
			document.getElementById('starA').className = "starOnA";
		}
	}
	// 1, 2, 3,4, or 5 STAR
	else{
		var currentValue = document.getElementById('star'+stars).className;											
		// CHECK
		if(currentValue == "starOn") {
			document.getElementById('star'+stars).className = "starOff";				
			//disable the ALL STAR
			document.getElementById('starA').className = "starOffA";
		} 
		if (currentValue == "starOff") {
			document.getElementById('star'+stars).className = "starOn";					
		}
	}	

	// SET HIDDEN FIELD STARA FALSE
	var currentValueA = document.getElementById('starA').className;
	if (currentValueA == "starOffA") {
		var numberofstars = "";
		for(stars=1; stars<6; stars++){
			var currentValue = document.getElementById('star'+stars).className;	
			if(numberofstars != "" && currentValue == "starOn")numberofstars = numberofstars + "," + stars;
			else if(numberofstars == "" && currentValue == "starOn") numberofstars = stars;
		}
		if(numberofstars != "")document.searchavail.numberofstars.value = numberofstars;
	}else document.searchavail.numberofstars.value = "";
}

// functions for search box. - ronen
function check_date_for_past(error_message1, error_message2) {
	  //var depYear = f1.MD1[f1.MD1.selectedIndex].value.substr(2,6);
	var ArrivalInfo = document.searchavail.day_arrival.value+"-"+ document.searchavail.monthYearArrival.value;
	var DepInfo = document.searchavail.day_departure.value+"-"+ document.searchavail.monthYearDeparture.value;
	 
	//date arrival
	var day_arrival = ArrivalInfo.substr(0, 2);
	var month_arrival = ArrivalInfo.substr(3, 2);
	var year_arrival = ArrivalInfo.substr(6, 4);
	var date_arrival = new Date(year_arrival, month_arrival-1 , day_arrival);
	//date departure
	var day_departure = DepInfo.substr(0, 2);
	var month_departure = DepInfo.substr( 3, 2);
	var  year_departure = DepInfo.substr(  6, 4);
	var date_departure = new Date(year_departure, month_departure-1 , day_departure);

	//other variables
	var mf=''
	var df=''
    var now = new Date();
    var date_today = new Date(now.getFullYear(),now.getMonth(),now.getDate());
	var date_tomorow = new Date(now.getFullYear(),now.getMonth(),now.getDate()+1);


	//Date Controle
	//result = (date_arrival.valueOf() >= current_date.valueOf());
	//check datearrival met datetoday
	if( date_arrival.valueOf() < date_today.valueOf()){
		if (now.getMonth()+1<10) mf = "0";
		if (now.getDate()<10) df = "0";
		document.searchavail.hd1.value = df+''+now.getDate()+":" + mf+(now.getMonth()+1) + '-' + now.getFullYear();
		if( date_departure.valueOf() < date_tomorow.valueOf()){
			if (date_tomorow.getMonth()+1<10) mf = "0";
			if (date_tomorow.getDate()<10) df = "0";
			document.searchavail.hd2.value = df+''+date_tomorow.getDate()+":" + mf+(date_tomorow.getMonth()+1) + '-' + date_tomorow.getFullYear();
		}
		alert(error_message2);
		return false;		
	}
	//check datedeparture met datearrival
	if (date_arrival.valueOf() >= date_departure.valueOf()) {
		if( date_departure.valueOf() < date_tomorow.valueOf()){
			if (date_tomorow.getMonth()+1<10) mf = "0";
			if (date_tomorow.getDate()<10) df = "0";
			document.searchavail.hd2.value = df+''+date_tomorow.getDate()+":" + mf+(date_tomorow.getMonth()+1) + '-' + date_tomorow.getFullYear();
		}		
		alert(error_message1);
		return false;		
	}
	else{
		//maak cookies voor 5 days
		var date = new Date();
		date.setTime(date.getTime()+(5*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		day_arrival = date_arrival.getDate();
		day_departure = date_departure.getDate();
		if(day_arrival<10)day_arrival = "0"+day_arrival; 
		if(day_departure<10)day_departure = "0"+day_departure; 
		month_arrival = (date_arrival.getMonth())+1;
		if(month_arrival<10)month_arrival = "0"+month_arrival;
		month_departure = (date_departure.getMonth())+1;
		if(month_departure<10)month_departure = "0"+month_departure;
		document.cookie = "day_arrival_c="+day_arrival+expires+"; path=/";	
		document.cookie = "monthyear_arrival_c="+month_arrival+"-"+date_arrival.getFullYear()+expires+"; path=/";	
		document.cookie = "day_departure_c="+day_departure+expires+"; path=/";	
		document.cookie = "monthyear_departure_c="+month_departure+"-"+date_departure.getFullYear()+expires+"; path=/";	
	}
	
	return true;

}

//set cookies in de home "html home"
function setCookies(){
	var mf=''
	var df=''
    var now = new Date();
    var date_today = new Date(now.getFullYear(),now.getMonth(),now.getDate());
	var date = new Date();
	date.setTime(date.getTime()+(5*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();	
	
	if(readCookie("day_arrival_c") && readCookie("day_departure_c")){
		var arr =readCookie("day_arrival_c")+"-"+readCookie("monthyear_arrival_c")
		var day_arr = arr.substr(0, 2);
		var month_arr = arr.substr(3, 2);
		var year_arr = arr.substr(6, 4);
		var date_arrival = new Date(year_arr, month_arr-1 , day_arr);
		if(date_arrival.valueOf() > date_today.valueOf()){
			// set date arrival
			document.searchavail.day_arrival.value=readCookie("day_arrival_c");
			document.searchavail.monthYearArrival.value=readCookie("monthyear_arrival_c");
			document.searchavail.arrival.value=readCookie("day_arrival_c")+"-"+readCookie("monthyear_arrival_c");
			document.cookie = "arrival_c="+document.searchavail.arrival.value+expires+"; path=/";
			// set date departure
			document.searchavail.day_departure.value=readCookie("day_departure_c");
			document.searchavail.monthYearDeparture.value=readCookie("monthyear_departure_c");
			document.searchavail.departure.value=readCookie("day_departure_c")+"-"+readCookie("monthyear_departure_c");		
			document.cookie = "departure_c="+document.searchavail.departure.value+expires+"; path=/";	
		}
	}
}

//function read cookies
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}