var xmlHttp2 = createXmlHttpRequestObject2();

var hid1=0;
var lan1='';
var keyw='';
var dopus1='';


									
function createXmlHttpRequestObject2() {
										var xmlHttp2;
										if (window.ActiveXObject){
																try { xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");}
																catch (e) {xmlHttp2 = false;}
																}
										
										else { 
											     try { xmlHttp2 = new XMLHttpRequest();}
												 catch (e) { xmlHttp2 = false;}
												}
										if (!xmlHttp2) alert ("Error create object XMLHttpRequest.")
										   else return xmlHttp2;
										}
 

								
								
								
							
								
			
			function ser(){
						
						document.getElementById('dser').innerHTML="<li><img src='/img/la.gif'></li>";
		                vis1();
						if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0)
										      { 
											  try{
											  url2="/search.php?cash="+new Date().getTime()+"&key="+keyw+"&lg="+lan1+dopus1;	  
				                              xmlHttp2.open("GET",url2,true);
											  xmlHttp2.onreadystatechange = handleServerResponseser;
											  xmlHttp2.send(null);}
											 catch (e) { 
                           alert("Error connect to server:\n"); 
                            } 
							
							} else setTimeout("ser()",1000);
								
				//document.getElementById('dser').innerHTML=document.getElementById('search').value;
				//document.getElementById('dser').style.display="block";
							
						}

			
			function hide(){setTimeout('hide1()',200);}
			function hide1(){document.getElementById('dser').style.display="none";}
			function vis(){setTimeout('vis1()',501);}
			function vis1(){
			document.getElementById('dser').style.top=$("#search").position().top+10+"px";
			document.getElementById('dser').style.left=$("#search").position().left+"px";
			//alert(document.getElementById('main').offsetLeft+440);
			//alert($("#search").position().top+20+"px");
			document.getElementById('dser').style.display="block";
			}
				
 
 
 function mousePageXY(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + 
      (document.documentElement.scrollLeft || document.body.scrollLeft) - 
      document.documentElement.clientLeft;
    y = e.clientY + 
      (document.documentElement.scrollTop || document.body.scrollTop) - 
      document.documentElement.clientTop;
  }

  return {"x":x, "y":y};
}

document.onclick = function(e){
    var mCur = mousePageXY(e); 
    if (mCur.x>$("#dser").offset().left+$("#dser").width()+5 || mCur.x<$("#dser").offset().left-5 || mCur.y<$("#dser").offset().top-20 || mCur.y>$("#dser").offset().top+$("#dser").height()+5) hide();
};
			function call(){
				          						   
				 if (document.getElementById('search').value!=keyw)
								{
								keyw=document.getElementById('search').value;
								lan1=document.getElementById('lg').value;
								if($("#fs input:radio:checked").val()==1)	dopus1="&"+$("#usl").attr("name")+"="+$("#usl").attr("value");
else dopus1='';

							    if (document.getElementById('search').value.length<3) hide1(); 
								else ser();
														
								}
								
							setTimeout('call()',500);			
				         
						}
									
									
									
		function handleServerResponseser(){
				if (xmlHttp2.readyState == 4)
			         {//alert ("Ready State:" + xmlHttp1.readyState);
			    	    //alert ("Status:" + xmlHttp1.status);
					   if (xmlHttp2.status == 200)
							      {
									    serch = xmlHttp2.responseText;
											
					document.getElementById('dser').innerHTML=serch;
					//alert (serch);
					//alert(document.getElementById('dser').childNodes[0].firstChild.data);
					vis();
					
											}
									else { alert ("Error connect to server:" + xmlHttp2.status);}
															   
				       }
				}
//----------------------------------kartinki vsplivayushie--------------------------------

var zap='';
var zapp='';
function poisk(zapros,zap1){
	zap=zapros;zapp=zap1;
	$.ajax({url: "/xml.php?"+zapros+"&cash="+new Date().getTime(), cache: false , success:   function(resp) {
															//		alert (zap);
														if (resp=='01' || resp=='00'){
															setTimeout('poisk(zap,zapp)',1000);
															}
														else {
															var template = /^[A-Za-z0-9_]+=[A-Za-z0-9_]+$/;
   															if (template.test(resp)){
															location.replace(zap1+resp);
															}
															else {alert('Service not available. Try again letter.');
															location.replace('http://www.reservationshotels.org/');
															}
															}
														
														
	}
});

}


$(document).ready(function(){
		

$("#pic li").hover(function() {

    $(this).css({'z-index' : '10'});
    $(this).find('img').addClass("hover").stop()
    .animate({
    marginTop: '-110px', 
    marginLeft: '-110px', 
    top: '50%', 
    left: '50%', 
    width: '300px', 
    height: '300px',
    padding: '5px' 
    }, 400);
  
    } , function() {
    $(this).css({'z-index' : '0'});
    $(this).find('img').removeClass("hover").stop()
    .animate({
    marginTop: '0', 
    marginLeft: '0',
    top: '0', 
    left: '0', 
    width: '90px', 
    height: '90px', 
    padding: '5px'
    }, 100);
    }); 
    $("#tmenf > td:lt(6)").click(function(){
								sel="#tab"+Math.floor(Number($("#tmenf > td").index(this))/2);
								$("#tab0").hide();$("#tab1").hide();$("#tab2").hide();
								 $(sel).show();
								 //alert($("#tmenf > td").index(this));
		//alert ($("#tmen > td:eq(2) > table  tr:eq(1)>td:eq(1)").text());
								  });
	$("#tmenm > td:lt(6)").click(function(){
								sel="#tab"+Math.floor(Number($("#tmenm > td").index(this))/2);
								$("#tab0").hide();$("#tab1").hide();$("#tab2").hide();
								 $(sel).show();
								 //alert($("#tmenm > td").index(this));
				//alert ($("#tmen > td:eq(2) > table  tr:eq(1)>td:eq(1)").text());
								  });
	$("#tmenl > td:lt(6)").click(function(){
				sel="#tab"+Math.floor(Number($("#tmenl > td").index(this))/2);
								$("#tab0").hide();$("#tab1").hide();$("#tab2").hide();
								 $(sel).show();
								// alert(sel);
					//alert ($("#tmen > td:eq(2) > table  tr:eq(1)>td:eq(1)").text());
								  });

$("#mf").click(function(){
								 $("#tab0").hide();$("#tab2").hide();
								 $("#tab1").show();
		//alert ($("#tmen > td:eq(2) > table  tr:eq(1)>td:eq(1)").text());
								  });

	$("#tmenf > td").eq(4).click(function(){
							 GetMap();
						 });
	$("#tmenm > td").eq(4).click(function(){
							 GetMap();
						 });
	$("#tmenl > td").eq(4).click(function(){
							 GetMap();
						 });
	
	});

