$(document).ready(function(){
    $('.slider .owl-carousel').owlCarousel({
        items:1,
        autoplay:true,
        autoplayTimeout:7000,
        loop:true,
        margin:10,
        responsiveClass:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:1
            },
            1000:{
                items:1
            }
        }
    });
    $('.min-slider .owl-carousel').owlCarousel({
        loop:true,
        items:5,
        autoplay:true,
        autoplayTimeout:3000,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:3
            },
            1000:{
                items:5
            }
        }
    });
    $('.referanslar .owl-carousel').owlCarousel({
        loop:true,
        items:5,
        autoplay:true,
        autoplayTimeout:3000,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:3
            },
            1000:{
                items:5
            }
        }
    });
    $('.index-blog .owl-carousel').owlCarousel({
        loop:true,
        items:2,
        autoplay:true,
        autoplayTimeout:3000,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:2
            },
            1000:{
                items:2
            }
        }
    });
    $('.haberler .owl-carousel').owlCarousel({
        loop:true,
        items:1,
        autoplay:true,
        autoplayTimeout:3000,
        margin:10,
        nav:true
    });
    $('.detay-slider .owl-carousel').owlCarousel({
        items:1,
        autoplay:true,
        autoplayTimeout:4000,
        loop:true,
        margin:10,
        responsiveClass:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:1
            },
            1000:{
                items:1
            }
        }
    });

    $('.tel-menu span').click(function () {
        $('.open-menu').slideToggle(200);
    });
    // Call global the function
    $('.t-datepicker').tDatePicker({
        // options here
    });

    $('.tur_kategori_liste ul').readmore({speed: 500});
    $('.detay-bolmeler2 .icerik_bolmeler').readmore({
        speed: 500,
        collapsedHeight: 116,
        moreLink: '<ul><li><a href="#" class="tumu_bolmeler">Tümünü Göster <i class="fa fa-chevron-down" aria-hidden="true"></i></a></li></ul>',
        lessLink: '<ul><li><a href="#" class="tumu_bolmeler">Daha Az Göster <i class="fa fa-chevron-up" aria-hidden="true"></i></a></li></ul>',
    });

    //Hakkımızda Menu
    $(".tabContent").hide();
    $(".tabContent:first").show();
    $("#tab ul li:first").addClass("active");
    $("#tab ul li").click(function(){
        $("#tab ul li").removeClass("active");
        $(this).addClass("active");
        $(".tabContent").hide();
        var tab = $(this).index();
        $(".tabContent:eq("+tab+")").fadeIn();

    });
    //Hakkımızda Menu

    //Kategori
    $("figure").mouseleave(
        function () {
            $(this).removeClass("hover");
        }
    );

    // Add active class to the current button (highlight it)
    var header = document.getElementById("myDIV");
    var btns = header.getElementsByClassName("btn");
    for (var i = 0; i < btns.length; i++) {
        btns[i].addEventListener("click", function() {
            var current = document.getElementsByClassName("active");
            current[0].className = current[0].className.replace(" active", "");
            this.className += " active";
        });
    }

});

/* + Accordion */
$(function() {
    var Accordion = function(el, multiple) {
        this.el = el || {};
        this.multiple = multiple || false;

        // Variables privadas
        var links = this.el.find('.link');
        // Evento
        links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
    }

    Accordion.prototype.dropdown = function(e) {
        var $el = e.data.el;
        $this = $(this),
            $next = $this.next();

        $next.slideToggle();
        $this.parent().toggleClass('open');

        if (!e.data.multiple) {
            $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
        };
    }

    var accordion = new Accordion($('.accordion'), false);
});
/* / Accordion */

//Fiyat Aralığı
$("#slider-range").slider({
    range: true,
    orientation: "horizontal",
    min: 0,
    max: 10000,
    values: [0, 10000],
    step: 100,

    slide: function (event, ui) {
        if (ui.values[0] == ui.values[1]) {
            return false;
        }

        $("#min_price").val(ui.values[0]);
        $("#max_price").val(ui.values[1]);
    }
});
//Fiyat Aralığı

