﻿function opImage(imgCls) {
    $("." + imgCls).hover(function () {
        $(this).css("opacity", "0.7");
    },
    function () {
        $(this).css("opacity", "1");
    }
    );
}
function ililcesehirGetir() {
    $(".sehir").append("<option value='0'>Seçiniz</option>");
    $.getJSON("garantiShopAjax.ashx", { cmd: "sehir" }, function (JSON) {
        $.each(JSON.sehirler, function (i, sehir) {
            $(".sehir").append("<option value='" + sehir.sehirNo + "'>" + sehir.sehirAdi + "</option>");
        });
    });
    $(".sehir").change(function () {
        $(".ilce").empty();
        $(".ilce").removeAttr("disabled");
        $(".ilce").append("<option value='0'>Seçiniz</option>");
        var sehirNo = $(this).val();
        if (sehirNo != 0) {
            $.getJSON("garantiShopAjax.ashx", { cmd: "ilce", sehir: sehirNo }, function (JSON) {
                $.each(JSON.ilceler, function (i, ilce) {
                    $(".ilce").append("<option value='" + ilce.ilceNo + "'>" + ilce.ilceAdi + "</option>");
                });
            });
        }
    })
    $(".ilce").change(function () {
        $(".semt").empty();
        $(".semt").removeAttr("disabled");
        $(".semt").append("<option value='0'>Seçiniz</option>");
        var ilceNo = $(this).val();
        if (ilceNo != 0) {
            $.getJSON("garantiShopAjax.ashx", { cmd: "semt", ilce: ilceNo }, function (JSON) {
                $.each(JSON.semtler, function (i, semt) {
                    $(".semt").append("<option value='" + semt.semtNo + "'>" + semt.semtAdi + "</option>");
                });
            });
        }
    })
}
function kayitFormKontrol() {
    var hataMsg = "";
    $(".gerekli").each(function () {
        if ($(this).val() == "") {
            hataMsg += "<p>" + $(this).attr("title") + "</p>";
        }
    });
    $(".secilmeli").each(function () {
        if ($(this).val() == 0) {
            hataMsg += "<p>" + $(this).attr("title") + "</p>";
        }
    });
    var uzunluk = $(".boyut").val().length;
    if (uzunluk < 6) {
        hataMsg += "<p>" + $(".boyut").attr("title") + "</p>";
    }
    var tekrar = $(".tekrar").val();
    if (tekrar != $(".boyut").val()) {
        hataMsg += "<p>" + $(".tekrar").attr("title") + "</p>";
    }
    var mail = $(".mail").val();
    var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+.)+([.])+[a-zA-Z0-9.-]{2,4}$/;
    if (regex.test(mail) == false) {
        hataMsg += "<p>" + $(".mail").attr("title") + "</p>";
    }
    return hataMsg;
}

function queryStr(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function urunuSepeteAt() {
    $(".sepete-at").click(function () {
        var urunId = $(this).attr("id");
        urunId = urunId.replace("sepeteat-", "");
        location.href = "default.aspx?p=sepet&uid=" + urunId + "&adet=1";
    });
}
function urunuIncele() {
    $(".urunu-incele").click(function () {
        var urunId = $(this).attr("id");
        var urunIdArr = new Array();
        urunIdArr = urunId.split("&");
        location.href = "default.aspx?p=urundetay&ugi="+ urunIdArr[0] +"&augi="+ urunIdArr[1] +"&uid="+ urunIdArr[2] +"";
    })
}

