
function changeCountry(c) { $v(llCity.input, "") }
//lstCountries = new ComboBox("lstCountries", "cbInputText", "cbButtonDown", "_tbCountries", "divContainer", 1, "changeCountry");
function KeyDown_lstCountries(ev){return lstCountries.keydown(ev);}
function KeyUp_lstCountries(ev) { return lstCountries.keyup(ev); }

  
              
function llCity_LoadData(){
var code = getCountryCode();
if(code&&code!=""){
llCity.filter = $v("SelectCity");
llCity.LoadData("CnCode="+code+"&filter="+llCity.filter);//$("SelectCity").value);
}
else{alert($v("msgChoiceCountry"))}	
}
function getCnCode(){return (lstCountries.value?lstCountries.value:null)}
function getCountryCode(){return (lstCountries.value?lstCountries.value:null)}
function setCountryCode(v){return lstCountries.value = v}
function getCountryName(){return (lstCountryCities.value?lstCountryCities.value:null)}
function setCountryNm(v){return lstCountryCities.value=v}
function setCountry(v){
if(typeof(v)=="string"){
var p = v.split(";");
if(p.length==2 && typeof(p[0])=="string" && typeof(p[1])=="string" && p[0]!="" && p[1]!="" &&
p[0]!="undefined" && p[1]!="undefined"){
try {lstCountries.choose(p[0],p[1])} catch(err) {}
}
}
}
function setCities(v){
if(typeof(v)=="string"){
var p = v.split(";");
if(p.length==2 && typeof(p[0])=="string" && typeof(p[1])=="string" && p[0]!="" && p[1]!="" &&
p[0]!="undefined" && p[1]!="undefined"){
try {lstCountryCities.choose(p[0],p[1])} catch(err) {}
}
}
}

var flagus = 0;
function onlBody(){
var Height = $("CityList").clientHeight
$("IFrameCityList").style.height = Height
}
function onclickbody(){
var oppens = $("CityList").style
var frame = $("IFrameCityList").style
if(flagus == 1){
oppens.visibility = 'hidden'
frame.visibility = 'hidden'
flagus = 0;
if(selectCountry == 0)$('SelectCity').value = "";
}}

function flaaag(){flagus = 1;}
function opennli(){flagus = 0;}

function HiddenCityList(){
$("CityList").style.visibility = 'hidden';
$("IFrameCityList").style.visibility = 'hidden';
$('SelectCity').value = "";
}

var selectCountry = null;
/*
function clicked(ids){
selectCountry = 1;
var alls = ids.innerText?ids.innerText:ids.textContent;
$('SelectCity').value = alls
var oppens = $("CityList").style
var frame = $("IFrameCityList").style
oppens.visibility = 'hidden'
frame.visibility = 'hidden'
$("quickSearch").disabled = false;
}
*/
function openwindow(){
var oppens = $("CityList").style
var frame = $("IFrameCityList").style
if(oppens.visibility == "visible"){oppens.visibility = 'hidden';frame.visibility = 'hidden'}
else{selectCountry = 0;GetLetterCity();}
}

function openhelp(helpes){
var heelp = $(helpes).style
if(heelp.visibility == "visible") heelp.visibility = 'hidden'	
else heelp.visibility = 'visible'	
}

function resizeframe(helpess){
var heelpn = $(helpess).style
if(heelpn.visibility == "visible") heelpn.visibility = 'hidden'
else heelpn.visibility = 'visible'
}

function loadAllCountry(el){
document.forms[0].action = "Country-world.html";
document.forms[0].submit();
return true;
}
var elements = "";
function createElement(newF,key,val){
	var newH = $(key);
	if(!newH){
		/*@cc_on @if (@_jscript)  
		var newH = document.createElement("<input id='"+key+"' name='"+key+"'>");  
		@else */  
		newH = document.createElement("input"); 
		newH.name = key; /* @end @*/ 
		newH.type = 'hidden'; 
		newF.appendChild(newH);
	}
	newH.value = val; 
// alert("createElement: " + newH.name + "  " + val);	
//elements += newH.name + "  " + val + "\n";
}

function CheckCountryCity(){
var cn = getCnCode();
var ct = $v("SelectCity");

if(cn==""){alert($("msgChoiceCountry").value);return false;}
if(ct==""){alert($("msgChoiceCity").value);return false;}
return true;
}