//fancybox
$( '[data-fancybox="images"]' ).fancybox({
    caption : function( instance, item ) {
        var caption = $(this).data('caption') || '';

        if ( item.type === 'image' ) {
            caption = (caption.length ? caption + '<br />' : '') + '<a href="' + item.src + '">Download image</a>' ;
        }

        return caption;
    }
});
//fancybox

//tabmenu
function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
}













$(document).ready(function () {
    $('#m_kisi_id').click(function () {
        $(".hesapla").fadeIn(300);
    });
    $('.oda_ekle4').click(function () {
        $(".hesapla").fadeOut(200);
    });

    $('.cik').click(function() {
        $('.hesapla').fadeOut(200);
    });

    $('#m_kisi_id2').click(function () {
        $(".hesapla2").fadeIn(300);
    });
    $('.oda_ekle4').click(function () {
        $(".hesapla2").fadeOut(200);
    });

    $('.cik').click(function() {
        $('.hesapla2').fadeOut(200);
    });

//setInterval(function(){
//  $('#dongu_onecikanlar').click();
//}, 3000);
});

$(function() {
    var Accordion = function(el, multiple) {
        this.el = el || {};
        this.multiple = multiple || false;

        // Variables privadas
        var links = this.el.find('.link');
        // Evento
        links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
    }

    Accordion.prototype.dropdown = function(e) {
        var $el = e.data.el;
        $this = $(this),
            $next = $this.next();

        $next.slideToggle();
        $this.parent().toggleClass('open');

        if (!e.data.multiple) {
            $el.find('.m_submenu').not($next).slideUp().parent().removeClass('open');
        };
    }

    var accordion = new Accordion($('#accordion2'), false);

    jQuery(function($){
        $(".mask_tel").mask("0(999) 999 99 99",{placeholder:" "});
        $(".ktel").mask("0(999) 999 99 99",{placeholder:" "});
        $(".kdt").mask("00-00-0000",{placeholder:" "});
    });

});

$(function () {
    var sWidth = $(".slider_box").width();
    var len = $(".slider_box .silder_panel").length;
    var index = 0;
    var picTimer;
    var mtop = len - 12;

    // create button
    var btn = "<a class='prev'></a><a class='next'></a>";
    $(".slider_box").append(btn);
    // create navbar pictures
    for (var i = 0; i < len; i++) {
        $imgUrl = $(".silder_panel").eq(i).find("img").attr("src");
        // console.log($imgUrl)
        $navItem = '<div class="silder_nav_item"><img src="' + $imgUrl + '"></div>';
        $(".silder_nav").append($navItem);
    }

    $( ".silder_nav_item:last" ).after( $( "<a class='goster_nav'>" + mtop + "<br><i class='fa fa-chevron-down' aria-hidden='true'></i></a>" ) );

    // re-arrange slides
    $(".slider_box .silder_con").css({
        "width": sWidth * (len + 2),
        "left": -sWidth
    });
    $(".silder_panel").eq(0).clone().appendTo($(".silder_con"));
    $(".silder_panel").eq(len - 1).clone().prependTo($(".silder_con"));

    // hover
    $(".slider_box .silder_nav .silder_nav_item").click(function () {
        index = $(".slider_box .silder_nav .silder_nav_item").index(this);
        showPics(index);
    }).eq(0).trigger("mouseenter");

    // Prev
    $(".slider_box .prev").click(function () {
        index -= 1;
        showPics(index);
        // console.log(index);
        if (index == -1) {
            index = len - 1;
        }
    });
    if (len < 12) {
        $(".goster_nav").hide();
    }else {
        $(".silder_nav_item").slice(12, 100).hide();

        $(".goster_nav").click(function(){
            $(".silder_nav_item").slice(0, 100).fadeIn();
            $(".goster_nav").hide();
        });
    }

    // Next
    $(".slider_box .next").click(function () {
        index += 1;
        showPics(index);
        // console.log(index);
        if (index >= len) {
            index = 0;
        }
    });

    // autoplay
    // $(".slider_box").hover(function () {
    //     clearInterval(picTimer);
    // }, function () {
    //     // console.log("Start")
    //     showPics(index);
    //     picTimer = setInterval(function () {
    //         $(".slider_box .next").trigger("click");
    //     }, 4000);
    // }).trigger("mouseleave");

    // showPics
    function showPics(index) {
        // position
        var nowLeft = -(index + 1) * sWidth;
        if (nowLeft == 0) {
            $(".slider_box .silder_con").stop(true, false).animate({
                "left": nowLeft
            }, 300, function () {
                $(".slider_box .silder_con").stop(true, false).css("left", -sWidth * len);
            });
        } else if (nowLeft == -(len + 1) * sWidth) {
            $(".slider_box .silder_con").stop(true, false).animate({
                "left": nowLeft
            }, 300, function () {
                $(".slider_box .silder_con").stop(true, false).css("left", -sWidth);
            });
        } else {
            $(".slider_box .silder_con").stop(true, false).animate({
                "left": nowLeft
            }, 300);
        }
        if (index == -1) {
            index = len - 1;
        }
        if (index >= len) {
            index = 0;
        }
        // nav
        $(".slider_box .silder_nav .silder_nav_item").removeClass("current").eq(index).addClass("current");
        $(".slider_box .silder_nav .silder_nav_item").stop(true, false).animate({
            "opacity": "0.6"
        }, 300).eq(index).stop(true, false).animate({
            "opacity": "1"
        }, 300);
    }
});

