$(function() {  $("#acc_options").hide();  jQuery('a[@rel*=facebox]').facebox();  //$("#fs_date_from, #fs_date_to").datepicker({dateFormat: 'yy-mm-dd'});  //$("#main_search")[0].reset();      $("#date_chooser td").click(function(){    $("#date_chooser td").each(function(){      $(this).css({"background-color":"#fff"});      $(this).removeClass("selected");    });    load_acc_options($(this).parent().attr("tid"),$(this).parent().attr("zid"));    $(this).parent().children().each(function(){      $(this).css({"background-color":"#6AD2FC"});      $(this).addClass("selected");    });  });    $("#date_chooser td").mouseover(function(){    $("#date_chooser td").not(".selected").each(function(){      $(this).css({"background-color":"#fff"});    });    $(this).not(".selected").parent().children().each(function(){      $(this).css({"background-color":"#C5E1F7"});    });  });    /*  $("#main_search select, #main_search input").change(main_search);  $("#main_search input[type=checkbox]").click(main_search); 	 	  $("#fs_destination").change(function(){		get_lokalita($(this).val())	});  */    function slideTopOffer(){		$(".accordion.collapsed").not(":animated").one("mouseover", function(){	  	if($('#top_offer_left').css("height")){				$('#top_offer_left').css({height: $('#top_offer_left').innerHeight()});			}			$(".accordion").parent().children().filter(".accordion").toggleClass("expanded");			$(".accordion").parent().children().filter(".accordion").toggleClass("collapsed");			$(".accordion").parent().children().filter(".container").slideToggle(400);			slideTopOffer();		});	}		slideTopOffer();	//$('#top_offer_left').css({height: $('#top_offer_left').innerHeight()});	$('#top_offer_left').css({height: $('#top_offer_left').innerHeight()});	$('#tab_1').click();		$('.tab[class*=detail]').click(function(){		$(this).addClass("big");		$("#"+$(this).attr("tab")).show();		$('.tab[class*=detail]').not($(this)).each(function(){			$(this).removeClass("big");			$("#"+$(this).attr("tab")).hide();		});	});		// nastavenie filtra krajiny a lokality	var filter_krajina = document.location.toString().match(/[&\?]filter_krajina=[0-9]+/i);	var filter_lokalita = document.location.toString().match(/[&\?]filter_lokalita=[0-9]+/i);		if (filter_krajina != null && filter_lokalita != null) {		var search_filter = "&destination=" + filter_krajina.toString().match(/[0-9]+/).toString();		search_filter += "&location=" + filter_lokalita.toString().match(/[0-9]+/).toString();		loadSearchFilter(search_filter, true);	}		// nacitanie filtra z cookies 	else if(document.location.toString().match(/\/ponuka$/) != null)			loadSearchFilter(readFilterFromCookies(), true);		// prazdny filter	else		loadSearchFilter("&nocookies=1", false);		/*	{  	var searching = false;    $("#main_search select, #main_search input").each(function(){      if($("#fs_destination").val()!="0" && searching==false){        get_lokalita($("#fs_destination").val());      }    	if(!($(this).val()=="0" || $(this).val()=="") && searching==false && $(this).attr("type")!="checkbox"){    		searching = true;    		main_search();    	}    });	}	*/	});function loadSearchFilter(formData, onLoadSearch) {	$.ajax({		url: "htdocs/search.filter.php",		timeout: 30000,		data: formData,		type: "GET",		error: function() {},		success: function(result){			$("#main_search_container")				.html(result)				.find("#fs_destination")					.change(function() {						$("#fs_location").attr("disabled", "disabled");					})				.end()				.find("select")					.change(serializeAndSearch)				.end()				.find(":checkbox")					.click(serializeAndSearch)				.end()				.find("input.datefield")					.change(serializeAndSearch)				.end()				.find("input.pricefield")					.keydown(function(e) {						if (e.keyCode == 10 || e.which == 10 || e.keyCode == 13 || e.which == 13)							serializeAndSearch();					})				$("#fs_date_from, #fs_date_to").datepicker({dateFormat: 'yy-mm-dd'});				if (onLoadSearch)					main_search();		},		beforeSend: function() {},		complete: function() {}	});}function serializeAndSearch() {	loadSearchFilter($("#main_search").serialize(), true);}function setFilter(data) {	loadSearchFilter(data, true);}function readFilterFromCookies() {		var filter = null;	var search_filter = "";		filter = document.cookie.toString().match(/peknypobyt_filter_lastminute=[01]/i);	if (filter != null)		search_filter += "&lastm=" + (filter.toString().match(/1/) != null ? "y" : "");		filter = document.cookie.toString().match(/peknypobyt_filter_firstmoment=[01]/i);	if (filter != null)		search_filter += "&firstm=" + (filter.toString().match(/1/) != null ? "y" : "");		filter = document.cookie.toString().match(/peknypobyt_filter_typ=[0-9%C]+/i);	if (filter != null)		search_filter += "&type=" + filter.toString().match(/[0-9%C]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_krajina=[0-9]+/i);	if (filter != null)		search_filter += "&destination=" + filter.toString().match(/[0-9]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_lokalita=[0-9]+/i);	if (filter != null)		search_filter += "&location=" + filter.toString().match(/[0-9]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_pocetdni=[0-9]+/i);	if (filter != null)		search_filter += "&day_count=" + filter.toString().match(/[0-9]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_doprava=[0-9]+/i);	if (filter != null)		search_filter += "&transport=" + filter.toString().match(/[0-9]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_termin_od=[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]/i);	if (filter != null)		search_filter += "&date_from=" + filter.toString().match(/[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_termin_do=[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]/i);	if (filter != null)		search_filter += "&date_to=" + filter.toString().match(/[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_cena_od=[0-9]+/i);	if (filter != null)		search_filter += "&price_from=" + filter.toString().match(/[0-9]+/).toString();		filter = document.cookie.toString().match(/peknypobyt_filter_cena_do=[0-9]+/i);	if (filter != null)		search_filter += "&price_to=" + filter.toString().match(/[0-9]+/).toString();		return search_filter;}function main_search(get){		if(get=="[object Object]" || get==undefined){		get = "";	}	$.ajax({		url: "htdocs/service.search.php",		timeout: 180000,		type: "POST",		data: "action=main_search&"+$("#main_search").serialize()+get,		dataType: "html",		error: function() {			//alert("Dotaz zlyhal");		},		success: function(result){			$("#search_results").fadeOut(100,function(){				$("#search_results").html(result);				$("#search_results").fadeIn(100);				bindClick();			});					},		beforeSend: function() {			$("#special_offer").slideUp(300);			$("#tabContent").slideUp(300);			$("#search_results").fadeOut(50,function(){				$("#search_results").html("<img src='images/loading.gif' alt='loading...' />");				$("#search_results").fadeIn(100);			});		}	});	}/*function get_lokalita(id_country, setValue) {	if(id_country==0){		$("#fs_location").attr("disabled","disabled");	}else{		$.ajax({			url: "htdocs/service.search.php",			timeout: 180000,			type: "POST",			data: "action=get_lokalita&country="+id_country,			dataType: "json",			error: function() {				//alert("Dotaz zlyhal");			},			success: function(result){				var jsonObject = result;								$("#fs_location").children().not("[@value=0]").remove();								for (var i = 0; i < jsonObject.list_item.length; i++) {					var option = document.createElement("option");					option.setAttribute("value", jsonObject.list_item[i].text);					option.innerHTML = jsonObject.list_item[i].text;					document.getElementById("fs_location").appendChild(option);										if ((typeof setValue != "undefined") && (option.value.toLowerCase() == setValue))						$(option).attr("selected", "selected");									}   				if(i>0){										$("#fs_location").removeAttr("disabled");					if (typeof setValue != "undefined")						$("#fs_location").change();									}else{					$("#fs_location").attr("disabled","disabled");				}			},			beforeSend: function() {}		});	}}*/function get_data(id,pid,select) {	$.ajax({		url: "htdocs/search_ajax.php",		timeout: 30000,		type: "POST",		data: "action="+id+"&get="+pid,		dataType: "json",		error: function() {			//alert("Dotaz zlyhal");		},		success: function(result){			var jsonObject = result;			for (var i = 0; i < jsonObject.list_item.length; i++) {				var option = document.createElement("option");				option.setAttribute("value", jsonObject.list_item[i].id);				if(select==jsonObject.list_item[i].id){          option.setAttribute("selected","selected");        }				option.innerHTML = jsonObject.list_item[i].text;				document.getElementById(id).appendChild(option);			}         		},		beforeSend: function() {			$("#"+id).children().not("[@value=0]").remove();		}	});}function load_acc_options(tid,zid) {	$.ajax({		url: "htdocs/service.search.php",		timeout: 30000,		type: "POST",		data: "action=get_cennik&tid="+tid+"&zid="+zid,		dataType: "html",		error: function() {			//alert("Dotaz zlyhal");		},		success: function(result){			$("#cennik").html(result);			submit_order();		},		beforeSend: function() {			$("#cennik").html("<img src='images/loading.gif' alt='loading...' />");			$('.tab[tab*=cennik]').click();		},		complete: function() {		 			}	});}function submit_order() {  $("#submit_order").click(function(){    var send = true;    if($("#suhlas").attr("checked")!=true){      send=false;    }    $(".mandatory").each(function(){      if($(this).val()=="" || $(this).val()=="povinné"){        $(this).css({"color":"#f00"});        $(this).val("povinné");        send = false;      }    });    if (send){    	$.ajax({    		url: "htdocs/service.submit_order.php",    		timeout: 30000,    		type: "POST",    		data: "action=send_order&"+$("#send_order").serialize(),    		dataType: "text",    		error: function() {    			//alert("Dotaz zlyhal");    		},    		success: function(result){    		  $("#send_order")[0].reset();    		  $("#cennik").fadeOut(250,function(){            $("#cennik").html(result);            $("#cennik").fadeIn(250);          });    		},    		beforeSend: function() {    		},    		complete: function() {    		}    	});    }  });    $("#kf_priezvisko, #kf_telefon").focus(function(){    if ($(this).val()=="povinné"){      $(this).val("");      $(this).css({"color":"#000000"});    }  });    $("#suhlas").change(function(){    $("[@for=suhlas]").toggleClass("red");  });    $("input[price]").keyup(function(){    var finalPrice = 0;    $("input[price]").each(function(){      finalPrice += ($(this).attr("price")*$(this).val());    });    $("#finalPrice").val(finalPrice+" EUR");  });}var globZal = '';function selZalozka(id, go) {	$("#tabContent").slideDown(300);	if(id != globZal){		$('#tab_'+id).attr('class', 'tab big');		$('#tab_'+globZal).attr('class', 'tab');		globZal = id;				var data = '';				jQuery.ajax({			data: data,			url: 'services.php?get=search-type&show='+go,			type: 'POST',			timeout: 3000,								error: function() {				//alert('Dotaz zlyhal');			},			success: function(result) {				$('#tabContent').html(result);			},			beforeSend: function() {							},			complete: function() {							}		})	}}function clearFilter(){	$("#main_search")		.find(":checkbox").removeAttr("checked").end()		.find(":text").val("").end()		.find("select option[value=0], select option[value=]").attr("selected", "selected");}function selectOption(id,val){	$("#"+id+" option[value="+val+"]").attr("selected","selected");	$("#"+id).change();}function checkField(id){	$("#"+id).attr("checked","checked");}function bindClick(){	$("a.page_number").click(function(){	 	main_search("&page="+$(this).attr("href").match(/[0-9]+$/));	 	return false;	});}function incrementClickCounter(countryId) {	jQuery.ajax({		url: './htdocs/increment.click.counter.php?krajina='+countryId,		type: 'GET',		timeout: 3000,		error: function() {},		success: function(result) {},		beforeSend: function() {},		complete: function() {}	});	}function open_popup(go) {	window.open("popup.php?go=" + go, "peknypobytsk_popup", "width=700,height=450,top=130,scrollbars=1");}