﻿$(document).ready(function() {
    var root = "/Temalar/2011/";
    //manşet
    //$("#featured > ul").tabs({ fx: { opacity: 'toggle'} }).tabs("rotate", 11000, true);
    $("#featured > ul").tabs({ event: 'mouseover' }).tabs("rotate", 11000, true);


    // kategori menü ---------->
    var kategori = $(".kategori-menu ul li");
    var i = 1;
    kategori.each(function() {
        $(this).append("<img src='" + root + "images/kate_menu/maskot/maskot_0" + i + ".png' alt='' class='maskot' />");
        i++;
    });

    function tumunuKapat() {
        kategori.each(function() {
            $(".maskot", this).stop(true, true).animate({ 'top': '0' }, 900);
        });
    }

    kategori.mouseover(function() { tumunuKapat(); $(".maskot", this).stop(true, true).animate({ 'top': '-40px' }, 300); }).mouseout(function() { $(".maskot", this).stop(true, true).animate({ 'top': '0' }, 500); });

    var rastgele = (Math.floor(Math.random() * 8) + 1);
    kategori.each(function() {
        if (rastgele == "") { rastgele = (Math.floor(Math.random() * 8) + 1); }
        if (rastgele.toString() == $(".maskot", this).attr("src").split('_')[2].replace(".png", "").replace("0", "")) {
            $(".maskot", this).stop(true, true).animate({ 'top': '-40px' }, 300);
        }
    })

    // başlık değişen slogan
    $('.mesaj ul').innerfade({
        speed: 'slow',
        timeout: 5000,
        animationtype: 'fade',
        type: 'random',
        containerheight: '45px'
    });

    // başlık değişen resim
    $('.degisenResimler ul').innerfade({
        speed: 'slow',
        timeout: 7000,
        type: 'sequence',
        containerheight: '148px'
    });

    // güncel haberler
    $(".guncelHaberler .menu li").each(function() {
        $(this).click(function() {
            var query = $(this).attr("id");
            ajaxPage("" + root + "AjaxPage/AnaSayfaTabs.aspx?Getir=" + query, ".guncelHaberler .liste");
            $(".guncelHaberler .menu li").removeClass("aktif");
            $(this).addClass("aktif");
        });
    });
    $(".guncelHaberler .menu #Guncel").addClass("aktif");
    ajaxPage("" + root + "AjaxPage/AnaSayfaTabs.aspx?Getir=Guncel", ".guncelHaberler .liste");

    // multimedya
    $(".mm .menu li").each(function() {
        $(this).click(function() {
            var query = $(this).attr("id");
            ajaxPage("" + root + "AjaxPage/AnaSayfaTabs.aspx?Getir=" + query, ".mm .liste");
            $(".mm .menu li").removeClass("aktif");
            $(this).addClass("aktif");
        });
    });
    $(".mm .menu #Fotograf").addClass("aktif");
    ajaxPage("" + root + "AjaxPage/AnaSayfaTabs.aspx?Getir=Fotograf", ".mm .liste");

    // ajax page
    function ajaxPage(sayfa, eleman) {
        var html = $.ajax({
            url: sayfa,
            cache: false,
            async: false
        }).responseText;
        $(eleman).empty();
        $(eleman).fadeOut().fadeIn().append(html);
    }

    if ((screen.width <= 1024) && (screen.height <= 768)) {
        $(".yan_maskot").css("display", "none");
    }

    // fotoğraf video anasayfa
    $("#fotoVideo").easySlider({
        auto: false,
        continuous: false,
        prevId: 'ileri',
        nextId: 'geri',
        controlsShow: false,
        speed: 2000,
        pause: 5000
    });

    $("#fotoVideo #ileri").attr("style", "background:url('" + root + "images/anasayfa-slider-aktif.png');");
    $("#fotoVideo #ileri a").attr("style", "color:white");

    $("#fotoVideo #ileri").click(function() {
        $(this).attr("style", "background:url('" + root + "images/anasayfa-slider-aktif.png');");
        $("a", this).attr("style", "color:white");
        $("#fotoVideo #geri").removeAttr("style");
        $("#fotoVideo #geri a").removeAttr("style");
    });
    $("#fotoVideo #geri").click(function() {
        $(this).attr("style", "background:url('" + root + "images/anasayfa-slider-aktif.png');");
        $("a", this).attr("style", "color:white");
        $("#fotoVideo #ileri").removeAttr("style");
        $("#fotoVideo #ileri a").removeAttr("style");
    });
});

//----
function balonGoster() {
    $("#balon").stop(true, true).animate({ opacity: "show" }, "slow");
    setTimeout("balonGizle()",5000);
}

function balonGizle() {
    $("#balon").animate({ opacity: "hide"}, "slow");
    setTimeout("balonGoster()", 5000);
}

setTimeout("balonGoster()", 5000);