function redirect(url){window.location.href=url;}
function depositPopup(){day=new Date();id=day.getTime();eval("page"
+id
+" = window.open('/deposit.popup.html', '"
+id
+"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 320,top = 150');");}
function bestpricePopup(){day=new Date();id=day.getTime();eval("page"
+id
+" = window.open('/bestprices.popup.html', '"
+id
+"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 320,top = 150');");}
function Popup(u,w,h){var day=new Date();var id=day.getTime();if(!w||!h){var w=840;var h=640;}
eval("page"
+id
+" = window.open('"
+u
+"', '"
+id
+"', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",left = 320,top = 150');");}
function confirmRedirect(url,message,url2){if(window.confirm(message)){redirect(url);}else if(url2){redirect(url2);}}
function showWindow(windowURL,width,height,namePrefix){if(!width){width=550;}else{width=parseInt(width);}
if(!height){height=350;}else{height=parseInt(height);}
if(!namePrefix){namePrefix='';}
var popUp=window.open(windowURL,'event_window'+namePrefix,'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width='+width+',height='+height);popUp.moveTo(screen.width/2-width/2,screen.height/2-height/2);}
function roundNumber(number,precision){if(!precision){precision=2;}
if(number>8191&&number<10485){number=number-5000;var newnumber=Math.round(number*Math.pow(10,precision))/Math.pow(10,precision);newnumber=newnumber+5000;}else{var newnumber=Math.round(number*Math.pow(10,precision))/Math.pow(10,precision);}
return newnumber;}
function arrayHasValue(needle,haystack){for(var i=0;i<haystack.length;i++){if(needle==haystack[i]){return true;}}
return false;}
function newSearchQuery(){var
searchForm=document.getElementById('search_form'),errorsDetected=false,errorList=new Array(),star=searchForm.star?searchForm.star.value:0,rooms=new Array();rooms['rooms_number']=document.getElementById('rooms[rooms_number]').value;for(var i=0;i<3;i++){var room={'adults_number':document.getElementById('rooms['+i+'][adults_number]').value,'children_number':document.getElementById('rooms['+i+'][children_number]').value,'children_ages':{'0':document.getElementById('rooms['+i+'][children_ages][0]').value,'1':document.getElementById('rooms['+i+'][children_ages][1]').value}}
rooms.push(room);}
hideErrors();city=($('#city_id').val()>0)?$('#city_id').val():null;hotel_id=$('#city_id').val()
searchForm.hotel_id?searchForm.hotel_id.value:null;JsHttpRequest.query('/search_hotels_validate'+(USE_REWRITER?'':'.php')+'?country='+country+'&site_id='+site_id,{'city':city,'hotel_id':hotel_id,'check_in':searchForm.check_in.value,'check_out':searchForm.check_out.value,'star':star,'rooms':rooms},function(result,errors){if(errors){alert(errors);document.getElementById('search_button').value="Check Availability";document.getElementById('search_button').disabled=false;alert('Error during query validation!'+errors);return;}else{if(result['city_id']>0){searchForm.search_city_id.value=result['city_id'];searchForm.submit();}else{if(result['city_list'].length>1){showCities(result['city_list']);}
showErrors(result['message_list']);document.getElementById('search_button').value="Check Availability";document.getElementById('search_button').disabled=false;}}},true);return false;}
function searchByHotelQuery(){setSearchCityId();var
searchForm=document.getElementById('search_form'),errorsDetected=false,errorList=new Array(),star=searchForm.star?searchForm.star.value:0,rooms=new Array();rooms['rooms_number']=document.getElementById('rooms[rooms_number]').value;for(var i=0;i<3;i++){var room={'adults_number':document.getElementById('rooms['+i+'][adults_number]').value,'children_number':document.getElementById('rooms['+i+'][children_number]').value,'children_ages':{'0':document.getElementById('rooms['+i+'][children_ages][0]').value,'1':document.getElementById('rooms['+i+'][children_ages][1]').value}}
rooms.push(room);}
hideErrors();document.getElementById('search_button').value="Processing query...";document.getElementById('search_button').disabled=true;JsHttpRequest.query('/search_hotels_by_name_validate'+(USE_REWRITER?'':'.php')+'?country='+country+'&site_id='+site_id,{'check_in':searchForm.check_in.value,'check_out':searchForm.check_out.value,'star':star,'rooms':rooms},function(result,errors){if(errors){alert(errors);document.getElementById('search_button').value="Check Availability";document.getElementById('search_button').disabled=false;alert('Error during query validation!'+errors);return;}
else{if(!result){searchForm.submit();}else{showErrors(result['message_list']);document.getElementById('search_button').value="Check Availability";document.getElementById('search_button').disabled=false;}}},true);return false;}
function showCities(cities){var
citiesFieldset=document.getElementById('cities_fieldset'),cityList=document.getElementById('city_list'),tmpText=new String(),pClass='';;cityList.innerHTML='';citiesFieldset.style.display='block';if(cities.length>5){pClass=' class="similar_list"';}
tmpText='<p'+pClass+'><table border="0" cellpadding="3" cellspacing="0">'
for(i in cities){tmpText+='<tr><td><input name="ready" type="radio" id="sim_'+i+'" onclick="putCityName(\''+cities[i]['temp_name']+'\')"></td><td><label for="sim_'+i+'">'+cities[i]['temp_name']+'</label></td></tr>';}
tmpText+='</table></p>';cityList.innerHTML=tmpText;}
function showErrors(errors){var
errorsTr=document.getElementById('error_list_tr'),errorList=document.getElementById('error_list');errorList.innerHTML='';errorsTr.style.display='';for(i in errors){errorList.innerHTML+='<li>'+errors[i]+'</li>';}}
function hideErrors(){var
errorsTr=document.getElementById('error_list_tr'),errorList=document.getElementById('error_list');errorList.innerHTML='';errorsTr.style.display='none';}
function addRemoveChildAgesInputs(selectTag){if(selectTag!=null&&selectTag!='')
{var roomNumber;if(selectTag.name=='rooms[0][children_number]'){roomNumber=1;}else if(selectTag.name=='rooms[1][children_number]'){roomNumber=2;}else{roomNumber=3;}
document.getElementById('room'+roomNumber+'_child1_age').style.display='none';document.getElementById('room'+roomNumber+'_child2_age').style.display='none';for(var i=1;i<=selectTag.value;i++){document.getElementById('room'+roomNumber+'_child'+i+'_age').style.display='';}}}
function addRemoveRooms(selectTag){for(var i=1;i<=selectTag.value;i++){document.getElementById('room_'+i).style.display='';}
for(var i=3;i>selectTag.value;i--){document.getElementById('room_'+(i)).style.display='none';document.getElementById('rooms['+(i-1)+'][children_number]').value=0;addRemoveChildAgesInputs(document.getElementById('rooms['+(i-1)+'][children_number]'));}}
function hotelprofile_addRemoveRooms(selectTag){for(var i=1;i<=selectTag.value;i++){document.getElementById('hotelprofile_room_'+i).style.display='';}
for(var i=3;i>selectTag.value;i--){document.getElementById('hotelprofile_room_'+(i)).style.display='none';document.getElementById('hotelprofile_rooms['+(i-1)+'][children_number]').value=0;addRemoveChildAgesInputs(document.getElementById('hotelprofile_rooms['+(i-1)+'][children_number]'));}}
function hotelprofile_addRemoveChildAgesInputs(selectTag){if(selectTag!=null&&selectTag!='')
{var roomNumber;if(selectTag.name=='rooms[0][children_number]'){roomNumber=1;}else if(selectTag.name=='rooms[1][children_number]'){roomNumber=2;}else{roomNumber=3;}
document.getElementById('hotelprofile_room'+roomNumber+'_child1_age').style.display='none';document.getElementById('hotelprofile_room'+roomNumber+'_child2_age').style.display='none';for(var i=1;i<=selectTag.value;i++){document.getElementById('hotelprofile_room'+roomNumber+'_child'+i+'_age').style.display='';}}}
function areaSuggest(){searchForm=document.getElementById('search_form');if(searchForm.last_city_id.value!=document.getElementById('city_id').value){searchForm.last_city_id.value=document.getElementById('city_id').value;var searchForm=document.getElementById('search_form');JsHttpRequest.query('/suggest_area'+(USE_REWRITER?'':'.php')+'?site_id='+site_id,{'city':document.getElementById('city_id').value},function(result,errors){if(errors){alert('Error '+errors);return;}
else{var areaList=eval("("+result['area_list']+")");showAreaList('city_area_id',areaList);document.getElementById('city_area_id_display').style.display='';}},true);}}
function showAreaList(documentId,areaList){var objSel=document.getElementById(documentId);objSel.options.length=0;objSel.options[0]=new Option('-- All --',0);for(i in areaList){objSel.options[objSel.options.length]=new Option(areaList[i],i);}}
function citySuggest(){var oTextbox=new AutoSuggestControl(document.getElementById('city_id'),new CitySuggestions());}
function CitySuggestions(){}
CitySuggestions.prototype.requestSuggestions=function(oAutoSuggestControl,bTypeAhead){var aSuggestions=new Array();var sTextboxValue=oAutoSuggestControl.textbox.value;var cityList=new Array();if(sTextboxValue.length>=3){JsHttpRequest.query('/suggest_city'+(USE_REWRITER?'':'.php')+'?country='+country+'&site_id='+site_id,{'value':sTextboxValue},function(result,errors){if(errors){alert('Error during selecting suggestions!');return;}else{cityList=result;}
for(var i=0;i<cityList.length;i++){if(cityList[i].toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(cityList[i]);}}
oAutoSuggestControl.textbox.focus();oAutoSuggestControl.autosuggest(aSuggestions,bTypeAhead);areaSuggest();},true);}else{oAutoSuggestControl.hideSuggestions();}
var radioList=document.getElementsByTagName('input'),i;for(i in radioList){if(radioList[i].type=="radio"){radioList[i].checked=false;}}};function suggest(){var oTextbox=new AutoSuggestControl(document.getElementById('hotel_name_id'),new HotelSuggestions());}
function HotelSuggestions(){}
HotelSuggestions.prototype.requestSuggestions=function(oAutoSuggestControl,bTypeAhead){var aSuggestions=new Array();var sTextboxValue=oAutoSuggestControl.textbox.value;var hotelList=new Array();if(sTextboxValue.length>=3){JsHttpRequest.query('/suggest_hotel'+(USE_REWRITER?'':'.php?site_id='+site_id),{'value':sTextboxValue},function(result,errors){if(errors){alert('Error during selecting suggestions!');return;}else{hotelList=result;}
for(var i=0;i<hotelList.length;i++){if(hotelList[i].toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(hotelList[i]);}}
oAutoSuggestControl.textbox.focus();oAutoSuggestControl.autosuggest(aSuggestions,bTypeAhead);},true);}else{oAutoSuggestControl.hideSuggestions();}};function setSearchCityId(){var objHotelId=document.getElementById('hotel_id');var objSearchName=document.getElementById('search_name');for(i=0;i<objHotelId.options.length;i++){if(objHotelId.options[i].selected==true){objSearchName.value=objHotelId.options[i].text;}}}
function searchForm_Optional(){if(getElementId('searchForm_Optional').style.display=='none')
{getElementId('searchForm_Optional').style.display='';}
else
{getElementId('searchForm_Optional').style.display='none';}}
function addRemoveChildrenAges(input,id){var string=new Array();if(id==null){id=input.id;}
for(i=1;i<=3;i++){if(id=='hotel_profile_double_child2_ages'){string[0]=id+'[1]['+i+']';string[1]=id+'[2]['+i+']';}
else{string[0]=id+'['+i+']';}
if(i>input.value){value=0;var display='none';}
else{value=0;var display='';}
for(var x in string){getElementId(string[x]).value=value;getElementId(string[x]).style.display=display;}}}
function getElementId(id){var returnVar=null;if(document.getElementById){returnVar=document.getElementById(id);}
else if(document.all){returnVar=document.all[id];}
else if(document.layers){returnVar=document.layers[id];}
return returnVar;}
function popUpMap(){day=new Date();id=day.getTime();eval("page"+id+" = window.open('/paris-reservations.map.html', '"+id+"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=576,height=500,left = 352,top = 262');");}
function loadWindow(target,file){target.window.location.href=domainprefix+file;window.self.close();}
function substr_count(haystack,needle,offset,length){var pos=0,cnt=0;haystack+='';needle+='';if(isNaN(offset))offset=0;if(isNaN(length))length=0;offset--;while((offset=haystack.indexOf(needle,offset+1))!=-1){if(length>0&&(offset+needle.length)>length){return false;}else{cnt++;}}
return cnt;}
function print_selected_area(area){var DocumentContainer=document.getElementById(area);var WindowObject=window.open('',"TrackHistoryData","width=550,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");WindowObject.document.writeln(DocumentContainer.innerHTML);WindowObject.document.close();WindowObject.focus();WindowObject.print();WindowObject.close();}
function doBlink(){var blink=document.all.tags("BLINK")
for(var i=0;i<blink.length;i++)
blink[i].style.visibility=blink[i].style.visibility==""?"hidden":""}
function startBlink(){if(document.all)
setInterval("doBlink()",1000)}
function bookmark(){var title=document.title
var url=location.href
if(window.sidebar)window.sidebar.addPanel(title,url,"");else if(document.all)window.external.AddFavorite(url,title);}
function AutoSuggestControl(oTextbox,oProvider){this.cur=-1;this.layer=null;this.provider=oProvider;this.textbox=oTextbox;this.init();}
AutoSuggestControl.prototype.autosuggest=function(aSuggestions,bTypeAhead){if(aSuggestions.length>0){if(bTypeAhead){this.typeAhead(aSuggestions[0]);}
this.showSuggestions(aSuggestions);this.cur=-1;}else{this.hideSuggestions();}};AutoSuggestControl.prototype.createDropDown=function(){var oThis=this;this.layer=document.createElement("div");this.layer.innerHTML='<!--[if lte IE 6.5]><iframe class="frm"></iframe><![endif]-->';this.layer.className="suggestions";this.layer.id="suggestions_layer";this.layer.style.visibility="hidden";this.layer.onmousedown=this.layer.onmouseup=this.layer.onmouseover=function(oEvent){oEvent=oEvent||window.event;oTarget=oEvent.target||oEvent.srcElement;if(oEvent.type=="mousedown"){oThis.textbox.value=oTarget.firstChild.nodeValue;oThis.hideSuggestions();}else if(oEvent.type=="mouseover"){oThis.highlightSuggestion(oTarget);}else{oThis.textbox.focus();}};document.body.appendChild(this.layer);};AutoSuggestControl.prototype.getLeft=function(){var oNode=this.textbox;var offset=$(oNode).offset();var iLeft=0;iLeft=offset.left;return iLeft;};AutoSuggestControl.prototype.getTop=function(){var oNode=this.textbox;var iTop=0;var offset=$(oNode).offset();iTop=offset.top;return iTop;};AutoSuggestControl.prototype.handleKeyDown=function(oEvent){switch(oEvent.keyCode){case 38:this.previousSuggestion();break;case 40:this.nextSuggestion();break;case 13:this.hideSuggestions();break;}};AutoSuggestControl.prototype.handleKeyUp=function(oEvent){var iKeyCode=oEvent.keyCode;if(iKeyCode==8||iKeyCode==46){this.provider.requestSuggestions(this,false);}else if(iKeyCode<32||(iKeyCode>=33&&iKeyCode<46)||(iKeyCode>=112&&iKeyCode<=123)){}else{this.provider.requestSuggestions(this,true);}};AutoSuggestControl.prototype.hideSuggestions=function(){this.cur=-1;this.layer.style.visibility="hidden";};AutoSuggestControl.prototype.highlightSuggestion=function(oSuggestionNode){for(var i=0;i<this.layer.childNodes.length;i++){var oNode=this.layer.childNodes[i];if(oNode.nodeName.toLowerCase()!='iframe'){if(oNode==oSuggestionNode){oNode.className="current"}else if(oNode.className=="current"){oNode.className="";}}}};AutoSuggestControl.prototype.init=function(){var oThis=this;this.textbox.onkeyup=function(oEvent){if(!oEvent){oEvent=window.event;}
oThis.handleKeyUp(oEvent);};this.textbox.onkeydown=function(oEvent){if(!oEvent){oEvent=window.event;}
oThis.handleKeyDown(oEvent);};this.textbox.onblur=function(){oThis.hideSuggestions();};this.createDropDown();};AutoSuggestControl.prototype.nextSuggestion=function(){var cSuggestionNodes=this.layer.childNodes;if(cSuggestionNodes.length>0){if(++this.cur!=cSuggestionNodes.length-1){var oNode=cSuggestionNodes[this.cur];this.textbox.value=oNode.firstChild.nodeValue;this.highlightSuggestion(oNode);}else{this.cur=0;this.textbox.value=cSuggestionNodes[0].firstChild.nodeValue;this.highlightSuggestion(cSuggestionNodes[0]);}}};AutoSuggestControl.prototype.previousSuggestion=function(){var cSuggestionNodes=this.layer.childNodes;if(cSuggestionNodes.length>0){if(this.cur>0){var oNode=cSuggestionNodes[--this.cur];this.highlightSuggestion(oNode);this.textbox.value=oNode.firstChild.nodeValue;}else{if(!cSuggestionNodes[cSuggestionNodes.length-2].firstChild){alert(cSuggestionNodes[cSuggestionNodes.length-2]);}
this.cur=cSuggestionNodes.length-2;this.textbox.value=cSuggestionNodes[cSuggestionNodes.length-2].firstChild.nodeValue;this.highlightSuggestion(cSuggestionNodes[cSuggestionNodes.length-2]);}}};AutoSuggestControl.prototype.selectRange=function(iStart,iLength){if(this.textbox.createTextRange){var oRange=this.textbox.createTextRange();oRange.moveStart("character",iStart);oRange.moveEnd("character",iLength-this.textbox.value.length);oRange.select();}else if(this.textbox.setSelectionRange){this.textbox.setSelectionRange(iStart,iLength);}
this.textbox.focus();};AutoSuggestControl.prototype.showSuggestions=function(aSuggestions){var oDiv=null;this.layer.innerHTML='';for(var i=0;i<aSuggestions.length;i++){oDiv=document.createElement("div");oDiv.appendChild(document.createTextNode(aSuggestions[i]));this.layer.appendChild(oDiv);}
this.layer.style.left=this.getLeft()+"px";this.layer.style.top=(this.getTop()+this.textbox.offsetHeight)+"px";this.layer.innerHTML+='<!--[if lte IE 6.5]><iframe class="frm" style="height:'+this.layer.offsetHeight+'px;"></iframe><![endif]-->';this.layer.style.visibility="visible";};AutoSuggestControl.prototype.typeAhead=function(sSuggestion){};$(document).ready(function(){$('#search_button').click(function(e){e.preventDefault();var values={},rooms=new Array();$.each($("#search_form").serializeArray(),function(i,field){values[field.name]=field.value;});values['city_id']=$('#city_id').val();for(var i=0;i<3;i++){var room={'adults_number':values['rooms['+i+'][adults_number]'],'children_number':values['rooms['+i+'][children_number]'],'children_ages':{'0':values['rooms['+i+'][children_ages][0]'],'1':values['rooms['+i+'][children_ages][1]']}};rooms.push(room);}
$('#search_button').val('Processing query...');$.getJSON('/search_hotels_validate'+(USE_REWRITER?'':'.php'),{'country':values['country'],'city':values['city_id'],'site_id':values['site_id'],'hotel_id':null,'check_in':values['check_in'],'check_out':values['check_out'],'rooms_number':values['rooms[rooms_number]'],'rooms':rooms},function(data){$('#error_list_tr').hide(0);$('#error_list').html('');if(data.message_list.length>0){$.each(data.message_list,function(i,item){$('#error_list_tr').show(0);$('#error_list').append(item+'<br />');});}
else if(data.city_id>0)
{$('input[name="search_city_id"]').val(data.city_id);$("#search_form").submit();}
else if(data.city_list.length>1)
{showCities(data.city_list);}});});});function StringBuffer(){this.buffer=[];}
StringBuffer.prototype.append=function append(string){this.buffer.push(string);return this;};StringBuffer.prototype.toString=function toString(){return this.buffer.join("");};StringBuffer.prototype.merge=function merge(val){this.buffer=this.buffer.concat(val);};

