// Javascript!
$(function () {
    /*
    Herhangi bir taga verilen HREF özniteliğini algılayar
    ve eğer değer boş değilse link olarak işlevsellik kazanmasını
    sağlar.
    */

    $("input").each(function (a, d) {
        if (($(d).val() == "") || ($(d).val() == undefined)) {
            if ($(d).attr("auto") != "") {
                $(d).val($(d).attr("auto"));
            }
        }
    }).focus(function () {
        if ($(this).val() == $(this).attr("auto")) {
            $(this).val("");
        }
    }).blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("auto"));
        }
    });

    $(".display-pane").click(function () {
        if ($(this).hasClass("open")) {
            $(this).removeClass("open");
            $(".login-block").stop().animate({ marginTop: 104 }, 500, "easeOutBack");
        } else {
            window.scrollTo(0, 0);

            var obj = document.getElementById('dvLoginContent');

            if (obj != null) {
                var html = document.getElementById('loginHTMLF').value;
                if (html != "")
                    obj.innerHTML = html;
                else {
                    var o = document.getElementById('name');
                    if (o != null)
                        o.focus();
                }
            }

            $(this).addClass("open");
            $(".login-block").stop().animate({ marginTop: 4 }, 500, "easeInBack");


        }
    });


    $(".search-input").focus(function () {
        $(this).stop().animate({ "width": "120px" });
    }).blur(function () {
        $(this).stop().animate({ "width": "50px" });
    });

    $(".head-banner-list li").each(function (index, element) {
        $(".jumper-menu").append("<li>" + (index + 1));
    });
    $(".jumper-menu li:first").addClass("active");

    $(".jumper-menu li").click(function () {
        $(".jumper-menu li").removeClass("active");
        $(this).addClass("active");
        idx = $(this).parent().children().index(this);
    });

    /*
    $(".big-menu li").click(function() {
    $(".big-menu li").removeClass("active");
    $(this).addClass("active");
    ndx = $(this).parent().children().index(this);
    $(".big-menu-blocks .big-menu-block").css("display","none");
    $(".big-menu-blocks .big-menu-block:eq("+ndx+")").css("display","inherit");		
    $(".big-menu-blocks .big-menu-block:eq("+ndx+") .block-image img:first").css("display","inherit");
    });
    */

    len = $(".jumper-menu li").length; autoVal = 6000; idx = 1;
    $(".main-carousel").jCarouselLite({
        visible: 1,
        auto: autoVal,
        btnGo: $(".jumper-menu li"),
        beforeStart: function () {
            idx = idx == len ? 0 : idx; idx++;
            $(".jumper-menu li").removeClass("active");
            $(".jumper-menu li:nth-child(" + idx + ")").addClass("active");
        }
    });

    $(".news-carousel").jCarouselLite({
        visible: 1,
        auto: 6000,
        btnNext: ".news-nav .next",
        btnPrev: ".news-nav .prev"
    });
    $(".news-carousel1").jCarouselLite({
        visible: 1,
        auto: 6000,
        btnNext: ".news-nav1 .next1",
        btnPrev: ".news-nav1 .prev1"
    });


    // $(".block-image img:eq("+$(".block-links ul li.active").parent().children(".active").index()+")").css("display","inherit");
    $(".block-links ul li").hover(function () {
        $(".block-image img").css("display", "none");
        $(".block-image img:eq(" + $(".block-links ul li").parent().children().index(this) + ")").css("display", "inherit");
    });

    $(".open-guide").click(function () {
        if ($(".left-top-menu.guide").hasClass("closed")) {
            $(".left-top-menu.guide").removeClass("closed");
        } else {
            $(".left-top-menu.guide").addClass("closed");
        }
    });

    $(".tab-menu li").click(function () {
        ndx = $(this).parent().children().index(this);
        $(".tab-menu li").removeClass("active");
        $(this).addClass("active");
        $(".tabs li").removeClass("active");
        $(".tabs li:eq(" + ndx + ")").addClass("active");
    });

    $(".optionbox").click(function () {
        $(".current").removeClass("current");
        $(this).addClass("current");
        base = 23;
        $("ul", this).css("z-index", "1000");
        $(".jump", this).css("z-index", "1100");
        $.each($(".optionbox"), function (ndx, val) {
            if (!$(val).hasClass("current")) {
                $(".optionbox ul").stop().animate({ height: base });
                $(val).removeClass("open");
                $("ul", val).css("z-index", "900");
                $(".jump", val).css("z-index", "980");
            } else {
            }
        });

        if ($(this).hasClass("open")) {
            $("ul", this).stop().animate({ height: base });
            $(this).removeClass("open");
        } else {
            count = $("ul li", this).length;
            $("ul", this).stop().animate({ height: (base * count) });
            $(this).addClass("open");
        }
        setTo = $("ul", this).attr("bind");
    });

    $(".optionbox ul li").click(function () {
        if (!$(this).hasClass("display")) {
            $(".display", $(this).parent()).html($(this).html());
            //$(setTo).val($(this).attr("value"));
        }
    });

    $(".bottom-tabs li").click(function () {
        $(".bottom-tabs li").removeClass("active");
        $(this).addClass("active");
        $(".bottom-tabs-blocks>div").css("display", "none");
        $(".bottom-tabs-blocks>div:eq(" + $(".bottom-tabs li").parent().children().index(this) + ")").css("display", "inherit");
    });
});