sayac = 1;
function sayisal(){
    $(".sayisal_deger").val(sayac+" Oda"+" "+yetiskinsay+" Yetişkin"+" "+cocuksay+" Çocuk")
}
$(document).on("click", ".oda_ekle", function(){
    if (sayac <2) {
        sayac =  sayac +1;
        $(".yeni_odalar").append("<div class='arama_oda' style='width: 100%; float: left;' id='oda"+sayac+"'><div class='col-md-1 m1 text-center' style='line-height:50px; font-weight: 900;width: 100%; float: left;text-align: left;'>"+sayac+".ODA</div><div class='col-md-6 m1' style='float: left;' ><h2 style=' color: white;font-size: 15px; font-weight: 400; margin-bottom: 10px; width: 100%;'>Yetişkin </h2><select class='form-control kisi m_odaekle' id='otelYetiskin_"+sayac+"' name='yetiskinSayisi["+sayac+"]'><option value='1'>1 </option><option value='2'>2 </option><option value='3'>3 </option><option value='4'>4 </option></select></div><div class='col-md-6 m1' style='float: right;' ><h2 style='color: white;font-size: 15px; font-weight: 400; margin-bottom: 10px; width: 100%;  '>Çocuk </h2><select class='form-control cocuksay m_odaekle' id='otelCocuk_"+sayac+"'' data-id='"+sayac+"' name='cocukSayisi["+sayac+"]' onchange='OdaCocuk(this.value);'><option value='0'>0 </option><option value='1'>1 </option><option value='2'>2 </option></select></div><div class='cocuk_div' id='cocukdiv"+sayac+"'><div id='cocuk"+sayac+"1' class='col-md-6 m1' style='float:left;'><h2 style='color: white; font-size: 15px; margin-bottom:10px; margin-top: 10px;'>1.Çocuk Yaşı</h2><select id='otelCocuk1_2' style='width:100%;' name='1cocukYasi["+sayac+"]' class='form-control cocuk cocuk_box'><option value='0' hidden>1.Çocuk Yaşı</option><option value='1'>1 Yaşında</option><option value='2'>2 Yaşında</option><option value='3'>3 Yaşında</option><option value='4'>4 Yaşında</option><option value='5'>5 Yaşında</option><option value='6'>6 Yaşında</option><option value='7'>7 Yaşında</option><option value='8'>8 Yaşında</option><option value='9'>9 Yaşında</option><option value='10'>10 Yaşında</option><option value='11'>11 Yaşında</option><option value='12'>12 Yaşında</option><option value='13' >13 Yaşında</option><option value='14' >14 Yaşında</option><option value='15' >15 Yaşında</option><option value='16' >16 Yaşında</option><option value='17' >17 Yaşında</option></select></div><div id='cocuk"+sayac+"2' class='col-md-6 m1' style='float:left;'><h2 style= 'float: left;color:white;   font-size: 15px;margin-top: 10px;'>2.Çocuk Yaşı</h2><select style='width:100%;' id='otelCocuk2_2' name='2cocukYasi["+sayac+"]' class='form-control cocuk cocuk_box m_odaekle_float_r'><option value='0' hidden >2.Çocuk Yaşı</option><option value='1'>1 Yaşında</option><option value='2'>2 Yaşında</option><option value='3' >3 Yaşında</option><option value='4'>4 Yaşında</option><option value='5' >5 Yaşında</option><option value='6'>6 Yaşında</option><option value='7'>7 Yaşında</option><option value='8'>8 Yaşında</option><option value='9'>9 Yaşında</option><option value='10'>10 Yaşında</option><option value='11'>11 Yaşında</option><option value='12'>12 Yaşında</option><option value='13'>13 Yaşında</option><option value='14'>14 Yaşında</option><option value='15'>15 Yaşında</option><option value='16'>16 Yaşında</option><option value='17'>17 Yaşında</option></select></div></div><div class='col-md-1 m1 text-center sil_oda' style='float: left;width: 130px;cursor:pointer;clear: both;background: #c00;border: 1px solid #333;border-radius: 4px;padding: 10px;font-size: 13px;height: 40px;text-align: center;margin-left: 16px;margin-top: 10px;' sil-id='"+sayac+"'><i style='margin-right: 10px;' class='fa fa-minus' aria-hidden='true' ></i> Odayı Sil</div><div class='clearfix'></div></div>");
        sayisal();
    }
});

