var tmp_page_promocje=0;
var allCity=new Array();
 
 
function change_block_promocje(u, max){
	
	for(i=0;i<max;i++){
		//$("#block_promocje_"+i).fadeOut("fast");
		$("#block_promocje_"+i).hide();
		$("#block_promocje_but_"+i).css("background", "#F1F1F1");
	}
	$("#block_promocje_"+u).show();
	$("#block_promocje_but_"+u).css("background", "#8EBF23");
return true;
}

function change_block_szukaj(u, max){
	
	for(i=0;i<max;i++){
		//$("#block_promocje_"+i).fadeOut("fast");
		$("#block_szukaj_"+i).hide();
		$("#block_szukaj_but_"+i).attr("class", "tab_deactiove");
	}
	$("#block_szukaj_"+u).css("display", "inline");
	$("#block_szukaj_but_"+u).attr("class", "tab_actiove");
return true;
}

function select_country_spa(){
	
	var options="";
	
	wartosc=$("#pcountry1").val();
	wartosc_region=$("#pregion1").val();
	if(wartosc==1){
		$("#region1").show();
	}else{
		$("#region1").hide();
	}
	
	options += '<option value="0">--------</option>';
	for( var i=0; i<allCity.length; i++){
		
		if(allCity[i]["pcountry"]==wartosc){
			if(wartosc_region=="0"){
				options += '<option value="'+allCity[i]["id"]+'">'+allCity[i]["name"]+'</option>';
				
			}else if(allCity[i]["pregion"]==wartosc_region){
				options += '<option value="'+allCity[i]["id"]+'">'+allCity[i]["name"]+'</option>';
			}
		
			
		}
		
	}

	$("#pcity_szukaj_1").html(options);
return true;
}


function select_country_hotel(){
	
		var options="";
	
	wartosc=$("#pcountry2").val();
	wartosc_region=$("#pregion2").val();
	if(wartosc==1){
		$("#region2").show();
	}else{
		$("#region2").hide();
	}
	
	options += '<option value="0">--------</option>';
	for( var i=0; i<allCity.length; i++){
		
		if(allCity[i]["pcountry"]==wartosc){
			if(wartosc_region=="0"){
				options += '<option value="'+allCity[i]["id"]+'">'+allCity[i]["name"]+'</option>';
				
			}else if(allCity[i]["pregion"]==wartosc_region){
				options += '<option value="'+allCity[i]["id"]+'">'+allCity[i]["name"]+'</option>';
			}
		
			
		}
		
	}

	$("#pcity_szukaj_2").html(options);
	
return true;
}

function parseDate(dateString)
{
	var str = new String(dateString);
	var array = str.split('-');
	if (array.length!=3)
		return null;
	var year = array[0];
	var month = array[1].charAt(0)=='0' ? parseInt(array[1].substr(1, 1)) : parseInt(array[1]);
	var day = array[2].charAt(0)=='0' ? parseInt(array[2].substr(1, 1)) : parseInt(array[2]);
	var date = new Date(year, month-1, day);
	if (isNaN(date))
		return null;
	date.setHours(0);
	date.setMinutes(0);
	date.setSeconds(0);
	date.setMilliseconds(0);
	return date;
}

function onArrivalDateChange(id ,arrivalDate, data_now)
{
	var arrivalDate = parseDate(arrivalDate);
	if (arrivalDate==null)
	{
		alert('Nieprawidłowy format Data Przyjazdu.\n\nPrawidłowy format daty: YYYY-MM-DD.');
		$("#"+id).val(data_now);
		return false;
	}
	
	var today = new Date();
	today.setHours(0);
	today.setMinutes(0);
	today.setSeconds(0);
	today.setMilliseconds(0);
	
	if (arrivalDate < today)
	{
		alert('Data Przyjazdu nie może być wcześniejsza od daty dzisiejszej.');
		$("#"+id).val(data_now);
		return false;
	}
	
	return true;

}