function toPostQuickSearch(newF){
SaveCookie();
if(!CheckCountryCity())	return false;	
if(!CheckADDate())	return false;	

elements = "";

createElement(newF,"ControlForm:book_HotelClass0","True");
createElement(newF,"ControlForm:book_HotelClass1","True");
createElement(newF,"ControlForm:book_HotelClass2","True");
createElement(newF,"ControlForm:book_HotelClass3","True");
createElement(newF,"ControlForm:book_HotelClass4","True");
createElement(newF,"ControlForm:book_HotelClass5","True");

var cn = getCnCode();
createElement(newF,"ControlForm:_CountryCode",cn);// el.options[el.selectedIndex].value);
var ct = $v("SelectCity");
createElement(newF,"ControlForm:_City",ct);// $("SelectCity").value);
createElement(newF,"ControlForm:_ArrivalDate",$("_ArrivalDate").value);
createElement(newF,"ControlForm:_DepartureDate",$("_DepartureDate").value);
//alert("CN: "+ cn + "\nCT: " + ct + "\nAD: " + $("_ArrivalDate").value + "\nDD: " + $("_DepartureDate").value);
//el = $("CountOfPerson");
createElement(newF,"ControlForm:_RoomType",$v("CountOfPerson"));// el.options[el.selectedIndex].value);
//el = $("CountOfRoom");
createElement(newF,"ControlForm:_AmountOfRooms",$v("CountOfRoom"));// el.options[el.selectedIndex].value);
createElement(newF,"ControlForm:_CurrencyCode","");
createElement(newF,"ControlForm:_Language",$("Lang").value);
//newF.action = "/hotels/search.aspx";
newF.action = "http://localhost:3554/search.aspx";
// showValues(newF);
//alert("toPostQuickSearch:\n" + elements);

var ws = $("__VIEWSTATE");
if(ws == null){var _ws = document.getElementsByName("__VIEWSTATE");ws = _ws[0]}
if(ws){ws.name = "_VIEW_STATE";ws.id = "_VIEW_STATE"}
newF.submit();
if(ws){ws.name = "__VIEWSTATE";ws.id = "__VIEWSTATE"}
return true;
}

function showValues(newF){}

function get_wh(){
var frameHeight=640;
if (self.innerHeight)frameHeight = self.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)	frameHeight = document.documentElement.clientHeight;
else if (document.body)	frameHeight = document.body.clientHeight;
return frameHeight}

function getBodyScrollTop(){
return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop)}

function getBodyScrollLeft(){
return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft)}

function onchangeCountry(){ 
SaveCookie();
// lcCountry.Set_selsug();
//var id = lcCountry.selsug.split(',');
var cn = getCountryName();
cn = cn.trim().toLowerCase();
//alert("onchangeCountry(): " + cn);
///// var sc = $('SelectQuickCountry');
var l = "/"+ cn + "+cities";
//// var l = "ListCity.aspx?country="+sc.options[sc.selectedIndex].value + "&allcity=1";
/////// var l = "/catalog/ru/ListCity.aspx?country="+cn;
// var l = "listcity.aspx?country="+cn;
var a = $("aCityList");
if(a.click){a.href = l;a.click();}
else{
var newF = document.createElement("form"); 
newF.action = l;
newF.method = 'GET'; 
// createElement(newF,"country",cn);
document.getElementsByTagName('body')[0].appendChild(newF); 
newF.submit(); 
}}		 

function LoadSearchForm(){onSetPeriod()}
//addLoadEvent(LoadSearchForm);

function GetParamForCookies(){
    var params = 
        'RoomType=' + $v("CountOfRoom") + '&'+ 'AmountOfRooms='+ $v("CountOfPerson") + '&'+
  		'ArrivalDate=' + $v("_ArrivalDate")+'&'+ 'DepartureDate=' + $v("_DepartureDate") + '&'+
  		'VisitorID=' + $v("VisitorID");
//alert("GetParamForCookies(): " + params);  		
  	return	params;
}

function GetParamForCookiesEx(){
    var params = 'Country='+ getCountryCode() + ";" + $v("cbInputText") +
                 '&City=' + $v("SelectCity") + 
                 '&Cities=' + getCountryName()+ ";" + $v("cbInputTextCities");
  	return	params;  		
}

function Save_Cookie(){
    deleteCookie("search_cookie");
    setCookie("search_cookie",GetParamForCookies());
    setCookie("index_cookie",GetParamForCookiesEx());
//alert("SaveCookie()\n"+document.cookie);    
}

function SaveCookie(){
    deleteCookie("search_cookie"); // ,"/","ru");
    //alert("SaveCookie()\n"+getAD);   
/*
    var cookies = "ArrivalDate=" + getAD() + 
        "&DepartureDate=" +  getDD() + 
        "&CountryCode=" + getCountryCode() + 
        "&city=" + escapeURI(String($v("SelectCity")).trim()) + 
        "&RoomType=" + $v("CountOfPerson") + 
        "&AmountOfRooms=" + $v("CountOfRoom")+
        "&ICountry="  + getCountryName(); //$v(cbInputTextCities;
*/

    var cookies = "ArrivalDate=" + getAD();
    cookies += "&DepartureDate=" + getDD();
    cookies += "&CountryCode=" + getCountryCode();
    cookies += "&city=" + escapeURI(String($v("SelectCity")).trim());
    cookies += "&RoomType=" + $v("CountOfPerson");
    cookies += "&AmountOfRooms=" + $v("CountOfRoom");
    cookies += "&ICountry=" + getCountryName(); //$v(cbInputTextCities;
   setCookie("search_cookie",cookies);
   alert("SaveCookie()\n" + document.cookie);   
}

function unloadPage(){SaveCookie();return true}
	    
function s(n,v){
var el = $(n);
v = String(v).toUpperCase();
if(el){
 v = v.trim().toLowerCase()
 for(j=0;j<el.options.length;j++)
 if(String(el.options[j].value).trim().toLowerCase() == v){el.selectedIndex=j;break}
}}

var timer_loadPage;
function onloadPage(){Timer_Progress = window.setTimeout('loadPage()',100)}
function loadPage(){setOnUnloadPage();return true} // onSetPeriod();
function setOnUnloadPage(){               
    for(var i=0; i<document.links.length; i++){
        link = document.links[i];
        if(!link.onclick) link.onclick = "unloadPage();return true"}
}

