// JavaScript Document
var tiklama=1;
$(document).ready(function () {
    //linklerin kenar cizgilerini kaldiriyor
    $("a").bind("focus", function () { if (this.blur) this.blur(); });
    $(document).pngFix();

    //$("#sub_content").css("display", "none").fadeIn(1000);
    
    $(document).keydown(function (event) { if (event.keyCode == 27) { popuphide(); infoboxhide(); } });

    $(".close_btn").click(function () {
        popuphide();
    });

    $("#page_up").click(function () {
        $.scrollTo("#main", 1500, { duration: 2500 });
    });

    $(".up_info_hata").delay(2000).fadeOut(7000);
    $(".up_info_uyari").delay(2000).fadeOut(7000);
    $(".up_info_tamam").delay(2000).fadeOut(7000);

    $(".up_info_hata").click(function () {
        $(this).hide();
    });

    $(".up_info_tamam").click(function () {
        $(this).hide();
    });


    $(".up_info_uyari").click(function () {
        $(this).hide();
    });

    var h = $(".content_right").height();
    if (h > 500) {
        $("#page_up").show();
    }

    var icerik_yuk = $(".content").height();
    if (icerik_yuk < 500) {
        $(".content").css({ "height": "500px" });
    }

    var icerik1_yuk = $(".content_right").height();
    if (icerik1_yuk < 500) {
        $(".content_right").css({ "height": "500px" });
    }

    var sol_taraf = $(".content_left").text();
    if (sol_taraf == "") {
        $(".content_right").css({ "float": "none", "margin-left": "0px", "width": "967px" });
        $(".content_left_bottom").css({ "width": "997px", "height": "10px", "float": "none" });
        $(".content_right_bottom").hide();
    }

    //------Sol Bolum Menu------//
    $(".sol_bolum .ana_menu ul").hide();
    if ($.cookie("cookieMenuID") == null || $.cookie("cookieMenuID") == "") {
        cookieMenuID = 0;
    } else {
        cookieMenuID = $.cookie("cookieMenuID");
    }
    $(".sol_bolum .ana_menu #ana_menu_id-" + cookieMenuID).parent().find("ul").show();
    $(".sol_bolum .ana_menu #ana_menu_id-" + cookieMenuID).addClass("aktif");
    $(".sol_bolum .ana_menu div").click(function () {
        if ($.cookie("cookieMenuID") == null || $.cookie("cookieMenuID") == "") {
            cookieMenuID = 0;
        } else {
            cookieMenuID = $.cookie("cookieMenuID");
        }
        iMenuID = this.id.replace("ana_menu_id-", "");
        if (iMenuID == cookieMenuID) {
            $(this).parent().find("ul").slideUp(300);
            $(this).removeClass("aktif");
            $.cookie("cookieMenuID", 0);
        } else {
            $(this).parent().find("ul").slideDown(300);
            $(this).addClass("aktif");
            $(".sol_bolum .ana_menu #ana_menu_id-" + cookieMenuID).parent().find("ul").slideUp(300);
            $(".sol_bolum .ana_menu #ana_menu_id-" + cookieMenuID).removeClass("aktif");
            $.cookie("cookieMenuID", iMenuID);
        }
    });
    //------/Sol Bolum Menu------//

});

function popupshow() {
    $("#screenBack").fadeTo(200, 0.5, function () { $("#popup").fadeTo(200, 1); });
}

function popuphide() {
    $("#popup").fadeOut(200, function () { $("#screenBack").fadeOut(200); });
}
	
//Numeric Control
function fn_validateNumeric(thi) {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 46))
        event.returnValue = false;
    if (event.keyCode == 46 && instr(thi.value, ".") >= 0)
        event.returnValue = false;
}

//----E-Mail Control----//
function ePostaKont(eposta) {
    var duzenli = new RegExp(/^[a-z]{1}[\d\w\.-]+@[\d\w-]{3,}\.[\w]{2,3}(\.\w{2})?$/);
    return duzenli.test(eposta);
}
//----/E-Mail Control----//

// karakter sayısı
function Count(text, long) {
    var maxlength = new Number(long); // Change number to your max length.
    if (text.value.length > maxlength) {
        text.value = text.value.substring(0, maxlength);
        jAlert("warning", "Maximum " + long + " karakter girebilirsiniz.", "Uyarı");
        document.getElementById("karakter").innerHTML = '0';
    } else {
        document.getElementById("karakter").innerHTML = long - text.value.length;
    }
}

function contact_control() {
    var ad = document.getElementById("ad").value;
    var soyad = document.getElementById("soyad").value;
    var email = document.getElementById("email").value;
    var mesaj = document.getElementById("mesaj").value;

    if (ad == "") {
        $("#ad").css("border", "1px solid #f1a846");
        return false;
    } else if (soyad == "") {
        $("#soyad").css("border", "1px solid #f1a846");
        return false;
    }
    else if (!ePostaKont(email)) {
        $("#email").css("border", "1px solid #f1a846");
        return false;
    } else if (mesaj == "") {
        $("#mesaj").css("border", "1px solid #f1a846");
        return false;
    } else {
        return true;
    }
}
