﻿function AskMesto(ssil,value)
{
if (!((value=="0")||(value=="")||(value==null)))
$.post("ajax/mesto.php", {mesto:value},function(data) {if (data!='0') window.location.href=(ssil+data); else window.location.href=(ssil);});
else
window.location.href=(ssil);
}

function SaveSession(name,value)
{
//alert(name+value);
if (name=='datas'){
$.post("ajax/savesession.php", {datas:value});}
if (name=='datapo'){
$.post("ajax/savesession.php", {datapo:value});}
if (name=='vzr'){
$.post("ajax/savesession.php", {vzr:value});}
if (name=='child'){
$.post("ajax/savesession.php", {child:value});}
if (name=='mesto'){
$.post("ajax/savesession.php", {mesto:value});}
if (name=='type'){
$.post("ajax/savesession.php", {type:value});}
if (name=='poi'){
$.post("ajax/savesession.php", {poi:value});}
if (name=='plus'){
$.post("ajax/savesession.php", {plus:value});}

}

function HotelClear()
{$(".show_price").each(function(){
this.innerHTML="<span class='price'>ПОД ЗАПРОС</span>";
this.className="onrequest";})
$(".show_offers").each(function(){
this.innerHTML="";})
}

function MultiHotel(id_str,datasv,datapov,vzrv,childv)
{
HotelClear();
if (datasv == null)
{datasv="";}
if (datapov == null)
{datapov="";}
if (vzrv == null)
{vzrv="1";}
if (childv == null)
{childv="0";}

if (id_str.substr(0,1)==",") {id_str=id_str.substr(1,id_str.length)};


//alert("show!");
	$.post("ajax/prices.php?multihotel", {arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			Loading(1);
			//$("#loading").show();
			if (document.getElementById("helper1")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper1").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
				//alert ('id='+id);
				
			

			//document.getElementById("show_offers_"+id).innerHTML=data;
			if (document.getElementById(id+"_offers")!=null)
			{
				document.getElementById("show_offers_"+id).innerHTML='';
				document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers").innerHTML;
			}
			
			if (document.getElementById("minprice_"+id)!=null)
				{document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(document.getElementById("minprice_"+id).innerHTML)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
				ShowHide(id);
				ShowHide(id);
				}
			else
				{if (document.getElementById("hdr_"+id)!=null)
					{document.getElementById("hdr_"+id).innerHTML="<span class='price'>ПОД ЗАПРОС</span>";
					document.getElementById("hdr_"+id).className="onrequest";
					//$("#hdr_"+id).click(function (){AskContactsOnRequest(this);});
					
					ShowHide2(id);
					}
				}
			//	$("#hdp_"+id).click(function(){ShowHide(id);});
			}
			SortAllHotelsPrice();
			;
			});
window.stc=false;

$.post("ajax/pricesstc.php?multihotel", {arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			
			if (document.getElementById("helper2")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper2").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
			
			if ($("#table_stc_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_stc_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_stc").innerHTML;
					$("#table_stc_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_stc_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_stc_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp=99999999999; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			ShowHide2(id);
			}
			SortAllHotelsPrice();
			stc=true;
			});			
window.rsi=false;
$.post("ajax/pricesrsi.php?multihotel", {arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {

			if (document.getElementById("helper3")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper3").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
			
			if ($("#table_rsi_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_rsi_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_rsi").innerHTML;
					$("#table_rsi_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_rsi_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_rsi_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp=99999999999; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			ShowHide2(id);
			}
			SortAllHotelsPrice();
			//$("#loading").hide();
			rsi=true;
			});			


}

function MultiHotelC(id_str,cities_str,datasv,datapov,vzrv,childv)
{
HotelClear();
if (datasv == null)
{datasv="";}
if (datapov == null)
{datapov="";}
if (vzrv == null)
{vzrv="1";}
if (childv == null)
{childv="0";}

if (id_str.substr(0,1)==",") {id_str=id_str.substr(1,id_str.length)};
//alert("show!");
	$.post("ajax/prices.php?multihotel", {arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			//$("#loading").show();
			Loading(1);
			if (document.getElementById("helper1")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper1").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
				//alert ('id='+id);
				
			

			//document.getElementById("show_offers_"+id).innerHTML=data;
			if (document.getElementById(id+"_offers")!=null)
			{
				document.getElementById("show_offers_"+id).innerHTML='';
				document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers").innerHTML;
			}
			
			if (document.getElementById("minprice_"+id)!=null)
				{document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(document.getElementById("minprice_"+id).innerHTML)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
				ShowHide2(id);
				}
			else
				{if (document.getElementById("hdr_"+id)!=null)
					{document.getElementById("hdr_"+id).innerHTML="<span class='price'>ПОД ЗАПРОС</span>";
					document.getElementById("hdr_"+id).className="onrequest";
					//document.getElementById("hdr_"+id).className="show_price";
					//$("#hdr_"+id).click(function (){AskContactsOnRequest(this);});
					
					ShowHide2(id);
					
					}
				}
			//	$("#hdp_"+id).click(function(){ShowHide(id);});
			}
			SortAllHotelsPrice();
			;
			});
window.stc=false;
$.post("ajax/pricesstc.php", {cities:cities_str,arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) 
			{
			if (document.getElementById("helper2")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper2").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
			
			if ($("#table_stc_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_stc_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML+"</tbody></table>";

				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_stc").innerHTML;
					$("#table_stc_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_stc_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_stc_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp=99999999999; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					//alert (id+"old:"+old_price_cmp+"new:"+new_price_cmp+"is_lowee"+(isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp));
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			ShowHide2(id);
			
			}
			SortAllHotelsPrice();
			stc=true;
			});			
window.rsi=false;
$.post("ajax/pricesrsi.php", {cities:cities_str,arr_str:id_str,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) 
			{
			if (document.getElementById("helper3")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper3").innerHTML=data;
			
			id_array=id_str.split(",");
			max=id_array.length-1;
			for (key=0;key<=max;key=key+1)
			{
			//for (var key in id_array) {
				var id = id_array[key];
			
			if ($("#table_rsi_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_rsi_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML+"</tbody></table>";

				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_rsi").innerHTML;
					$("#table_rsi_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_rsi_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_rsi_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp=99999999999; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					//alert (id+"old:"+old_price_cmp+"new:"+new_price_cmp+"is_lowee"+(isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp));
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			ShowHide2(id);
			
			}
			SortAllHotelsPrice();
			//$("#loading").hide();
			rsi=true;
			});			


}




function SingleHotel(id,datasv,datapov,vzrv,childv)
{
if (datasv == null)
{datasv="";}
if (datapov == null)
{datapov="";}
if (vzrv == null)
{vzrv="1";}
if (childv == null)
{childv="0";}
$("#loading").show();
$.post("ajax/prices.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper1")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper1").innerHTML=document.getElementById("helper1").innerHTML+data;
			//document.getElementById("show_offers_"+id).innerHTML=data;
			if (document.getElementById(id+"_offers")!=null)
			{
				document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers").innerHTML;
			}
			if (document.getElementById("minprice_"+id)!=null)
				{document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(document.getElementById("minprice_"+id).innerHTML)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
				}
			else
			{document.getElementById("hdr_"+id).innerHTML="<span class='price'>ПОД ЗАПРОС</span>";
				document.getElementById("hdr_"+id).className="onrequest";
				//document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){AskContactsOnRequest(this);});
				}
			//$("#hdp_"+id).click(function(){ShowHide(id);});
			ShowHide(id);} );

$.post("ajax/pricesstc.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper2")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper2").innerHTML=document.getElementById("helper2").innerHTML+data;
			if ($("#table_stc_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//$("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_stc_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_stc").innerHTML;
					$("#table_stc_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_stc_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_stc_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp='999999'; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						//alert ("old:"+old_price_cmp+"new:"+new_price_cmp);
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
					pricePreview();
		pricePreview2();
			ShowHide2(id);
			
			//ShowHide(id); уже показывается
			} );			
$.post("ajax/pricesrsi.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper3")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper3").innerHTML=document.getElementById("helper3").innerHTML+data;
			if ($("#table_rsi_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//$("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_rsi_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_rsi").innerHTML;
					$("#table_rsi_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_rsi_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_rsi_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp='999999'; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						//alert ("old:"+old_price_cmp+"new:"+new_price_cmp);
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
					pricePreview();
		pricePreview2();
			$("#loading").hide();
			ShowHide2(id);
			
			//ShowHide(id); уже показывается
			} );			
}


function SingleHotelS(id,datasv,datapov,vzrv,childv)
{
document.getElementById("show_offers_"+id).innerHTML="";
if (datasv == null)
{datasv="";}
if (datapov == null)
{datapov="";}
if (vzrv == null)
{vzrv="1";}
if (childv == null)
{childv="0";}
$("#loading").show();
$.post("ajax/prices.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper1")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper1").innerHTML=data;
			//document.getElementById("show_offers_"+id).innerHTML=data;
			if (document.getElementById(id+"_offers")!=null)
			{
				document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers").innerHTML;
			}
			if (document.getElementById("minprice_"+id)!=null)
				{document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(document.getElementById("minprice_"+id).innerHTML)+"&#8364;</span>";
				document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){ShowHide(id);}); 
				}
			else
			{document.getElementById("hdr_"+id).innerHTML="<span class='price'>ПОД ЗАПРОС</span>";
				document.getElementById("hdr_"+id).className="onrequest";
				//document.getElementById("hdr_"+id).className="show_price";
				//$("#hdr_"+id).click(function (){AskContactsOnRequest(this);});
				}
			//$("#hdp_"+id).click(function(){ShowHide(id);});
		pricePreview();
		pricePreview2();
		ShowHide(id);} );
					if ($(".show_offers>thead>tr>th")[2]!=null)
				$($(".show_offers>thead>tr>th")[2]).text("Вмест.");
			if ($(".show_offers>thead>tr>th")[1]!=null)
				$($(".show_offers>thead>tr>th")[1]).text("Пит.");
			//$('td:nth-child(3)[class*="C"]').css("white-space","nowrap");

				
				
				
$.post("ajax/pricesstc.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper2")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper2").innerHTML=data;
			if ($("#table_stc_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//$("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_stc_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_stc_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_stc").innerHTML;
					$("#table_stc_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_stc_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_stc_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp='999999'; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						//alert ("old:"+old_price_cmp+"new:"+new_price_cmp);
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			pricePreview();
		pricePreview2();
			if ($(".show_offers>thead>tr>th")[2]!=null)
				$($(".show_offers>thead>tr>th")[2]).text("Вмест.");
			if ($(".show_offers>thead>tr>th")[1]!=null)
				$($(".show_offers>thead>tr>th")[1]).text("Пит.");
			//$('td:nth-child(3)[class*="C"]').css("white-space","nowrap");
			$('.show_offers').css('width','auto');
			ShowHide2(id);
			
			//ShowHide(id); уже показывается
			} );			
$.post("ajax/pricesrsi.php?singlehotel", {arr_str:id,datas:datasv,datapo:datapov,vzr:vzrv,child:childv},function(data) {
			if (document.getElementById("helper3")==null)
				setTimeout("var a;",5000);
			document.getElementById("helper3").innerHTML=data;
			if ($("#table_rsi_"+id+">tbody")[0]!=null)
			{
				if ($("#table_"+id+">tbody")[0]!=null)
				{
					//$("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					//I HATE IE $("#table_"+id+">tbody")[0].innerHTML=$("#table_"+id+">tbody")[0].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML;
					
					$("#table_"+id+">tbody")[0].parentNode.parentNode.innerHTML="<table class='show_offers' id='table_"+id+"'><thead>"+$("#table_rsi_"+id+">tbody")[0].parentNode.childNodes[0].innerHTML+"</thead><tbody>"+$("#table_"+id+">tbody")[0].parentNode.childNodes[1].innerHTML+$("#table_rsi_"+id+">tbody")[0].innerHTML+"</tbody></table>";
				}
				else
				{
					document.getElementById("show_offers_"+id).innerHTML=document.getElementById(id+"_offers_rsi").innerHTML;
					$("#table_rsi_"+id).attr("id","table_"+id);
				}
			}
			if(document.getElementById("minprice_rsi_"+id)!=null) {var new_price_cmp=document.getElementById("minprice_rsi_"+id).innerHTML;
			if (new_price_cmp!=null)
				{
					
					tmp=$("#hdr_"+id+">span").text();
					if (tmp=="ПОД ЗАПРОС")
					{
						var old_price_cmp='999999'; 
					}
					else
					{	
						var old_price_cmp=tmp.substring(3, tmp.length-1);
					}
					
					if (isNaN(old_price_cmp) || isNaN(new_price_cmp) ? old_price_cmp > new_price_cmp : +old_price_cmp > +new_price_cmp)
					{
						//alert ("old:"+old_price_cmp+"new:"+new_price_cmp);
						document.getElementById("hdr_"+id).innerHTML="<span class='price'>от "+Math.ceil(new_price_cmp)+"&#8364;</span>";
						document.getElementById("hdr_"+id).className="show_price";
						//$("#hdr_"+id).click(function (){ShowHide(id);}); 
					}
				}
			else
			{
				//do nothing
			}
			}
			pricePreview();
		pricePreview2();
			if ($(".show_offers>thead>tr>th")[2]!=null)
				$($(".show_offers>thead>tr>th")[2]).text("Вмест.");
			if ($(".show_offers>thead>tr>th")[1]!=null)
				$($(".show_offers>thead>tr>th")[1]).text("Пит.");
			//$('td:nth-child(3)[class*="C"]').css("white-space","nowrap");
			$('.show_offers').css('width','auto');
			$("#loading").hide();
			ShowHide2(id);
			
			//ShowHide(id); уже показывается
			} );			
}

function AddSort(id)
{
var th = $('#table_'+id+'>thead>tr>th'),
	inverse = new Array(false,false,false,false,false,false,false);
	th.click(function()
	{
		var header = $(this),
		index = header.index();
		//alert(index);
		header
			.closest('table')
			.find('td')
			.filter(function()
			{ 
				return $(this).index() === index;
			}) 
			.sortElements(function(a, b)
			{ 
				
				var a = $(a).text();
				var b = $(b).text();
				if (index==6)
				{a=a.substring(0, a.length-4);
				b=b.substring(0, b.length-4);}
				return ( 
				isNaN (a) || isNaN(b) ? a > b : +a > +b ) ? inverse[index] ? -1 : 1 :inverse[index] ? 1 : -1;},
				function(){return this.parentNode; 
			});
		inverse[index] = !inverse[index];
	});
}

function SortPrice(id)
{
		inverse=false;
		var th = $('#table_'+id+'>thead>tr>th');
		var header = $(th[6]);
		index = 6;
		//alert(index);
		header
			.closest('table')
			.find('td')
			.filter(function()
			{ 
				return $(this).index() === index;
			}) 
			.sortElements(function(a, b)
			{ 
				
				var a = $(a).text();
				var b = $(b).text();
				a=a.substring(0, a.length-4);
				b=b.substring(0, b.length-4);
				return ( 
				isNaN (a) || isNaN(b) ? a > b : +a > +b ) ? inverse ? -1 : 1 :inverse ? 1 : -1;},
				function(){return this.parentNode; 
			});
		pricePreview();
		pricePreview2();
}


function ShowHide(id)
{

	var oRows = document.getElementById("show_offers_"+id).getElementsByTagName('tr');
	
	var iRowCount = oRows.length-1;
	var msg;
	
	thediv = document.getElementById("hdp_"+id);
	thediv2 = document.getElementById("show_offers_"+id);
	var state=thediv.className;
	switch (iRowCount) 
	{
		case -1:
			msg="Под запрос &#8897;";
			state= 'hdp_onRequest';
		break;
		case 1:
		case 21:
		case 31:
		case 41:
		case 51:
		case 61:
		case 71:
		case 81:
		case 91:
		case 101:
			msg=iRowCount+" предложение &#8896;";
		break;
		case 2:
		case 3:
		case 4:
		case 22:
		case 23:
		case 24:
		case 32:
		case 33:
		case 34:
		case 42:
		case 43:
		case 44:
		case 52:
		case 53:
		case 54:
		case 62:
		case 63:
		case 64:
		case 72:
		case 73:
		case 74:
		case 82:
		case 83:
		case 84:
		case 92:
		case 93:
		case 94:
			msg=iRowCount+" предложения &#8896;";
		break;
		default:
			msg=iRowCount+" предложений &#8896;";
	}		
	if(state == 'hdp_off')
	{
		//thediv2.className = 'show';
		var mesg = msg.substring(0, msg.length-7);
		mesg+="&#8897;";
		thediv.className = 'hdp_on';
		thediv.innerHTML=mesg;		
	} else if (state == 'hdp_on')
	{
		//thediv2.className = 'hide';
//		thediv.className = 'hdp_off';
		msg = msg.substring(0, msg.length-7);
		msg+="&#8897;";
	//	alert(msg);
		//msg="... предложения &#8897;";
		thediv.innerHTML=msg;
	}
	else if (state == 'hdp_onRequest')
	{	//thediv2.className = 'hide';
		msg="Под запрос &#8897;";
		thediv.className = 'hdp_off';
		thediv.innerHTML=msg;}
	//thediv2.className ="";
	$("#show_offers_"+id).fadeToggle("fast");
	AddSort(id);
	SortPrice(id);
}

function ShowHide2(id)
{

	var oRows = document.getElementById("show_offers_"+id).getElementsByTagName('tr');
	
	var iRowCount = oRows.length-1;
	var msg;
	
	thediv = document.getElementById("hdp_"+id);
	thediv2 = document.getElementById("show_offers_"+id);
	var state=thediv.className;
	switch (iRowCount) 
	{
		case -1:
			msg="Под запрос &#8897;";
			state= 'hdp_onRequest';
		break;
		case 1:
		case 21:
		case 31:
		case 41:
		case 51:
		case 61:
		case 71:
		case 81:
		case 91:
		case 101:
			msg=iRowCount+" предложение &#8896;";
		break;
		case 2:
		case 3:
		case 4:
		case 22:
		case 23:
		case 24:
		case 32:
		case 33:
		case 34:
		case 42:
		case 43:
		case 44:
		case 52:
		case 53:
		case 54:
		case 62:
		case 63:
		case 64:
		case 72:
		case 73:
		case 74:
		case 82:
		case 83:
		case 84:
		case 92:
		case 93:
		case 94:
			msg=iRowCount+" предложения &#8896;";
		break;
		default:
			msg=iRowCount+" предложений &#8896;";
	}		
	if(state == 'hdp_off')
	{
		//thediv2.className = 'show';
		var mesg = msg.substring(0, msg.length-7);
		mesg+="&#8897;";
		thediv.className = 'hdp_on';
		thediv.innerHTML=mesg;		
	} else if (state == 'hdp_on')
	{
		//thediv2.className = 'hide';
//		thediv.className = 'hdp_off';
		msg = msg.substring(0, msg.length-7);
		msg+="&#8897;";
	//	alert(msg);
		//msg="... предложения &#8897;";
		thediv.innerHTML=msg;
	}
	else if (state == 'hdp_onRequest')
	{	//thediv2.className = 'hide';
		msg="Под запрос &#8897;";
		thediv.className = 'hdp_off';
		thediv.innerHTML=msg;}
	//thediv2.className ="";
	AddSort(id);
	SortPrice(id);
}


function AskContacts(obj)
{
$('.of').show();
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false; //эта проверка из-за глюков огнелиса

document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
offer="<table class='show_offers'>"+obj.parentNode.parentNode.parentNode.parentNode.childNodes[0].innerHTML+"<tbody>"+obj.parentNode.parentNode.innerHTML+"</tbody></table>";

var offer_tr=obj.parentNode.parentNode.innerHTML;
document.getElementById("offer_offer").innerHTML=offer;
var code=obj.name;
if (obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id!="RightHotel")
{

var stars=obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[0].childNodes[1].childNodes[1].innerHTML;
var name=obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[0].innerHTML;
if(!hasInnerText){
var hotelname=obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[0].childNodes[0].textContent;
} else{
var hotelname=obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[0].childNodes[0].innerText;
}


var svazki=obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[2].childNodes[0].innerHTML;
var id_str=obj.parentNode.parentNode.parentNode.parentNode.id;
var id=id_str.substring(6, id_str.length);
}
else 
{
if(!hasInnerText){
var name=$('.MainTitle')[0].textContent;
var hotelname=name;
var str=$(".IerarhHeader")[0].textContent;
} else{
var name=$('.MainTitle')[0].innerText;
var hotelname=name;
var str=$(".IerarhHeader")[0].innerText;
}


var svazki=str.substring(10, str.length);
var stars=$('#stars')[0].innerHTML;
var id_str=obj.parentNode.parentNode.parentNode.parentNode.id;
var id=id_str.substring(6, id_str.length);
}
var turop=obj.id;
var price=obj.innerHTML;
var food=obj.parentNode.parentNode.childNodes[1].innerHTML;
var room=obj.parentNode.parentNode.childNodes[0].innerHTML;
var datas=obj.parentNode.parentNode.childNodes[3].innerHTML;
var datapo=obj.parentNode.parentNode.childNodes[4].innerHTML;
var vzr=$("#vzr").val();
var child=$("#child").val();
var link=window.location.href;

document.getElementById("hotel_offer").innerHTML=name+"&nbsp;&nbsp;&nbsp;"+stars+"&nbsp;&nbsp;&nbsp;<br />"+svazki;
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='code' value='"+code+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='turop' value='"+turop+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='hotel_id' value='"+id+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='hotelname' value='"+hotelname+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='room' value='"+room+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='food' value='"+food+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datas' value='"+datas+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datapo' value='"+datapo+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='price' value='"+price+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";

}

function AskContactsOnRequest(obj)
{
$('.of').show();
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;

document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
//offer="<table class='show_offers'>"+obj.parentNode.parentNode.parentNode.parentNode.childNodes[0].innerHTML+"<tbody>"+obj.parentNode.parentNode.innerHTML+"</tbody></table>";
//offer_tr=obj.parentNode.parentNode.innerHTML;
//document.getElementById("offer_offer").innerHTML=offer;

var id_str=obj.id
var id=id_str.substring(4, id_str.length);

if (obj.parentNode.id!="RightHotel")
{
var stars=obj.parentNode.parentNode.childNodes[1].childNodes[1].innerHTML;
var name=obj.parentNode.parentNode.parentNode.childNodes[1].childNodes[0].innerHTML;
var svazki=obj.parentNode.parentNode.parentNode.childNodes[2].childNodes[0].innerHTML;
if(!hasInnerText){
var hotelname=obj.parentNode.parentNode.parentNode.childNodes[1].childNodes[0].textContent;
} else{
var hotelname=obj.parentNode.parentNode.parentNode.childNodes[1].childNodes[0].innerText;
}

}
else
{
if(!hasInnerText){
var name=$('.MainTitle')[0].textContent;
var hotelname=name;
var str=$(".IerarhHeader")[0].textContent;
} else{
var name=$('.MainTitle')[0].innerText;
var hotelname=name;
var str=$(".IerarhHeader")[0].innerText;
}
var svazki=str.substring(10, str.length);
var stars=$('#stars')[0].innerHTML;
var id_str=obj.id;
var id=id_str.substring(4, id_str.length);
}

var datas=$("#datepicker_in").val();
var datapo=$("#datepicker_out").val();
var vzr=$("#vzr").val();
var child=$("#child").val();
var link=window.location.href;

document.getElementById("hotel_offer").innerHTML=name+"&nbsp;&nbsp;&nbsp;"+stars+"&nbsp;&nbsp;&nbsp;<br />"+svazki + "<br />ЗАПРОС: Для "+vzr+" взр. и "+child+" реб."+" c "+datas+" по "+datapo;
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='hotel_id' value='"+id+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='hotelname' value='"+hotelname+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datas' value='"+datas+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datapo' value='"+datapo+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";

}


function AskContactsSPO(obj)
{
$('.of').show();
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	
document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
var id=obj.id

if(!hasInnerText){
var spo_title=$('.MainTitle')[0].textContent;
} else{
var spo_title=$('.MainTitle')[0].innerText;
}



var vzr=$("#vzr").val();
var child=$("#child").val();
var link=window.location.href;

document.getElementById("hotel_offer").innerHTML=spo_title;

document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='spo_id' value='"+id+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='spo_title' value='"+spo_title+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";
}


function AskContactsTop(obj)
{
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
var vzr=$("#vzr").val();
var child=$("#child").val();
var link=window.location.href;
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";
$('.of').hide();
}


function AskContactsGarant(obj)
{
$('.of').show();
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	
document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
var id=obj.id;

if(!hasInnerText){
var spo_title=$('.MainTitle')[0].textContent;
} else{
var spo_title=$('.MainTitle')[0].innerText;
}


var link=window.location.href;

document.getElementById("hotel_offer").innerHTML=spo_title;
document.getElementById("hotel_offer").innerHTML+="<table class='lpad10 collapse' width='100%'><tbody><tr class='ubborder'>"+obj.parentNode.parentNode.parentNode.childNodes[1].innerHTML+"</tr><tr class='ubborder'>"+obj.parentNode.parentNode.previousElementSibling.innerHTML+"</tr></tbody></table>";
var code=obj.parentNode.parentNode.previousElementSibling.childNodes[5].childNodes[0].name;

document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='code' value='"+code+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='gar_id' value='"+id+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";

}




function AskContactsExcurs2(obj)
{
$('.of').show();
window.location.hash="";
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	
document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;

$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
$("#AskContactsIn").css('height','350px');
window.location.hash = '#AskContacts';
var offer="<table class='show_offers'><thead>"+obj.parentNode.parentNode.parentNode.childNodes[1].innerHTML+"</thead><tbody><tr>"+obj.parentNode.innerHTML+"</tr></tbody></table>";


document.getElementById("offer_offer").innerHTML=offer;



var id_pac=obj.parentNode.parentNode.parentNode.id;

if(!hasInnerText){
var price=obj.textContent;
var datastr=obj.parentNode.childNodes[1].textContent;
} else{
var price=obj.innerText;
var datastr=obj.parentNode.childNodes[1].innerText;
}

document.getElementById("hotel_offer").innerHTML=document.getElementById("title").innerHTML;

var datas=datastr.substr(0,5);

var datapo=datastr.substr(8,5);

switch (obj.className)
{
case "sgl":
	var vzr="1";
	var child="0";
	$('.show_offers>tbody>tr>td[class*="sgl"]').css("background-color",'#FFBF00');
	break;
case "dbl":
	var vzr="2";
	var child="0";
	$('.show_offers>tbody>tr>td[class*="dbl"]').css("background-color",'#FFBF00');
	break;
case "trp":
	var vzr="3";
	var child="0";
	$('.show_offers>tbody>tr>td[class*="trp"]').css("background-color",'#FFBF00');
	break;
case "dvao":
	var vzr="2";
	var child="1";
	$('.show_offers>tbody>tr>td[class*="dvao"]').css("background-color",'#FFBF00');
	break;
case "grupp":
	$('.show_offers>tbody>tr>td[class*="grupp"]').css("background-color",'#FFBF00');
	break;
}

var link=window.location.href;

//document.getElementById("hotel_offer").innerHTML=name+"&nbsp;&nbsp;&nbsp;"+stars+"&nbsp;&nbsp;&nbsp;<br />"+svazki;


document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='tur_id' value='"+id_pac+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='price' value='"+price+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datas2' value='"+datas+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datapo2' value='"+datapo+"' />";
if (obj.className!="grupp")
{
	document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
	document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
}
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";

}

function AskContactsExcurs(obj)
{
$('.of').show();
var hasInnerText =
	(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	
document.getElementById("AskContacts").innerHTML=document.getElementById("ETAskContacts").innerHTML;
$(function() {
		$('#defaultReal').realperson();
});
$("#AskContacts").show();
window.location.hash = '#AskContacts';
var offer="<table class='show_offers'><tbody><tr>"+obj.parentNode.innerHTML+"</tr><tr>"+obj.parentNode.nextElementSibling.innerHTML+"</tr></tbody></table>";
document.getElementById("offer_offer").innerHTML=offer;

var id_offer=obj.id;
var id_tur=obj.parentNode.id;
var code=obj.name;

if(!hasInnerText){
var price=obj.textContent;
} else{
var price=obj.innerText;
}

var datas=obj.parentNode.childNodes[5].childNodes[1].childNodes[3].childNodes[0].data;

var datapo=obj.parentNode.childNodes[5].childNodes[1].childNodes[3].childNodes[2].data;

var vzr=$("#vzr").text();
var child=$("#child").text();
var link=window.location.href;

//document.getElementById("hotel_offer").innerHTML=name+"&nbsp;&nbsp;&nbsp;"+stars+"&nbsp;&nbsp;&nbsp;<br />"+svazki;


document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='offer_id' value='"+id_offer+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='code' value='"+code+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='tur_id' value='"+id_tur+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='price' value='"+price+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datas' value='"+datas+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='datapo' value='"+datapo+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='vzr' value='"+vzr+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='child' value='"+child+"' />";
document.getElementById("contacts_form").innerHTML+="<input type='hidden' name='link' value='"+link+"' />";

}



$(document).ready(function(){
	$(document).mousemove(function(e){
		$("#loading")
			.css("top",(e.pageY)+0 + "px")
			.css("left",(e.pageX)+30 + "px");
	});
	

}); 

function checkCode(hashval,thisval)
{
$.post("ajax/realperson.php", {defaultRealHash:hashval,defaultReal:thisval},function(data) {if (data!='0') {$("#codestatus").removeClass();$("#codestatus").addClass("OK");checkorder();} else {$("#codestatus").removeClass();$("#codestatus").addClass("NOTOK");checkorder();};});

}

function checkName(checkval)
{validate=checkval.length;
	if (validate>0) {$("#namestatus").removeClass();$("#namestatus").addClass("OK");} else {$("#namestatus").removeClass();$("#namestatus").addClass("NOTOK");}
	checkorder();}
function checkEmail(checkval)
{
	validate=checkval.search("@");
	if (validate>-1) {$("#emailstatus").removeClass();$("#emailstatus").addClass("OK");} else {$("#emailstatus").removeClass();$("#emailstatus").addClass("NOTOK");}
	checkorder();
}
function checkPhone(checkval)
{
	validate=checkval.length;
	if (validate>6) {$("#phonestatus").removeClass();$("#phonestatus").addClass("OK");} else {$("#phonestatus").removeClass();$("#phonestatus").addClass("NOTOK");}
	checkorder();
}

function checkorder()
{if ($("#codestatus").hasClass("OK") && ($("#phonestatus").hasClass("OK") || $("#emailstatus").hasClass("OK")))
	{$("#order").removeClass();$("#order").addClass("CanOrder");}
	else
	{$("#order").removeClass();$("#order").addClass("CannotOrder");}
	}
function order() 
{
	checkorder();
	if ($("#order").hasClass("CanOrder"))
	$("#order")[0].parentNode.parentNode.parentNode.parentNode.parentNode.submit();
	//document.forms["contacts_form"][0].submit();
}

function Loading(tag)
{
if (tag==1)
{$("#AskContacts").show();
document.getElementById("AskContacts").innerHTML=document.getElementById("LoadingDIV").innerHTML;



$("#counter").everyTime('1s', 'timer', function(i) {
$(this).text(i); if((i==30)||(stc&&rsi)){$("#counter").stopTime('timer');$("#AskContacts").hide(2000); }}, 30);
//

}
else
{$("#AskContacts").hide();}
}

function removepoi(ssilka)
{SaveSession ('mesto','');
SaveSession ('poi','');
window.location.href=ssilka;}

