var _baseCityList;var _baseCountry;var _baseCity;var _documentForm;var _iFrame;var TimerForCity;var hide=true;function hideDiv(div){if(document.getElementById){var c=$(div);c.style.display="none";}}
function CheckCountryCity(){if(_baseCountry.selectedIndex==0){alert($("msgChoiceCountry").value);return false;}
if(_baseCity.value==""){alert($("msgChoiceCity").value);return false;}
return true;}
function MustChooseCountry(){_baseCity.value="";alert($("msgChoiceBeforeCountry").value);}
function GetLetterCity(){if(_baseCountry.selectedIndex==0){MustChooseCountry();return false;}
else{var Cbo=new CallBackObject();Cbo.OnError=Cbo_OnError;Cbo.OnComplete=GetLetterCityComplete;var URL="/LoadCities/ListCities.aspx";var Query="City="+_baseCity.value+"&Country="+_baseCountry[_baseCountry.selectedIndex].value+"&Count=0";Cbo.DoCallBack(URL,Query);ChangeCity();return true;}}
function NewGetLetterCity()
{if(TimerForCity!=null)clearTimeout(TimerForCity);TimerForCity=setTimeout('GetLetterCity()',100);}
function getLetCity(e)
{switch(e.keyCode){case 40:case 38:case 13:case 27:case 9:break;default:NewGetLetterCity();break;}
return true;}
function Cbo_OnError(status,statusText,responseText){alert("OnError: "+status+"\r"+statusText+"\r"+responseText);}
function GetCityComplete(responseText,responseXML){eval(responseText);}
function GetLetterCityComplete(responseText,responseXML){eval(responseText);}
citiesLetter=function(is,cs,ds,pr){_cityName=cs;_countHotel=ds;_cityLetters=String(pr).split(',');var s='<div class="alfavit3 bgalfavit"><div class="fffcolor">'+$("msgCityDest").value+'</div>';re=/[a-z]/i;for(var k=0;k<_cityLetters.length;k++){if(re.test(_cityLetters[k])){oc="_baseCity.value='"+_cityLetters[k]+"';GetLetterCity();return false;";s+='<a href="#" onclick="'+oc+'">'+_cityLetters[k]+'</a> ';}}
s+='</div>';s+='<div class="paddingcitylist">';s+='<div class="zaglav">'+is.split(';')[1]+'<a name="A"></a></div>';_baseCityList.innerHTML="";for(var k=0;k<_cityName.length;k++){s+='<div class="paddingtopcit" onclick="clicked(this); return false;">';s+='<a href="#" class="textcitylist" >'+_cityName[k]+'</a></div>';}
s+="</div>";_baseCityList.innerHTML=s;_baseCityList.style.width="240px";var h=_cityName.length>16?350:_cityName.length*16+100;_baseCityList.style.height=String(h)+"px";_iFrame.style.width=_baseCityList.offsetWidth+"px";_iFrame.style.height=_baseCityList.offsetHeight+"px";var top=calculateOffsetTop(_baseCity)+_baseCity.offsetHeight-5;var left=calculateOffsetLeft(_baseCity);var he=get_wh()+getBodyScrollTop();if(top+h+10>he){top=he-h-10;left=left+60;}
_baseCityList.style.left=left+"px";_baseCityList.style.top=top+"px";_iFrame.style.left=_baseCityList.style.left;_iFrame.style.top=(top+5)+"px";_iFrame.style.display="block";_iFrame.style.visibility="visible";_baseCityList.style.display="block";_baseCityList.style.visibility="visible";}
function SetCityText(index){_baseCity.value=_cityName[index];SetVisibilityHidden();}
function SetVisibilityHidden(){_baseCityList.innerHTML="";_baseCityList.style.visibility="hidden";_iFrame.style.visibility="hidden";CitiesGetted=-1;}
function ClearOnSubmit(){_documentForm.onsubmit=empty();}
function CheckCityEmpty(){if(_baseCity.value=="")SetVisibilityHidden();else CityListUpdate();}
function empty(){return"return false;"}
function calculateOffsetLeft(r){return Ya(r,"offsetLeft")}
function calculateOffsetTop(r){return Ya(r,"offsetTop")}
function Ya(r,attr){var kb=0;while(r){kb+=r[attr];r=r.offsetParent}return kb}
function ChangeCountry(){SetVisibilityHidden();_baseCity.value="";$("ToChooseCity").disabled=_baseCountry.selectedIndex==0;}
function ChangeCity(){$("quickSearch").disabled=_baseCity.value=="";}
function InitSelectCity(frm,CityList,Country,City,iFrame){_documentForm=frm;_baseCityList=CityList;_baseCountry=Country;_baseCity=City;_iFrame=iFrame;_baseCountry.onchange=ChangeCountry;ChangeCountry();_iFrame.style.width=_baseCity.style.width;_baseCityList.style.left=calculateOffsetLeft(_baseCity)+"px";_baseCityList.style.top=calculateOffsetTop(_baseCity)+_baseCity.offsetHeight-1+"px";_iFrame.style.left=_baseCityList.style.left;_iFrame.style.top=_baseCityList.style.top;_iFrame.style.width=_baseCityList.offsetWidth+"px";_iFrame.style.height=_baseCityList.offsetHeight+"px";_baseCityList.style.position="absolute";_iFrame.style.position="absolute";SetVisibilityHidden();}
function _InitSelectCity(){InitSelectCity($("FormQuickSearch"),$("CityList"),$("SelectSearchCountry"),$("SelectCity"),$("IFrameCityList"));}
