﻿
//tablar
$(function() {
    //$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-left');
    $("#tabs").tabs().addClass('ui-tabs-horizantal ui-helper-clearfix');
    loadTab(1);
    oneridiv();
    function dynblink(sel, val) {

        TabbedPanels1.showPanel(0);
        document.getElementById('p1').style.display = 'none';
        document.getElementById('p2').style.display = 'block';
        intrvl = 0;
        document.getElementById('ctl00_Nav1_rbd').checked = true;

        for (nTimes = 0; nTimes < 3; nTimes++) {
            intrvl += 200;
            setTimeout("document.getElementById('ctl00_Nav1_b1').style.backgroundColor ='#f6edee';", intrvl);
            intrvl += 200;
            setTimeout("document.getElementById('ctl00_Nav1_b1').style.backgroundColor = '#ffffff';", intrvl);
        }
        var sel = document.getElementById(sel);
        for (var i = 0, limit = sel.options.length; i < limit; ++i) {
            if (sel.options[i].value == val)
                sel.options[i].selected = true;
        }

    }
    function tripdegistir(triptip) {
        var ttindex = triptip.selectedIndex;
        var secilentrip = triptip.options[ttindex].value;
        switch (secilentrip) {
            case "ROUNDTRIP":
                document.getElementById("donustarih").style.display = 'block';

                break;
            case "ONEWAY":
                document.getElementById("donustarih").style.display = 'none';
                break;
        }
    }
})

//ana menu
$(document).ready(function() {
    $("ul.subnav").parent().append("<span></span>");
    $("ul.topnav li span").mouseover(function() {
        $(this).parent().find("ul.subnav").slideDown('fast').show();
        $(this).parent().hover(function() {
        }, function() {
            $(this).parent().find("ul.subnav").slideUp('slow');
        });
    }).hover(function() {
        $(this).addClass("subhover");
    }, function() {
        $(this).removeClass("subhover");
    });
    $(".bizbuton").hover(function() { $(this).attr("src", "images/sa.gif"); }, function() { $(this).attr("src", "images/sa2.gif"); });
    $(".canlibutton").hover(function() { $(this).attr("src", "images/cd.gif"); }, function() { $(this).attr("src", "images/cd2.gif"); });
});

//çeşitli fonksiyonlar
$("#ctl00_txtAraAd").bind("change", function() { document.getElementById('ctl00_namead').value = $("#ctl00_txtAraAd").val(); });
$("#ctl00_txtAraSoyad").bind("change", function() { document.getElementById('ctl00_nameSoyad').value = $("#ctl00_txtAraSoyad").val(); });
$("#ctl00_txtAratel").bind("change", function() { document.getElementById('ctl00_nametel').value = $("#ctl00_txtAratel").val(); });
$("#ctl00_dropZaman").bind("change", function() { document.getElementById('ctl00_nameZaman').value = $("#ctl00_dropZaman").val(); });
$(function() {
    $.ui.dialog.defaults.bgiframe = true;
    $('#siziarayalim').dialog({ autoOpen: false });
    $('#axesskampanya').dialog({ autoOpen: false });
    $('#bsa').click(function() { $('#siziarayalim').dialog({ height: 500, width: 500 }).dialog('open'); });
    $('#ortdestek').click(function() { $('#siziarayalim').dialog({ height: 500, width: 500 }).dialog('open'); });
    $('#bsalt').click(function() { $('#siziarayalim').dialog({ height: 500, width: 500 }).dialog('open'); });
    $('#ortara').click(function() { $('#siziarayalim').dialog({ height: 500, width: 500 }).dialog('open'); });
    $('#sagreklam').click(function() { $('#axesskampanya').dialog({ height: 300, width: 800 }).dialog('open'); });
    $('#BtnSiziArayalim').click(function() {
        $('#bekletdiv').show();
        var dataString = 'islemler.ashx?adsoyad=' + $("input#txtAraAd").val() + " " + $("input#txtAraSoyad").val() + '&zaman=' + $('#dropZaman :selected').text() + '&gsm=' + $("input#txtAratel").val() + '&aramakaydet=kaydet';
        $.ajax({
            type: "POST",
            url: dataString,
            data: dataString,
            success: function(mesaj) {
                var options = { id: 'message_from_top',
                    position: 'top',
                    size: 50,
                    backgroundColor: 'red',
                    delay: 3500,
                    speed: 700,
                    fontSize: '20px'
                };
                $.showMessage(mesaj, options);
                $('#bekletdiv').hide();
                $('#siziarayalim').dialog('close');
            }
        });
    });
    $('#btngiris').click(function() {
        $('#bekletdiv').show();
        var dataString = 'islemler.ashx?user=' + $("input#txtuser").val() + '&pwd=' + $("input#txtpwd").val() + '&uyegiris=userlogin';
        $.ajax({
            type: "POST",
            url: dataString,
            data: dataString,
            success: function(mesaj) {
                var options = { id: 'message_from_top',
                    position: 'top',
                    size: 50,
                    backgroundColor: 'red',
                    delay: 3500,
                    speed: 700,
                    fontSize: '20px'
                };
                if (mesaj.toString().substring(mesaj.toString().length - 4, mesaj.toString().length) == "true") {
                    $('#uyeislemtip').html("Üye İşlemleri");
                    $('#uyelogintable').hide(); $('#uyeislemdetay').show();
                }
                $.showMessage(mesaj.substring(0, mesaj.toString().length - 4), options);
                $('#usrmform').html(mesaj);
            }
        });
    });
});