$(document).on("click", ".sil_oda", function(){
    var id = $(this).attr('sil-id');
    if (sayac > id ) {
        alert("Bu oda Silinemez")
    }else {
        sayac =  sayac -1;
        $("#oda"+id).remove();
        sayisal();
        say();
    }
});
var yetiskinsay = 0;
var cocuksay = 0;
function say(){
    yetiskinsay = 0;
    cocuksay = 0;
    $(document).find(".kisi").each(function(i){
        yetiskinsay = parseInt(yetiskinsay) + parseInt($(this).val());
    });
    $(document).find(".cocuksay").each(function(i){
        cocuksay = parseInt(cocuksay) + parseInt($(this).val());
    });
    sayisal();
};

$(document).on('change', 'select', function() {
    say();
});

$(document).on('change', '.cocuksay', function() {
    var id = $(this).attr('data-id');
    var evt = $(this).val();
    if(evt==1){
        $("#cocukdiv"+id).show();
        $("#cocuk"+id+"1").show();
        $("#cocuk"+id+"2").hide();
        $('.uyari').css('display','block');
    }else if(evt==2){
        $("#cocukdiv"+id).show();
        $("#cocuk"+id+"1").show();
        $("#cocuk"+id+"2").show();
        $('.uyari').css('display','block');
    }else{
        $("#cocukdiv"+id).hide();
        $("#cocuk"+id+"1").hide();
        $("#cocuk"+id+"2").hide();
    }
});
var cocuksayisi;
$(document).on("click", ".hizmet_btn", function(){
    var id = ($(this).attr('data-id'));
    $("#"+id).show();
});

$(document).on("click", ".hizmet_kapat", function(){
    var id = ($(this).attr('data-id'));
    $("#"+id).hide();
});

