var now=new Date();var dayString=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var curArea;function startUp(){fillYear();var defCountry="0";var defArea="6";var setParams=false;try{ if(location.search!="") {  var ls=location.search.substring(1);  var spl=ls.split("&");  for(var i=0;i<spl.length;i++)  {   var s=spl[i].split("=");   if(s[0]=="country"){defCountry=s[1];}   if(s[0]=="area"){defArea=s[1];}  }  setParams=true; }}catch(e){}var ck=readCookie("country");if(ck==null || setParams==true){ fillMonth(); fillDate(); getElem("country").value=defCountry; getAreas(parseInt(defCountry)); getElem("area").value=defArea; getElem("duration").value="7";  getElem("people").value="2";}else{ try{  getElem("country").value=ck;  getAreas(parseInt(ck));  getElem("area").value=readCookie("area");  getElem("startyear").value=readCookie("startyear");  fillMonth();  getElem("startmonth").value=readCookie("startmonth");  fillDate();  getElem("startdate").value=readCookie("startdate");  getElem("people").value=readCookie("people");  getElem("duration").value=readCookie("duration");  getElem("pets").value=readCookie("pets");  if(getElem("pets").value==""){getElem("pets").selectedIndex=0;} }catch(e){}}showLocation();}function checkSearch(){var sdt=new Date(parseInt(getElem("startyear").value),parseInt(getElem("startmonth").value),parseInt(getElem("startdate").value));if(new Date().getTime()>sdt.getTime()){ alert("The start date is either in the past or today!"); return;}document.osc.rand.value=Math.random();try{ var ca=parseInt(getElem("area").value); var cc=parseInt(getElem("country").value); if(ca==0) {  document.osc.areaname.value=escape(document.osc.country.options[cc].text); }else{  document.osc.areaname.value=escape(curArea[ca][0]); } createCookie("country",getElem("country").value,7); createCookie("area",getElem("area").value,7); createCookie("startdate",getElem("startdate").value,7); createCookie("startmonth",getElem("startmonth").value,7); createCookie("startyear",getElem("startyear").value,7); createCookie("people",getElem("people").value,7); createCookie("duration",getElem("duration").value,7); createCookie("pets",getElem("pets").value,7);}catch(e){}document.osc.submit();}function fillYear(){var s="<select name='startyear' id='startyear' onchange='fillDate();'>";var yr=now.getFullYear();s+="<option value='"+yr+"'>"+yr+"</option>";s+="<option value='"+(yr+1)+"'>"+(yr+1)+"</option>";s+="</select>";getElem("startyeardiv").innerHTML=s;}function fillMonth(){var mn=now.getMonth()+1;if(mn==12){mn=11;}getElem("startmonth").selectedIndex=mn;}function fillDate(){var curday;if(getElem("startdate")!=null){ curday=getElem("startdate").selectedIndex;}var dt=new Date(parseInt(getElem("startyear").value),parseInt(getElem("startmonth").value));var s="<select name='startdate' id='startdate' onchange='checkMidWeek();'>";var dm=getDayValues(dt.getFullYear());for(var i=1;i<=dm[dt.getMonth()];i++){ dt.setDate(i); s+="<option value='"+i+"'>"+i+"&nbsp;&nbsp;"+dayString[dt.getDay()]+"</option>"; if(curday==null && dt.getDay()==6){curday=(i-1);} }s+="</select>";getElem("startdatediv").innerHTML=s;getElem("startdate").selectedIndex=curday;}function getDayValues(year){var daysofmonth   = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];var daysofmonthLY = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if((year/4)!=Math.floor(year/4)){return daysofmonth;}if((year/100)!=Math.floor(year/100)){return daysofmonthLY;}if((year/400)!=Math.floor(year/400)){return daysofmonth;}return daysofmonthLY;}function checkMidWeek(){var cmid=getElem("midweekwarning");if(cmid==null){return;}var dt=new Date(parseInt(getElem("startyear").value),parseInt(getElem("startmonth").value),parseInt(getElem("startdate").value));if(dt.getDay()<5){ cmid.innerHTML="Tip: Most holiday rents start on a Friday or Saturday.";}else{ cmid.innerHTML="";}}function getAreas(inarea){eval("areaInfo_"+inarea+"();");fillArea();showLocation();}function fillArea(){var s="<select name='area' id='area' onchange='showLocation();'>";for(var i=0;i<curArea.length;i++){ s+="<option value='"+i+"'>"+curArea[i][0]+"</option>";}s+="</select>";getElem("areadiv").innerHTML=s;}function getElem(inid){return document.getElementById(inid);}function showLocation(){var idx=parseInt(getElem("area").value);var plc=curArea[idx];var mm=getElem("mapmarker");if(mm==null){return;}mm.style.left=(plc[1]-6)+"px";mm.style.top=(plc[2]-6)+"px";mm.title=plc[0];if(idx==0){ mm.src="images/countrymarker.png";}else{ mm.src="images/marker.png";}}function setMapLocation(pic,evt){var x;var y;if(window.event==null){ x=x=evt.layerX; y=y=evt.layerY;}else{ x=window.event.x-pic.offsetLeft; y=window.event.y-pic.offsetTop+5;}var dist=-1;var cn=0;var idx=0;for(var t=0;t<5;t++){ eval("areaInfo_"+t+"();");  for(var i=1;i<curArea.length;i++) {  var plc=curArea[i];  var curdist=Math.sqrt(((plc[1]-x)*(plc[1]-x))+((plc[2]-y)*(plc[2]-y)));  if(dist==-1||curdist<dist){idx=i;cn=t;dist=curdist;} }}eval("areaInfo_"+cn+"();"); getElem("country").selectedIndex=cn;fillArea();getElem("area").selectedIndex=idx;showLocation();}function createCookie(name,value,days){var expires;if(days){ var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = ";"; expires+=date.toGMTString();}else{ expires = ";";}document.cookie = name+"="+value+expires+"; path=/";}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;}