//slide, spot, duyuru, haftanın
$(document).ready(function() {
    $('#spothaber').jshowoff({ links: false, speed: 4000, controls: false, effect: 'slideLeft', cssClass: 'jshowoff2', hoverPause: false });
    $('#duyurular').jshowoff({ links: false, speed: 3000, controls: false, effect: 'slideLeft', cssClass: 'duyurular', hoverPause: false });
    $('#haftaurunleri').jshowoff({ links: false, speed: 3800, controls: false, effect: 'slideLeft', cssClass: 'duyurular', hoverPause: false });
    $('#haftaelemani').jshowoff({ links: false, speed: 4600, controls: false, effect: 'slideLeft', cssClass: 'duyurular', hoverPause: false });
});
// taber menu binder
var pageUrl = new Array();
pageUrl[1] = "searchpaket.aspx";
pageUrl[2] = "searchyurtici.aspx"; // pageUrl[2] = "searchkot.aspx";
pageUrl[3] = "searchucak.aspx";
pageUrl[4] = "searchotel.aspx";
pageUrl[5] = "searchucakotel.aspx";
pageUrl[6] = "searcharac.aspx";
pageUrl[7] = "searchgemi.aspx";


function loadTab(id) 
{
    if (pageUrl[id].length > 0) 
    {
        $("#preloader").show();

        $.ajax(
			        {
			            url: pageUrl[id],
			            cache: false,
			            success: function(message) {

			                $("#tabcontent-" + id).empty().html(message);
			                $("#preloader").hide();
			            }
			        });
    }
}
function oneridiv() {    
        $.ajax(
			        {
			            url: "kappaoneri.aspx",
			            cache: false,
			            success: function(message) {
			            $("#kappaoneriyor").empty().html(message);			                
			            }
			        });    
}
function prefillDest(id, hsehir, hskod, vsehir, vskod) {
    //var id=6;
    $("#tabs").tabs("option", "selected", 4);
    $("#preloader").show();
    $.ajax(
			        {
			            url: pageUrl[id],
			            cache: false,
			            success: function(message) {

			                $("#tabcontent-" + id).empty().html(message);
			                document.getElementById('uosehirgit').value = hsehir;
			                document.getElementById('Hiddenucakotelg').value = hskod;
			                document.getElementById('uosehirvar').value = vsehir;
			                document.getElementById('Hiddenucakotelv').value = vskod;
			                $("#preloader").hide();
			                var tarihfocus = document.getElementById("uot1");
			                tarihfocus.focus();
			            }
			        });
    //loadTab(6);


}

// floating yardım fonk
$(document).ready(function($) {
    var $floatingbox = $('#floating-box');
    if ($(document).height() > 0) {

        var bodyY = parseInt($('#parentDataList').offset().top) - 20;
        var originalX = $floatingbox.css('margin-left');
        $(window).scroll(function() {
            var scrollY = $(window).scrollTop();
            var isfixed = $floatingbox.css('position') == 'fixed';
            if ($floatingbox.length > 0) {
                if (scrollY > bodyY && !isfixed) {
                    $floatingbox.stop().css({
                        position: 'fixed',
                        display: 'block',
                        bottom: 0
                    });
                } else if (scrollY < bodyY && isfixed) {
                    $floatingbox.css({
                        position: 'relative',
                        display: 'none',
                        bottom: 0
                    });
                }
            }
        });
    }
});