$(document).on('change', '.turcheck', function() {
    var fiyat =  ($(this).attr('data-fiyat'));
    var oda =  ($(this).attr('data-oda'));
    var total =  $("input[name=fiyat_al]").val();
    var ekhizmet = $(".ek_hizmet").html();
    var odaucret = $(".hodafiyat"+oda).val();
    var parabirimi = $("#parabirimi").val();
    if(this.checked) {
        $("input[name=fiyat_al]").val(parseFloat(total)+parseFloat(fiyat));
        $(".fiyat01").html(parseFloat(total)+parseFloat(fiyat) + " "+parabirimi);
        $(".ek_hizmet").html(parseFloat(ekhizmet)+parseFloat(fiyat));
        $(".hodafiyat"+oda).val(parseFloat(odaucret)+parseFloat(fiyat));
        $("#odafiyat"+oda).html(parseFloat(odaucret)+parseFloat(fiyat) + " "+parabirimi);
    }else {

        $("input[name=fiyat_al]").val(parseFloat(total)-parseFloat(fiyat));
        $(".fiyat01").html(parseFloat(total)-parseFloat(fiyat) +" "+parabirimi);
        $(".ek_hizmet").html(parseFloat(ekhizmet)-parseFloat(fiyat));
        $(".hodafiyat"+oda).val(parseFloat(odaucret)-parseFloat(fiyat));
        $("#odafiyat"+oda).html(parseFloat(odaucret)-parseFloat(fiyat) + " "+parabirimi);

        if($(".select-all[data-oda='"+oda+"']")[0].checked == true)
            $(".select-all[data-oda='"+oda+"']").trigger("click");
    }
});

$(document).on('change', '.select-all', function() {
    var fiyat =  $(this).val();
    var oda =  ($(this).attr('data-oda'));
    var total =  $("input[name=fiyat_al]").val();
    var ekhizmet = $(".ek_hizmet").html();
    var odaucret = $(".hodafiyat"+oda).val();
    var parabirimi = $("#parabirimi").val();
    if(this.checked) {
        $("input[name=fiyat_al]").val(parseFloat(total)-parseFloat(fiyat));
        $(".fiyat01").html(parseFloat(total)+parseFloat(fiyat) - " "+parabirimi);
        $(".ek_hizmet").html(parseFloat(ekhizmet)-parseFloat(fiyat));
        $(".hodafiyat"+oda).val(parseFloat(odaucret)-parseFloat(fiyat));
        $("#odafiyat"+oda).html(parseFloat(odaucret)-parseFloat(fiyat) + " "+parabirimi);
    }else {

        $("input[name=fiyat_al]").val(parseFloat(total)+parseFloat(fiyat));
        $(".fiyat01").html(parseFloat(total)+parseFloat(fiyat) +" "+parabirimi);
        $(".ek_hizmet").html(parseFloat(ekhizmet)+parseFloat(fiyat));
        $(".hodafiyat"+oda).val(parseFloat(odaucret)+parseFloat(fiyat));
        $("#odafiyat"+oda).html(parseFloat(odaucret)+parseFloat(fiyat) + " "+parabirimi);


    }
});
(function ($) {
    $.fn.countTo = function (options) {
        options = options || {};
        return $(this).each(function () {
            // set options for current element
            var settings = $.extend({}, $.fn.countTo.defaults, {
                from:            $(this).data('from'),
                to:              $(this).data('to'),
                speed:           $(this).data('speed'),
                refreshInterval: $(this).data('refresh-interval'),
                decimals:        $(this).data('decimals')
            }, options);
            // how many times to update the value, and how much to increment the value on each update
            var loops = Math.ceil(settings.speed / settings.refreshInterval),
                increment = (settings.to - settings.from) / loops;
            // references & variables that will change with each update
            var self = this,
                $self = $(this),
                loopCount = 0,
                value = settings.from,
                data = $self.data('countTo') || {};
            $self.data('countTo', data);
            // if an existing interval can be found, clear it first
            if (data.interval) {
                clearInterval(data.interval);
            }
            data.interval = setInterval(updateTimer, settings.refreshInterval);
            // initialize the element with the starting value
            render(value);
            function updateTimer() {
                value += increment;
                loopCount++;
                render(value);

                if (typeof(settings.onUpdate) == 'function') {
                    settings.onUpdate.call(self, value);
                }

                if (loopCount >= loops) {
                    // remove the interval
                    $self.removeData('countTo');
                    clearInterval(data.interval);
                    value = settings.to;
                    if (typeof(settings.onComplete) == 'function') {
                        settings.onComplete.call(self, value);
                    }
                }
            }
            function render(value) {
                var formattedValue = settings.formatter.call(self, value, settings);
                $self.html(formattedValue);
            }
        });
    };

    $.fn.countTo.defaults = {
        from: 0,               // the number the element should start at
        to: 0,                 // the number the element should end at
        speed: 1000,           // how long it should take to count between the target numbers
        refreshInterval: 100,  // how often the element should be updated
        decimals: 0,           // the number of decimal places to show
        formatter: formatter,  // handler for formatting the value before rendering
        onUpdate: null,        // callback method for every time the element is updated
        onComplete: null       // callback method for when the element finishes updating
    };

    function formatter(value, settings) {
        return value.toFixed(settings.decimals);
    }

}

(jQuery));

