﻿function il_dok() {


    $.ajax({

        type: 'POST',

        url: 'yonetim.aspx/ildok',

        data: "{ildok:'ildok'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {

            document.getElementById("bulundugu_il").options.length = 0;
            var sonuc = result.d;
            for (i = 0; i < sonuc.length; i += 2) {
                var option = document.createElement("option");
                option.appendChild(document.createTextNode(sonuc[i]));
                option.setAttribute("value", sonuc[i + 1]);
                document.getElementById("bulundugu_il").appendChild(option);
            }

        },

        error: function(result) {

            alert('Talep esnasinda sorun olustu. Yeniden deneyin');


        }

    });



}


function ilce_dok() {

    $.ajax({

        type: 'POST',

        url: 'yonetim.aspx/ilcedok',

        data: "{ilce:'" + document.getElementById("bulundugu_il").value + "'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {

            document.getElementById("bulundugu_ilce").options.length = 0;
            var sonuc = result.d;
            for (i = 0; i < sonuc.length; i += 2) {
                var option = document.createElement("option");
                option.appendChild(document.createTextNode(sonuc[i]));
                option.setAttribute("value", sonuc[i + 1]);
                document.getElementById("bulundugu_ilce").appendChild(option);
            }

        },

        error: function(result) {


            alert('Talep esnasinda sorun olustu. Yeniden deneyin');


        }

    });



}


function kurumdok() {

    $.ajax({

        type: 'POST',

        url: 'yonetim.aspx/kurumdok',

        data: "{}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function (result) {
            alert(result.d);

            $('#kurum_adi_textbox').autocomplete(result.d);


        },

        error: function (result) {


            alert('Talep esnasinda sorun olustu. Yeniden deneyin');


        }

    });

}


function kurumbilgigetir(rn) {

    $.ajax({

        type: 'POST',

        url: 'yonetim.aspx/kurumbilgigetir',

        data: "{id:'" + rn + "'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function (result) {


            var sonuc = result.d;
    
            for (i = 0; i < sonuc.length; i++) {
                $('#t' + (i)).html(sonuc[i]);
            }

        },

        error: function (result) {


            alert('Talep esnasinda sorun olustu. Yeniden deneyin');


        }

    });



}

function ekle(resim) {

    var adres = document.getElementById(resim).src;
    document.getElementById(resim).src = adres.replace("sepet=0", "sepet=1");
    document.getElementById(resim.replace("resim", "sa")).style.display = "none";
    document.getElementById(resim.replace("resim", "sk")).style.display = "block";
}
function kaldir(resim) {

    var adres = document.getElementById(resim).src;
    document.getElementById(resim).src = adres.replace("sepet=1", "sepet=0");
    document.getElementById(resim.replace("resim", "sa")).style.display = "block";
    document.getElementById(resim.replace("resim", "sk")).style.display = "none";

}

function kurum_kaydet() {

    $.ajax({

        type: 'POST',

        url: 'yonetim.aspx/kurumkaydet',

        data: "{kurum_adi:'" + document.getElementById("kurum_adi_textbox").value + "',adresi:'" + document.getElementById("adresi_textbox").value + "',il:'" + document.getElementById("bulundugu_il").value + "',ilce:'" + document.getElementById("bulundugu_ilce").value + "',telefon:'" + document.getElementById("telefon_textbox").value + "',fax:'" + document.getElementById("fax_textbox").value + "',email:'" + document.getElementById("email_textbox").value + "',yetkili:'" + document.getElementById("yetkili_textbox").value + "',vergidairesi:'" + document.getElementById("vergi_dairesi_textbox").value + "',vergino:'" + document.getElementById("vergi_numarasi_textbox").value + "'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {

            alert(result.d);
            

        },

        error: function() {

            alert('Talep esnasinda sorun olustu. Yeniden deneyin');

        }

    });

}




function SepeteEkle(urunkodu) {

    $.ajax({

        type: 'POST',

        url: '../sepet.aspx/SepeteEkle',

        data: "{urun_sk:'" + urunkodu + "',ipno:'" + ip() + "'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {
            SayiAl();
            SepetiGoster()
            //$('#sonuc').html(result.d);



        },

        error: function() {

            alert('Talep esnasinda sorun olustu. Yeniden deneyin');

        }

    });

}


function SayiAl() {

    $.ajax({

        type: 'POST',

        url: '../sepet.aspx/spet',

        data: "{urun_sk:'9'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {


            $('#urun_teklif').html(result.d);



        },

        error: function(xhr, ajaxOptions, thrownError) {
            alert(xhr.responseText);
            alert(thrownError);
        }


        /*   function() {

                alert('Talep esnasinda sorun olustu. Yeniden deneyin');

            }*/

    });

}


function SepettenKaldir(urunkodu) {

    $.ajax({

        type: 'POST',

        url: '../sepet.aspx/SepettenKaldir',

        data: "{urun_sk:'" + urunkodu + "'}",

        contentType: 'application/json; charset=utf-8',

        dataType: 'json',

        success: function(result) {
            SayiAl();
            //$('#sonuc').html(result.d);


        },

        error: function() {

            alert('Talep esnasinda sorun olustu. Yeniden deneyin');

        }

    });

}

function ipal() {

    if (tanim == true) {

        $.ajax({

            type: 'POST',

            url: '../sepet.aspx/ip',

            data: "{ipadres:'" + ip() + "',nerden:'" + document.title + "'}",

            contentType: 'application/json; charset=utf-8',

            dataType: 'json',

            success: function(result) {

                $('#sonuc').html(result.d);



            },

            error: function() {

                alert('Talep esnas&#305;nda sorun olustu. Yeniden deneyin');

            }

        });

        tanim = false;
    }

}


function degis(a) {
    switch (a) {
        case 'cop': document.getElementById("resim").src = "/media/slide/cop.jpg"; break;
        case 'bank': document.getElementById("resim").src = "/media/slide/bank.jpg"; break;
        case 'konteynir': document.getElementById("resim").src = "/media/slide/konteynir.jpg"; break;
        case 'oyun': document.getElementById("resim").src = "/media/slide/oyun.jpg"; break;
        case 'pergole': document.getElementById("resim").src = "/media/slide/pergole.jpg"; break;
        case 'aydinlatma': document.getElementById("resim").src = "/media/slide/aydinlatma.jpg"; break;
        case 'piknik': document.getElementById("resim").src = "/media/slide/piknik.jpg"; break;
        case 'kamelya': document.getElementById("resim").src = "/products/kolonpaint.aspx?file=/products/kamelya/1.jpg&en=190&boy=144"; break;


    }
}

