var aktif = 1; var timer; var adet;

$(document).ready(function() {

    /* programlar */
    jQuery('#mycarousel').jcarousel({ visible: 5 });

    $("#mycarousel img").reflect({ height: 0.5, opacity: 0.5 });


    /*  manset  */
    $("#manset_big").show();
    $("#manset_big li").hide();
    $("#manset_big li:first").show();
    adet = $("#manset_big li").length;
    timer = setInterval(degistir, 6000);


    haber(1);

    //            $("#gundem").html("");
    //            $("#turkiye").html("");
    //            $("#dunya").html("");
    //            $("#ekonomi").html("");
    //            $("#spor").html("");
    //            $("#kultur-sanat").html("");
    //            $("#bilim").html("");

    var tabNo = location.hash;
    var idAdi = tabNo.replace('#', '');

    if (idAdi) {
    $.ajax({
        type: "POST",
        url: "ajax.aspx",
        data: "id=" + encodeURIComponent(idAdi),
        success: function(msg) {
            $("#" + idAdi).html(msg).show("fast");
            haber(1);

        } 
    });		
        }
                    //$("#load").css ({ display: "none"} );    
    
    
});

function haber(id) {
    renk(id);
    $("#manset_big li").css("display", "none");
    aktif = id;
    $("#manset_big li:nth-child(" + id + ")").css("display", "block");

    $("#manset_big span").css("top", "377px");

    $("#manset_big li:nth-child(" + id + ") span").animate({ "top": "290px" }, "slow");

    clearInterval(timer);
    timer = setInterval(degistir, 6000);

}


function degistir() {
    $("#manset_big li:nth-child(" + aktif + ")").css("display", "none");

    aktif = (aktif + 1) % adet;
    if (aktif == 0) aktif = adet;
    $("#manset_big li:nth-child(" + aktif + ")").css("display", "block");

    $("#manset_big span").css("top", "377px");

    $("#manset_big li:nth-child(" + aktif + ") span").animate({ "top": "290px" }, "slow")

    renk(aktif);

}

function renk(deger) {
    $("#manset_small li").css("border", "2px #aab2ba solid");
    $("#manset_small li:nth-child(" + deger + ")").css("border", "2px #fff solid");
}

function sayfalar() {
    var sayfa_no = "";
    for (var i = 1; i <= adet; i++) {
        sayfa_no += "<span class='sayfa' onclick=tikla(" + i + ")>" + i + "</span>"
    }
    $("#sayfa_no").html(sayfa_no);
}


$(function() {

    $('#container').tabs({
        fxFade: true,
        fxSpeed: 'fast',

        onShow: function() {

            $("#gundem").html("");
            $("#turkiye").html("");
            $("#dunya").html("");
            $("#ekonomi").html("");
            $("#spor").html("");
            $("#kultur-sanat").html("");
            $("#bilim").html("");

            var tabNo = location.hash;
            var idAdi = tabNo.replace('#', '');

            $.ajax({
                type: "POST",
                url: "ajax.aspx",
                data: "id=" + encodeURIComponent(idAdi),
                success: function(msg) {
                    $("#" + idAdi).html(msg).show("fast");
                    haber(1);

                    //$("#load").css ({ display: "none"} );
                } 
            });

        }
    });

});