$("figure").mouseleave(function(){
    $(this).removeClass("hover");
});

jQuery(function ($) {
    // custom formatting example
    $('.count-number').data('countToOptions', {
        formatter: function (value, options) {
            return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
        }
    });
    // start all the timers
    $('.timer').each(count);
    function count(options) {
        var $this = $(this);
        options = $.extend({}, options || {}, $this.data('countToOptions') || {});
        $this.countTo(options);
    }
});

$(".Dropdown").on("click", function(){
    $(this).toggleClass('is-expanded');
});

$(".tur_box_ac").mouseover(function(){
    $(".tur_box_acik").slideDown();
    $(".turboxx").hide();
    $(".aaa").show();
});

$(".otel_box_ac").mouseover(function(){
    $(".otel_box_acik").slideDown();
    $(".otelboxx").hide();
    $(".bbb").show();
});

$(".tur_box_kapat").mouseover(function(){
    $(".tur_box_acik").slideUp();
    $(".turboxx").show();
    $(".aaa").hide();
});

$(".otel_box_kapat").mouseover(function(){
    $(".otel_box_acik").slideUp();
    $(".otelboxx").show();
    $(".bbb").hide();
});

$(document).on("click", "#ac", function(){
    $(".fc-listMonth-button").click();
});

$(document).on("click", ".tarih_btn", function(){
    var ID =($(this).attr('data-target'));
    var degis =($(this).attr('id'));
    if (degis=="farkli2") {
        document.getElementById("farkli2").className = "tarih_btn tarih_active";
        document.getElementById("farkli1").className = "tarih_btn";
        $("#farkli2").css({"border-left": "1px solid "});
        $("#farkli2").css({"border-right": "0px"});
    }
    if (degis=="farkli1") {
        document.getElementById("farkli1").className = "tarih_btn tarih_active";
        document.getElementById("farkli2").className = "tarih_btn";
    }
    //document.getElementById("a").className = "farkli";
    document.getElementById("a").className = "farkli";
    document.getElementById("b").className = " farkli";

    //document.getElementById("c").className = " farkli";
    document.getElementById(""+ID).className = "farkli farkli_active";
});

$(document).on("click", ".aramatab li", function(){
    var ID =($(this).attr('data-target'));
    document.getElementById("otel1").className="aramatab_li";
    document.getElementById("tur1").className="aramatab_li";
    document.getElementById("ucak1").className="aramatab_li";
    document.getElementById(""+ID+1).className="aramatab_li_active";
    document.getElementById("otel").className = "arama_tab_box";
    document.getElementById("tur").className = " arama_tab_box";
    document.getElementById("ucak").className = " arama_tab_box";
    document.getElementById(""+ID).className = "arama_tab_box arama_tab_box_active";
});

var snipid ;

var sniplistid ;

$(".snip1191").mouseover(function(){
    snipid =($(this).attr('data-id'));
    sniplistid =($(this).attr('id'));
    $("#"+snipid).css("top", "10%");
    $("."+sniplistid).css("display", "block");
});

$(".snip1191").mouseout(function(){
    $("#"+snipid).css("top", "35%");
    $("."+sniplistid).css("display", "none");
});

$(document).on("click", "#odaara", function(){
    var started_at = $("input[name=t-start]").val();
    var finished_at = $("input[name=t-end]").val();
    var type = "MinGunHesapla";
    var otel_id =$("#id").val();
    istekler =   {type:type,started_at:started_at,finished_at:finished_at,otel_id:otel_id};
    $.ajax({ // ajax işlemi başlar
        type:'GET', // veri gönderme tipimiz. g
        url:'/postBack.php', // post edilecek adres
        data:istekler,//post edilecek veriler
        success:function(cevap){
            if (cevap==1) {
            }else{
                swal(
                    'Gün Sınırlaması!',
                    cevap,
                    'error'
                )
            }
        }
    });
});