function onDepartureDateChange(przyj, nocy, departureDate){
	var arrivalDate = parseDate(document.getElementById(przyj).value);
	if (arrivalDate==null)
	{
		alert('Nieprawidłowy format Daty Przybycia.\n\nPrawidłowy format daty: YYYY-MM-DD.');	
		return false;
	}
	var depDate = parseDate(departureDate);
	if (depDate==null)
	{
		alert('Nieprawidłowy format Daty Wyjazdu.\n\nPrawidłowy format daty: YYYY-MM-DD.');
		return false;
	}
	if (depDate <= arrivalDate)
	{
		alert('Data Wyjazdu musi być późniejsza od Daty Przybycia.');
		return false;	
	}
	if ((depDate-arrivalDate)/(1000*60*60*24) > 60)
	{
		alert('Data Wyjazdu nie może być późniejsza niż 60 dni od Daty Przybycia.');
		return false;
	}
	document.getElementById(nocy).value = Math.round((depDate.getTime() - arrivalDate.getTime())/(1000*60*60*24));
}

function pakiet_wew_but(id, key){
	//alert(id+" "+key);
	
	$("#pakiety_content_wew").html("<center><img src=\"/images/loading2.gif\" style=\"border: 0px none;\"></center>");
	$(".pakiet_wew_button").css("background", "#E8E8E8");
	$(".pakiet_wew_button").css("border-right", "1px solid #d3d3d3");
	$(".pakiet_wew_buttonP").css("background", "#FEFF9F");
	$(".pakiet_wew_buttonP").css("border-right", "1px solid #d3d3d3");
	
	$("#pakiety_content_wew").load("/ajax.php?etap=pakiety&id="+id);
	
	$("#pakiety_content_but_"+key).css("background", "#FFFFFF");
	$("#pakiety_content_but_"+key).css("border-right", "1px solid #FFFFFF");

	
	
	return false;
}

function pakiet_wew_but_new(id, key){
	//alert(id+" "+key);
	
	$("#pakiety_content_wew").html("<center><img src=\"/images/loading2.gif\" style=\"border: 0px none;\"></center>");
	$(".pakiet_wew_button_new").css("background", "#E8E8E8");
	$(".pakiet_wew_buttonP_new").css("background", "#FEFF9F");
	
	$("#pakiety_content_wew").load("/ajax.php?etap=pakiety&id="+id);
	
	$("#pakiety_content_but_"+key).css("background", "#FFFFFF");

	
	
	return false;
}