//sol kategoriler
$(document).ready(function() {
    $("#1pane p.menu_head").mouseover(function() {
        $(this).css({ backgroundImage: "url(down.png)" }).next("div.menu_body").slideDown(100).siblings("div.menu_body").slideUp("slow").css('border-bottom', 'solid 1px #f0f0f0');
        $(this).siblings().css({ backgroundImage: "url(left.png) no-repeat 0px -5px;" });
    });
    $("#2pane p.menu_head").mouseover(function() {
        $(this).css({ backgroundImage: "url(down.png)" }).next("div.menu_body").slideDown(100).siblings("div.menu_body").slideUp("slow").css('border-bottom', 'solid 1px #f0f0f0');
        $(this).siblings().css({ backgroundImage: "url(left.png)" });
    });
    $("#3pane p.menu_head").mouseover(function() {
        $(this).css({ backgroundImage: "url(down.png)" }).next("div.menu_body").slideDown(100).siblings("div.menu_body").slideUp("slow").css('border-bottom', 'solid 1px #f0f0f0');
        $(this).siblings().css({ backgroundImage: "url(left.png)" });
    });
    $("#4pane p.menu_head").mouseover(function() {
        $(this).css({ backgroundImage: "url(down.png)" }).next("div.menu_body").slideDown(100).siblings("div.menu_body").slideUp("slow").css('border-bottom', 'solid 1px #f0f0f0');
        $(this).siblings().css({ backgroundImage: "url(left.png)" });
    });
    $("#5pane p.menu_head").mouseover(function() {
        $(this).css({ backgroundImage: "url(down.png)" }).next("div.menu_body").slideDown(100).siblings("div.menu_body").slideUp("slow").css('border-bottom', 'solid 1px #f0f0f0');
        $(this).siblings().css({ backgroundImage: "url(left.png)" });
    });
});

function paketgonder() {
    var u = document.getElementById('ulke').value;
	var b = document.getElementById('bolge').value; //document.getElementById('bolgevalue').value;           
    //var b = document.getElementById('bolgevalue').value;
    var t1 = document.getElementById('tarih1').value;
    var t2 = document.getElementById('tarih2').value;
    //alert($('input[name=group1]:checked').val());    
    //if (document.getElementById('donemsec').value == "") {
    if ($('input[name=group1]:checked').val() == "tarih") {
        var currentTime = new Date();
        var month = currentTime.getMonth() + 1;
        var day = currentTime.getDate();
        var year = currentTime.getFullYear();
        if (t1 == "") {
            t1 = day + "." + month + "." + year;
        }
        if (t2 == "") {
            t2 = day + "." + month + "." + 2015;
        }
        document.location.href = "http://www.kappatur.com/products.aspx?ulke=" + u + "&bolge=" + b + "&tarih1=" + t1 + "&tarih2=" + t2 + "&fiyat1=1&fiyat2=5000&nav=pakettur";
    }
    else 
    {
        var sorgu=document.getElementById('donemsec').value;
        var bir=sorgu.indexOf('&');
        var iki=sorgu.length;
        var temizsorgu=sorgu.substr(bir,iki-bir); 

       document.location.href = "http://www.kappatur.com/products.aspx?ulke=" + u + "&bolge=" + b  + temizsorgu.replace('t1', 'tarih1').replace('t2', 'tarih2') + "&fiyat1=49&fiyat2=5000&nav=pakettur";
    }
}
function otelgonder() {
    var u = document.getElementById('otelulke').value;
    var b = document.getElementById('sehirvalue').value;
    var t1 = document.getElementById('oteltarih1').value;
    var t2 = document.getElementById('oteltarih2').value;
    if (t1 == "" || t2 == "") {
        var currentTime = new Date();
        var month = currentTime.getMonth() + 1;
        var day = currentTime.getDate();
        var year = String(currentTime.getFullYear()).substring(2, 4);  //currentTime.getFullYear();        
        t1 = day + "/" + month + "/" + year; //.toString().substring(2,2);
        t2 = day + "/" + month + "/" + 15;
    }    
    document.location.href = "yurticihotel.aspx?ulke=" + u + "&sehir=" + b + "&tarih1=" + t1 + "&tarih2=" + t2 + "&fiyat1=1&fiyat2=5000&nav=yurticiotel";

}