var frm = $('#contactForm1');
frm.submit(function (e) {
    e.preventDefault();
    $.ajax({
        type: frm.attr('method'),
        url: frm.attr('action'),
        data: frm.serialize(),
        success: function (data) {
            $(".getir").empty();
            $(".getir").append(data);
            $("#otel_ara").click();
            $(".cocuklar").hide();
        },
        error: function (data) {
            console.log('An error occurred.');
            console.log(data);
        },
    });
});

$.extend({
    getUrlVars: function(){
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for(var i = 0; i < hashes.length; i++)
        {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    },
    getUrlVar: function(name){
        return $.getUrlVars()[name];
    }
});

var byTarih = $.getUrlVar('tarih');
var byYetiskin = $.getUrlVar('yetiskinSayisi');
if(byTarih != '' && byTarih != null) {
    $.ajax({
        type: frm.attr('method'),
        url: frm.attr('action'),
        data: frm.serialize(),
        success: function (data) {
            $(".getir").empty();
            $(".getir").append(data);
            $("#otel_ara").click();
            $(".cocuklar").hide();
        },
        error: function (data) {
            console.log('An error occurred.');
            console.log(data);
        },
    });
}

$(document).ready(function () {
    $('.fav_close').on('click',function () {
        var favid = $(this).data('id');
        $('#fav-'+ favid).remove();
    })
    $('.favoriekle').click(function () {
        var id = $(this).data("id");
        var datatype = $(this).data("type");
        var durum = $(this).data("durum");
        var type = "favorieklecikart";
        istekler =   {type:type,id:id,ftype:datatype,durum:durum};
        $.ajax({ // ajax işlemi başlar
            type:'GET', // veri gönderme tipimiz.
            url:'/postBack.php', // post edilecek adres
            data:istekler,//post edilecek veriler
            success:function(cevap){
                if (cevap==1) {
                    swal(
                        'Favorilere Eklendi!',
                        '',
                        'success'
                    )
                    $("#favoridata"+id).data("durum",1);
                    $("#favyazi"+id).text("Favorilerimden Çıkart");
                }else{
                    swal(
                        'Favorilerden Çıkarıldı.',
                        '',
                        'error'
                    )
                    $("#favoridata"+id).data("durum",0);
                    $("#favyazi"+id).text("Favorilere Ekle");
                }
            }
        });
    });
});

$(document).ready(function () {
    $('.selectTourDate').click(function () {
        $('.spinner-overlay').show();
        $('.spinner-tour').show();
        var id = $(this).data('id');
        var date = $(this).data('date');
        $.post('/postBack.php', {type: 'GetTourDate', id: id}, function (res) {
            if(res)
            {
                var result = JSON.parse(res);
                // write in html
                $('.tour-date').html(date);
                $('.ucgen').html('% '+result.indirimyuzde);
                $('.fiyat del').html(result.fiyat+' '+result.parabirimi);
                $('.tur-fiyat').html(result.indirimli+' '+result.parabirimi);
                $('.minimalistBlack table').html(result.fiyatlar);
                $('#accordion2').html(result.ozellikler);
                $('.spinner-overlay').hide();
                $('.spinner-tour').hide();
                $('html, body').animate({scrollTop: 0}, 800);
            }
        });
    });
});

$('.cityTour li').click(function () {
    var type = $(this).data('type'),
        pathName = location.pathname.split('-');
    if(pathName[pathName.length - 1] === 'yurtici' || pathName[pathName.length - 1] === 'yurtdisi')
        pathName.splice(pathName.length - 1, 1);
    pathName[pathName.length] = type;
    var newUrl = location.protocol + '//' + location.host + pathName.join('-');
    window.history.pushState({}, null, newUrl);
});

function printDiv(divName) {
    $( "#t-pro-goster" ).trigger( "click" );
    var printContents = document.getElementById(divName).innerHTML;
    var originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;
}
