﻿function changeprdimg(img) { $("[id$=imgmodelbuyuk]").attr("src", $(img).attr("src")); }


function selectmodel(div) {
    //    var array = $("div[name=divkucukmodel]")
    //    $.each(array, function(anahtar, deger) { $("#" + deger.id).attr("class", "renk"); });
    //    $(div).attr("class", "renkselected");
    $("[id$=modelid]").val(div.id);
}

function listeislem(id, islem) {
    //EKLEME İŞLEMİNDE ID=0;

    var parametre, wsname, responseproc;

    if (islem == 'add') {
        var modelid = $("[id$=modelid]").val();
        if (modelid == -1) { alert("Lütfen model seçiniz."); return false; }
        wsname = "sepeteekle";
        parametre = "{'id':'" + $("[id$=modelid]").val() + "','adet':'" + $("[id$=adet]").val() + "'}";
        responseproc = function(s) { $("[id$=lblBasket]").html(s.d); alert("Seçtiğiniz modelden listenize " + $("[id$=adet]").val() + " adet eklendi."); }
    }
    else if (islem == 'remove') {
        wsname = "sepettencikar";
        parametre = "{'id':'" + id + "'}";
        responseproc = function(s) { $("#model" + id).fadeOut(); $("[id$=lblBasket]").html(s.d); }
    }

    $.ajax({
        type: "POST",
        url: "ajax/listproc.asmx/" + wsname,
        data: parametre,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            responseproc(msg);
        },
        error: function(e) {
            alert(wsname + " isimli servis şu an kullanılmamaktadır.\nLütfen bu bilgiyi yilmazbuhar@gmail.com adresine gönderiniz.");
        }
    });
    
}


function listupdate(modelid, islem) {
    var adet = $("#adet" + modelid).val();
    $.ajax({
        type: "POST",
        url: "ajax/listupdate.aspx",
        data: "a=" + adet + "&m=" + modelid + "&p=" + islem,
        success: function(s) {
            if (islem == "update") { $("#fiyat" + modelid).val(s); alert("Ürün adedi güncellendi"); }
        }
    });
}

function hideshowbasket() {
    $("[id$=basketbody]").slideToggle("slow");
}

function topmenushowcats(control, div) {

    var offset = $(control).offset();
    var div = $(div);

    div.css("top", offset.top + 32);
    div.css("left", offset.left + 1);
    div.fadeIn("slow");
}

function orderstatus() {
    $('.basketitem').each(function() {
        if ($(this).attr("title") == '1') { }
        else if ($(this).attr("title") == '2') { $(this).css("background-color", "#49bb87"); }
        else if ($(this).attr("title") == '3') $(this).css("background-color", "#bb4949"); $(this).css("color", "#ffffff")
    });
    //$(".basketitem:first").css("font-style", "italic");
}



