
window.addEvent('domready', function(){

//$('destination').addEvents({
//	'keyup':function() {
//		$('city').value="";
//		},
//	'change':function() {
//		$('city').value="";
//		}
//});
new Element('div', {'id':'shCalendar'}).inject($('content'));

document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false);

$('searchButton').addEvent('click', function() { 
	if($('checkin').value && $('checkout').value) {
		//var addr=document.location.href; /// ïîêà ÷òî îòêëþ÷èë âîçìîæíîñòü ïîèñêà íà ýòîé æå ñòðàíèöå áåç ïåðåçàãðóçêè
		//if(addr.indexOf('search.html')>0){
		//	searchHotels(); }
		//else
			$('searchform').submit();	}
	else if($('destination').value) {
		document.location.href='/destination/'+$('destination').value+'/';	 }
	if(1==2) // ïîèñê íàïðàâëåíèÿ (ïîêà îòêëþ÷åí)
		{
		var div = setInfoWindow('infoDiv');
		setCenterWin(div, 339, 4);
		var img = new Element('img', {'src': '/lib/im/load.gif'}).inject(div['top']);
		img.setStyle('padding-top', '5px');
		new Element('div', {'html': 'Please wait. Search destination...'}).inject(div['top']);
		morphCenterWin(div, 339, 30);
		
		new Request.JSON({
					url: "/lib/json/search_destination.php",
					onComplete: function(jsonObj){ 
						var list=jsonObj.list;
	
						if(list.length==1)	{
							$('city').value=list[0].uin;
							$('destination').value=list[0].name;
							$('searchform').submit();	}
						else {
							$('infoDiv').empty();
							$('pageTitle').innerHTML=list.length+" destinations found for “"+$('destination').value+"”";
							var content=$('pageContent')
							content.empty();
							new Element('h4', {'html': "Please make your choice by clicking on the destination name below…"}).inject(content);
							new Element('br').inject(content);
							list.each(function(str) {		
								new Element('div', {'html': "City: "+str.name}).inject(content);
								
								});
							}
						}}).post($('searchform'));
			}
	});
});
