var flagus = 0;
function onlBody(){
var Height = $("CityList").clientHeight
$("IFrameCityList").style.height = Height
$('HeightC').style.height = $('cHeight').clientHeight
$('helpess1').style.height = $('helpes1').clientHeight
$('helpess1').style.width = $('helpes1').clientWidth
$('helpess2').style.height = $('helpes2').clientHeight
$('helpess2').style.width = $('helpes2').clientWidth
}

function onclickbody(){
var oppens = $("CityList").style
var frame = $("IFrameCityList").style
window.status = flagus + "  " + oppens.visibility
if(flagus == 1){ // || oppens.visibility != 'hidden'){
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';
$('sCity').value = "";
}

var selectCountry = null;
function clicked(ids){
selectCountry = 1;
var alls = ids.innerText?ids.innerText:ids.textContent;
$('sCity').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
selectCountry = 0;GetLetterCity()}

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; 
}

function toPostQuickSearch(newF){
if(!CheckCountryCity())	return false;	

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 el = $("sCountry");
createElement(newF,"ControlForm:_CountryCode",el.options[el.selectedIndex].value);
createElement(newF,"ControlForm:_City",$("sCity").value);

var msg = $("msgInvalidAD").value;
s = CheckDate("_AD", msg);
if(s=="") return;
createElement(newF,"ControlForm:_ArrivalDate",s);

s = $("_DD").value;
s = CheckDate("_DD",$("msgInvalidDD").value);
if(s=="") return;
createElement(newF,"ControlForm:_DepartureDate",s);

el = $("CountOfPerson");
createElement(newF,"ControlForm:_RoomType",el.options[el.selectedIndex].value);
el = $("CountOfRoom");
createElement(newF,"ControlForm:_AmountOfRooms",el.options[el.selectedIndex].value);
createElement(newF,"ControlForm:_CurrencyCode","");
createElement(newF,"ControlForm:_Language",$("Lang").value);
newF.action = "http://catalogue.horse21.ru/hotels/search.aspx";
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 CheckCountryCity(){
if($("sCountry").selectedIndex == 0){alert($("msgChoiceCountry").value);return false}
if($("sCity").value == ""){alert($("msgChoiceCity").value);return false}
return true;
}

function CheckDate(d,msg){
var s = $(d).value;
var m = String(s).split("/");
if(m.length != 3){ alert(msg); return "";}
if(m[2].length == 1)  m[2] = "0" + m[2]; 
var yy = parseInt("20"+m[2],10); 
//  if(m[1].charAt(0)=="0") m[1] = m[1].substring(1, 2);
var mm = parseInt(m[1],10)-1;
//  if(m[0].charAt(0)=="0") m[0] = m[0].substring(1, 2);
var dd = parseInt(m[0],10);
var _d = new Date(yy, mm, dd);
var c = isNaN(_d);
if(c){ alert(msg); s= "";}
else s = _d.toString();
// String(_d.getFullYear()) + "-" + String(_d.getMonth()+1) + "-" + String(_d.getDate());    
return s;
}

function onGoCatalog(){ 
alert("onGoCatalog()");
//var sc = $('SelectQuickCountry');
//var l = sc.options[sc.selectedIndex].value+"_citylist.html";
// var l = "/"+sc.options[sc.selectedIndex].value + "+cities";
var l = $("UrlCatalog").value; //  "http://catalogue.horse21.ru";
//var a = $("aCityList");
//if(a.click){a.href = l;a.click();}
//else{
var newF = document.createElement("form"); 
newF.action = l;
newF.method = 'GET'; 
document.getElementsByTagName('body')[0].appendChild(newF); 
newF.submit(); 
//}
}		 