function zobacz_pokoje_pre(){
	var end=false;
	var select_sezon=0;
	
	var today = parseDate($("#date1").val());
	
	//alert(dump(date_parse));

	if(typeof(date_parse[5]) == 'object'){
		
		for(var z=0;z<date_parse[5].length;z++){
			if(date_parse[5][z][0]!=''){
				od_date=parseDate(date_parse[5][z][0]);
				do_date=parseDate(date_parse[5][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=5;
				}
				
				
			}
		}
	}
	
	if(typeof(date_parse[4]) == 'object' && end==false){
		//alert("1");
		for(var z=0;z<date_parse[4].length;z++){
			if(date_parse[4][z][0]!=''){
				od_date=parseDate(date_parse[4][z][0]);
				do_date=parseDate(date_parse[4][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=4;
				}
				
				
			}
		}
	}
	
	
	if(typeof(date_parse[1]) == 'object' && end==false){
		for(var z=0;z<date_parse[1].length;z++){
			if(date_parse[1][z][0]!=''){
				od_date=parseDate(date_parse[1][z][0]);
				do_date=parseDate(date_parse[1][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=1;
				}
				
				
			}
		}
	}
	
	
	if(typeof(date_parse[2]) == 'object' && end==false){
		for(var z=0;z<date_parse[2].length;z++){
			if(date_parse[2][z][0]!=''){
				od_date=parseDate(date_parse[2][z][0]);
				do_date=parseDate(date_parse[2][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=2;
				}
				
				
			}
		}
	}
	
	
	
	if(typeof(date_parse[3]) == 'object' && end==false){
		for(var z=0;z<date_parse[3].length;z++){
			if(date_parse[3][z][0]!=''){
				od_date=parseDate(date_parse[3][z][0]);
				do_date=parseDate(date_parse[3][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=3;
				}
				
				
			}
		}
	}
	
	
	//alert("wybrałeś sezon: "+select_sezon);
	//alert(dump(dane_pakiet["room"]));
	
	if(select_sezon>0 && typeof(dane_pakiet["room"][0]) == 'object'){ 
		options = '';
		
		for( var i=0; i<dane_pakiet["room"].length; i++){
				options += '<option value="'+dane_pakiet["room"][i]["id"]+'">'+dane_pakiet["room"][i]["romm_main"]+" - ";
				//alert("wybrałeś: "+dane_pakiet["room"][i]["id"]);
				if(dane_pakiet["room"][i]["romm_sub"]!=" ")
					options += dane_pakiet["room"][i]["romm_sub"]+" - ";
				
				if(dane_pakiet["promocja"]=="1"){
					options += dane_pakiet["room"][i]["psezon"+select_sezon] +" PLN ";
					
				}else{
					options += dane_pakiet["room"][i]["sezon"+select_sezon] +" PLN "; 
					
				}
				options +='</option>';
		}
	
		$("#kind_pokoju").html(options);
		$("#select_sezon").val(select_sezon);
		$("#reservation_button").show();
		refresh_info_cost_pre();
	}else{
		options = '<option value="0">Pakiet niedostępny w tym terminie / Package is unavailable in this term</option>';
		$("#kind_pokoju").html(options);
		$("#select_sezon").val("0");
		$("#reservation_button").hide();
		refresh_info_cost_pre();
	}
	
	
	return true;
}

function zobacz_pokoje(){
	var end=false;
	var select_sezon=0;
	
	var today = parseDate($("#date1").val());
	
	//alert(dump(date_parse));

	if(typeof(date_parse[5]) == 'object'){
		
		for(var z=0;z<date_parse[5].length;z++){
			if(date_parse[5][z][0]!=''){
				od_date=parseDate(date_parse[5][z][0]);
				do_date=parseDate(date_parse[5][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=5;
				}
				
				
			}
		}
	}
	
	if(typeof(date_parse[4]) == 'object' && end==false){
		//alert("1");
		for(var z=0;z<date_parse[4].length;z++){
			if(date_parse[4][z][0]!=''){
				od_date=parseDate(date_parse[4][z][0]);
				do_date=parseDate(date_parse[4][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=4;
				}
				
				
			}
		}
	}
	
	
	if(typeof(date_parse[1]) == 'object' && end==false){
		for(var z=0;z<date_parse[1].length;z++){
			if(date_parse[1][z][0]!=''){
				od_date=parseDate(date_parse[1][z][0]);
				do_date=parseDate(date_parse[1][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=1;
				}
				
				
			}
		}
	}
	
	
	if(typeof(date_parse[2]) == 'object' && end==false){
		for(var z=0;z<date_parse[2].length;z++){
			if(date_parse[2][z][0]!=''){
				od_date=parseDate(date_parse[2][z][0]);
				do_date=parseDate(date_parse[2][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=2;
				}
				
				
			}
		}
	}
	
	
	
	if(typeof(date_parse[3]) == 'object' && end==false){
		for(var z=0;z<date_parse[3].length;z++){
			if(date_parse[3][z][0]!=''){
				od_date=parseDate(date_parse[3][z][0]);
				do_date=parseDate(date_parse[3][z][1]);
				
				if(today>=od_date && today<do_date){
					end=true;
					select_sezon=3;
				}
				
				
			}
		}
	}
	
	
	//alert("wybrałeś sezon: "+select_sezon);
	//alert(dump(dane_pakiet["room"]));
	
	if(select_sezon>0 && typeof(dane_pakiet["room"][0]) == 'object'){ 
		options = '';
		
		for( var i=0; i<dane_pakiet["room"].length; i++){
				options += '<option value="'+dane_pakiet["room"][i]["id"]+'">'+dane_pakiet["room"][i]["romm_main"]+" - ";
				//alert("wybrałeś: "+dane_pakiet["room"][i]["id"]);
				if(dane_pakiet["room"][i]["romm_sub"]!=" ")
					options += dane_pakiet["room"][i]["romm_sub"]+" - ";
				
				if(dane_pakiet["promocja"]=="1"){
					options += dane_pakiet["room"][i]["psezon"+select_sezon] +" PLN ";
					
				}else{
					options += dane_pakiet["room"][i]["sezon"+select_sezon] +" PLN "; 
					
				}
				options +='</option>';
		}
	
		$("#kind_pokoju").html(options);
		$("#select_sezon").val(select_sezon);
		$("#reservation_button").show();
		refresh_info_cost_pre();
	}else{
		options = '<option value="0">Pakiet niedostępny w tym terminie / Package is unavailable in this term</option>';
		$("#kind_pokoju").html(options);
		$("#select_sezon").val("0");
		$("#reservation_button").hide();
		refresh_info_cost_pre();
	}
	
	
	return true;
}

function refresh_info_cost_pre(){
	var select_sezon=$("#select_sezon").val();
	var error=true;
	var out="";
	var out2="";
	var mnoznik=1;
	if($("#count_pakiet").val()!='undefine' && $("#count_pakiet").val()>0){
		mnoznik=parseInt($("#count_pakiet").val());
	}
	//alert($("#select_sezon").val());
	for( var i=0; i<dane_pakiet["room"].length; i++){
		if(dane_pakiet["room"][i]["id"]==$("#kind_pokoju").val()){
			error=false;
			
			out+='<div style="width: 240px; float: left; font-weight: bold; font-size: 14px;  text-decoration:line-through; margin-top: 0px; text-align: center;">';
			if(dane_pakiet["promocja"]=="1"){
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='<small>';
				out += (mnoznik*parseInt(dane_pakiet["room"][i]["sezon"+select_sezon])) +' PLN ';
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='</small>';
			}
			out += '</div>';
			
			out2 += '<div style="width: 240px;  float: left; color: #AF1564; font-weight: bold; font-size: 28px; text-align: center; margin: 0px;">';
			if(dane_pakiet["promocja"]=="1"){
				//alert('23');
				if(dane_pakiet["room"][i]["psezon"+select_sezon].length>4) out2+='<small>';
				out2 += (mnoznik*parseInt(dane_pakiet["room"][i]["psezon"+select_sezon])) +' PLN ';
				//out2 += "cos";
				if(dane_pakiet["room"][i]["psezon"+select_sezon].length>4) out2+='</small>';
			}else{
				//alert(dane_pakiet["room"][i]["sezon"+select_sezon].length);
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out2+='<small>';
				out2 += (mnoznik*parseInt(dane_pakiet["room"][i]["sezon"+select_sezon])) +' PLN ';
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out2+='</small>';
			}
			out2 += '</div>';
		}
			//alert(dane_pakiet["room"][i]["romm_sub"]);
	}
	if(error==true){
		out='<div style="width: 160px; float: left; color: #222222; font-weight: bold; font-size: 12px;  margin-top: 5px; text-align: right"> Niedostępny </div>';
	}
	
	$("#info_cost").html(out);
	$("#info_cost2").html(out2);
}


function refresh_info_cost(){
	var select_sezon=$("#select_sezon").val();
	var error=true;
	var out="";
	var mnoznik=1;
	if($("#count_pakiet").val()!='undefine' && $("#count_pakiet").val()>0){
		mnoznik=parseInt($("#count_pakiet").val());
	}
	//alert($("#select_sezon").val());
	for( var i=0; i<dane_pakiet["room"].length; i++){
		if(dane_pakiet["room"][i]["id"]==$("#kind_pokoju").val()){
			error=false;
			
			out+='<div style="width: 40%; float: left; font-weight: bold; font-size: 14px;  text-decoration:line-through; margin-top: 5px; text-align: right;">';
			if(dane_pakiet["promocja"]=="1"){
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='<small>';
				out += (mnoznik*parseInt(dane_pakiet["room"][i]["sezon"+select_sezon])) +' PLN ';
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='</small>';
			}
			out += '</div>';
			out += '<div style="width: 60%;  float: left; color: #AF1564; font-weight: bold; font-size: 20px; text-align: right;">';
			if(dane_pakiet["promocja"]=="1"){
				if(dane_pakiet["room"][i]["psezon"+select_sezon].length>4) out+='<small>';
				out += (mnoznik*parseInt(dane_pakiet["room"][i]["psezon"+select_sezon])) +' PLN ';
				if(dane_pakiet["room"][i]["psezon"+select_sezon].length>4) out+='</small>';
			}else{
				//alert(dane_pakiet["room"][i]["sezon"+select_sezon].length);
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='<small>';
				out += (mnoznik*parseInt(dane_pakiet["room"][i]["sezon"+select_sezon])) +' PLN ';
				if(dane_pakiet["room"][i]["sezon"+select_sezon].length>4) out+='</small>';
			}
			out += '</div>';
		}
			//alert(dane_pakiet["room"][i]["romm_sub"]);
	}
	if(error==true){
		out='<div style="width: 160px; float: left; color: #222222; font-weight: bold; font-size: 12px;  margin-top: 5px; text-align: right"> Niedostępny </div>';
	}
	
	$("#info_cost").html(out);
}

function test(){

return true;
}

function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}

function ChangePageOnHotelList(id_curent, id_max){
	for(tmp_i=0;tmp_i<=id_max;tmp_i++){
		$(".search_li_hotel_"+tmp_i).hide();
		$(".ButtonPageHotel").css("background", "transparent");
		$(".ButtonPageHotel").css("color", "#000000");
	}
	$(".search_li_hotel_"+id_curent).show();
	$("#ButtonPageDown_"+id_curent).css("background", "#BE1769");
	$("#ButtonPageDown_"+id_curent).css("color", "#FFFFFF");
	$("#ButtonPageTop_"+id_curent).css("background", "#BE1769");
	$("#ButtonPageTop_"+id_curent).css("color", "#FFFFFF");
	
	window.location.hash="#top_search_a";
}

function disabled_rate(id_kategori, id_rate){
	if($("#"+id_kategori).val()==2 || $("#"+id_kategori).val()==1){
		$("#"+id_rate).val("0");
		$("#"+id_rate).attr("disabled","true");
	}else{
		$("#"+id_rate).removeAttr("disabled","true");
	}
	
	
}

function theme_pakiet_spa(count, i){
	var tmp="";
	page='<div style="width: 380px; float: left; overflow: hidden; ';
	if(i%2==1){
		page+='margin-left: 10px;';
	}
	page+='">';
	
	page+='<div style="background: url(\'/images/bg_pakietSpa';
	if(count['polecany'])
		page+='P';
	page+='.gif\') no-repeat top center; width: 380px; height: 106px; margin-top: 10px; cursor: pointer;" class="search_li" id="search_div_' + i + '" onmouseover="$(this).css(\'background-position\',\'bottom center\');" onmouseout="$(this).css(\'background-position\',\'top center\');" onclick="location.href=\'/'+count['hotel_name_city']+'/'+count['hotel_cname']+',pakiety,'+count['id']+'\';"';
	
	
	if(count['Pname'].length>55)
		page+='title="'+count['Pname']+'"';
	page+='>';
	
	
	page+='<div style="clear: both; margin-top: 3px;"></div>';
	
	page+='<div style="margin-left: 4px; height: 15px; overflow: hidden;"><a href="/'+count['hotel_name_city']+'/'+count['hotel_cname']+',pakiety,'+count['id']+'" class="link_title" style="font-size: 12px;">'+count['Pname']+'</a></div>';
	page+='<div style="clear: both; margin-top: 3px;"></div>';
	
	///
	///	ZDJECIE
	///

	if(count['foto_exists'])
		page+='<div style="width: 94px; margin-left: 4px; float: left; overflow: hidden; margin-bottom: 3px;"><a href="/'+count['hotel_name_city']+'/'+count['hotel_cname']+',pakiety,'+count['id']+'" class="link_title"><img src="/photos_spa/'+count['id']+'.jpg" style="width: 90px;"></a></div>';
	
	
	
	////
	////	content
	////
	
	page+='<div style="width: ';
	if(count['foto_exists'])
		page+='278';
	else
		page+='370';
	page+='px; float: left; margin-left: 4px; text-align: left; overflow: hidden; ">';
	
	//$page.=$count['hotel_rate']; 

	
	page+='<div style="clear: both;"></div>';
	page+='<div class="info_adress" style="font-weight: bold;">';
	page+=count['hotel_name'];
	page+=count['hotel_rate'];
	page+='</div>';
	
	page+='<div style="clear: both;"></div>';
	page+='<div class="info_adress">';
	page+=count['hotel_country']+' » ';
	page+=count['hotel_city'];
	
	
	page+='</div>';
	
	page+='<div style="clear: both;"></div>';
	page+='<div style="margin-top: 5px;"></div>';
	
	page+='<div style="float: left; text-align: left; overflow: hidden; color: #64AF2B; font-weight: bold;">';
	page+='('+count['kategoria_name2']+')';
	page+='</div>';
	
	page+='<div>';
	
	page+='<div style="clear: both;"></div>';
	page+='<div style="margin-top: 5px;"></div>';
	
	
	page+='<span style="font-weight: bold;">'+count["kategoria_name"]+'</span>';
	
	if(count['promocja']=='1')
		page+='<div style="float: right; display: inline; margin-right: 10px;"><span style="font-weight: normal; color: #AF1564;">TANIEJ NIŻ W HOTELU</span></div>';
		
	page+='<div style="float: right; margin-right: 10px;">Cena od: ';
	if(count['promocja']=='1')
		page+='<span style="font-size: 11px; text-decoration: line-through;">'+count['od_cena']+' PLN</span> <span style="color: #AF1564; font-weight: bold;font-size: 13px; "> '+count['od_cenaP']+' PLN</span>';
		
	if(count['promocja']=='0')
		page+='<span style="font-weight: bold; color: #4F4F4F;font-size: 12px; ">'+count['od_cena']+' PLN</span>';
		
	page+='/os.</div>';	
	
	page+='</div>';


	page+='</div>';
		
	
	page+='</div>';

	
	page+='</div>';
	page+='</div>';
	
return page;
}

function by(i,dir) {
	return function(a,b){a = a[i];b = b[i];return a.toLowerCase() == b.toLowerCase() ? 0 : (a.toLowerCase() < b.toLowerCase() ? -1*dir : dir)}
}

function nu(i,dir) {
	return function(a,b){a = a[i];b = b[i];return (a-b)*dir}
}

function pakiet_filtr(){
	//$("#loading_search").css('display','block');
	//$("#fell_search").css("opacity","0.6");
	//alert("ASA");
	//wait(1000);
	z=0;
	var err="";
			
	if($('#sort_button_1').css('text-decoration')=="underline")
		SPA.sort(by("CPname",1));
	else if($('#sort_button_2').css('text-decoration')=="underline")
		SPA.sort(nu("pobyt",1));
	else
		SPA.sort(nu("od_cena",1));
		
	for( var i=0; i<SPA.length; i++){
		var stan=true;
		if($("#kategoria2").val()!=0 && SPA[i]["kategoria2"]!=$("#kategoria2").val()){
			stan=false;
		}
		if($("#kategoria").val()!=0 && SPA[i]["kategoria"]!=$("#kategoria").val()){
			stan=false;
		}
		if($("#pcountry1").val()!=0 && SPA[i]["hotel_pcountry"]!=$("#pcountry1").val()){
			stan=false;
		}
		if($("#pregion1").val()!=0 && SPA[i]["hotel_pregion"]!=$("#pregion1").val()){
			stan=false;
		}
		if($("#pcity_szukaj_1").val()!=0 && SPA[i]["hotel_pcity"]!=$("#pcity_szukaj_1").val()){
			stan=false;
		}
		
		if(stan){
			//alert('see');
			err+=theme_pakiet_spa(SPA[i], z);
			z++;
		}
	}
	
	if(z==0){
		err+='<div style="width: 780px; height: 5px; overflow: hidden; background: url(\'/images/bg_search_pakiet_top.gif\') no-repeat; margin-top: 10px;"></div>';
		err+='<div style="background: url(\'/images/bg_search_dark.gif\') repeat-y; font-size: 14px; text-align: center;" class="search_li" id="search_div_'+i+'">';
		err+='<br><b>Brak pakietów...</b><br><br>Prosimy zmienić parametry wyszukiwania<br><br>';
		err+='</div>';
		err+='<div style="width: 780px; height: 5px; overflow: hidden; background: url(\'/images/bg_search_pakiet_bottom.gif\') no-repeat; "></div>';
	}
	//$("#loading_search").hide();
	//$("#fell_search").html(err);
	
	document.getElementById('fell_search').innerHTML = err;
	$(".search_li").ToolTipDemo();
	$("#count_pakietow").html(z);
	//wait(1000);
	//$("#fell_search").css("opacity","1");
	return true;
}

function wait(msecs)
{
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{
cur = new Date().getTime();
} 
}
