﻿var VisibleInfo = null;
var VisibleInfoCtrl = null;
var ActivateMember = false;

function prVisibleThisInfo(x) {
    if (VisibleInfo != null) {
        VisibleInfo.css('display', 'none');
    }
    VisibleInfo = $("#info_" + x);
    if (VisibleInfo == VisibleInfoCtrl) {
        VisibleInfoCtrl = null;
        return;
    }
    VisibleInfoCtrl = VisibleInfo;
    VisibleInfo.css('display', 'inline');
    VisibleInfo.html('<img src="i/loading.gif">');
    AjaxMethods.VisibleThisInfo(x, cbVisibleThisInfo);
}

function cbVisibleThisInfo(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    VisibleInfo.html(result.value);
}

function MOver(x) {
    if (x.src.indexOf('ovr') > 0)
        x.src = x.src.replace('ovr', 'out');
    else
        x.src = x.src.replace('out', 'ovr');
}

function MClick(x) {
    $('#liAnaSayfa').removeClass('sec');
    $('#liHakkimizda').removeClass('sec');
    $('#liFotograflar').removeClass('sec');
    $('#liOnlineKamera').removeClass('sec');
    $('#liPaketServis').removeClass('sec');
    $('#liIletisim').removeClass('sec');

    AjaxMethods.LinkClicked(x, GetContent); $('#li' + x).addClass('sec');
}

function GetContent(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function AClick(x) {
    AjaxMethods.ALinkClicked(x, AGetContent);
}

function A5Click(x, y, z) {
    AjaxMethods.A5LinkClicked(x, y, z, AGetContent);
}

function AGetContent(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentWindow").html(result.value);
}

function prLostPassword() {
    if ($('#UserName').val().length < 1) {
        alert('Lütfen kullanıcı adınızı giriniz!.');
        return
    }
    AjaxMethods.LostPassword($('#UserName').val(), cbLostPassword);
}

function cbLostPassword(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0')
        alert('Şifreniz mail adresinize gönderildi.')
    else
        alert('Yanlış kullanıcı adı. Lütfen doğru kullanıcı adını giriniz.');
}

function prReActivate() {
    if ($('#UserName').val().length < 1) {
        alert('Lütfen kullanıcı adınızı giriniz!.');
        return
    }
    AjaxMethods.ReActivate($('#UserName').val(), cbReActivate);
}

function cbReActivate(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0')
        alert('Aktivasyon kodunuz mail adresinize gönderildi.')
    else
        alert('Aktive edilmemiş böyle bir kullanıcı bulunmamaktadır. Lütfen doğru kullanıcı adını giriniz.');
}

var xi, yi;
function prAddShop(x, y) {
    xi = x;
    yi = y;
    AjaxMethods.ControlShopSpace(cbControlShopSpace);
}

function cbControlShopSpace(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0') {
        AjaxMethods.AddShop(xi, yi);
        AjaxMethods.LoadShopPanel(cbLoadShopPanel);
    }
    else {
        $("#ContentPanel").html(result.value);
    }
    xi = null;
    yi = null;
}

function prRemoveShop(x) {
    AjaxMethods.RemoveShop(x);
    AjaxMethods.LoadShopPanel(cbLoadShopPanel);
}

function prRemoveAllShop(x) {
    AjaxMethods.RemoveAllShop(x);
    AjaxMethods.LoadShopPanel(cbLoadShopPanel);
}

function prUpdateShop(x, y) {
    AjaxMethods.UpdateShop(x, y);
    AjaxMethods.LoadShopPanel(cbLoadShopPanel);
}

function prViewDetailsShop() {
    AjaxMethods.ViewDetailsShop(cbViewDetailsShop);
}

function cbViewDetailsShop(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function prEndShop() {
    AjaxMethods.ViewDetailsShop(cbViewDetailsShop);
}

function GoToMailSender(x, y) {
    if (x == 0) $("#ArticlesDetail").html('');
    AjaxMethods.AMailSender(x, y, cbAMailSender);
}

function cbAMailSender(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0|0|0|0') { alert('İşlem Tamamlandı'); return; }
    var x = result.value.split('|');
    if (x[0] * 1 == 1) {
        $("#ArticlesDetail").html($("#ArticlesDetail").html() + '<br>' + x[3] + ' - Gönderildi.');
        GoToMailSender(x[1], x[2]);
    }
    if (x[0] * 1 == -1) {
        $("#ArticlesDetail").html($("#ArticlesDetail").html() + '<br><font color="red">' + x[3] + ' - Gönderilemedi.</font>');
        GoToMailSender(x[1], x[2]);
    }
}

function GoToMailSenderPrv() {
}

function cbAMailingPrvSettings(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prAMailingPrvSettingsUpdate() {
    AjaxMethods.AMailingPrvSettingsUpdate($("#m_header").val(), $("#m_content").val(), cbAMailingPrvSettingsUpdate);
}


function cbAMailingPrvSettingsUpdate(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
}

function GoToSUpdate(x) {
    AjaxMethods.GoToSUpdate(x, cbGoToSUpdate);
}

function cbGoToSUpdate(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prAUpdateProductAll() {
    var PArr = $("#PArrAll").val().split('|');
    for (var i = 0; i < PArr.length; i++)
        AjaxMethods.AUpdateProductMini(PArr[i], $('#n_price_' + PArr[i]).val(), $('#n_bonus_' + PArr[i]).val(), $('#n_status_' + PArr[i]).is(':checked') ? 1 : 0, cbAUpdateProductAll);
    alert('Ürünler Güncellendi.');
}

function cbAUpdateProductAll(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
}

function openEdx(x) {
    $("#ArticlesDetail").html('<iframe src="/edxtr.aspx?ID=' + x + '" frameborder="0" scrolling="auto" noresize width="100%" height="100%"></iframe>');
}



function prGoToEndShop() {
    AjaxMethods.GoToEndShop(cbGoToEndShop);
}

function cbGoToEndShop(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0') {
        alert('Sepetinizde hiçbirşey bulunamadı. Lütfen sisteme giriş yapınız.');
        $('#UserName').focus();
        return;
    }
    if (result.value == '1') {
        alert('Lütfen sisteme giriş yapınız.');
        $('#UserName').focus();
        return;
    }
    $("#ContentPanel").html(result.value);
    try {
        $('input[name=chk_payment]').first().attr("checked", "checked");
        $('input[name=chk_addr]').first().attr("checked", "checked");
        // $('input[name=chk_payment]:checked').index(0).attr("checked", "checked");
    }
    catch (e) { }
}

function prEndOfShop() {
    var xn_usernaddress = '';
    var xn_usernaddresst = '';
    if ($('input[name=chk_addr]:checked').val() == 0) {
        xn_usernaddress = $("#n_usernaddress").val();
        xn_usernaddresst = $("#n_usernaddresst").val();
    }

    AjaxMethods.EndOfShop($('input[name=chk_payment]:checked').val(), $("#n_notes").val(), $('input[name=chk_addr]:checked').val(), xn_usernaddress, xn_usernaddresst, cbEndOfShop);
}

function cbEndOfShop(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0') {
        alert('Sepetinide hiçbirşey bulunamadı. Lütfen sisteme giriş yapınız.');
        $("#UserName").focus();
        return;
    }
    if (result.value == '1') {
        alert('Lütfen sisteme giriş yapınız.');
        $("#UserName").focus();
        return;
    }
    AjaxMethods.LoadShopPanel(cbLoadShopPanel);
    $("#ContentPanel").html(result.value);
}

function GetRadioValue(r) {
    var rv = null;
    for (var i = 0; i < r.length; i++) {
        if (r[i].checked)
            return r[i].value;
    }
    return rv;
}

function prActiveShop() {
    AjaxMethods.ActiveShop(cbActiveShop);
}

function cbActiveShop(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function prOldShop() {
    AjaxMethods.OldShop(cbOldShop);
}

function cbOldShop(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function cbNewMember(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function ContolAddr(x) {
    $("#n_usernaddress").attr('disabled', (x != 0) ? 'disabled' : '');
    $("#n_usernaddresst").attr('disabled', (x != 0) ? 'disabled' : ''); 
}

function ControlFormElement(e, a) {
    if (e.val().length == 0) {
        alert(a);
        e.focus();
        return false;
    }
    return true;
}

function prControlNewMember() {
    if (!ControlFormElement($("#n_name"), 'Lütfen adınızı giriniz.')) return;
    if (!ControlFormElement($("#n_sname"), 'Lütfen soyadınızı giriniz.')) return;
    if (!ControlFormElement($("#n_usermail"), 'Lütfen e-mail adresinizi giriniz.')) return;
    if (!ControlFormElement($("#n_username"), 'Lütfen kullanıcı adınızı giriniz.')) return;
    if (!ControlFormElement($("#n_userpass"), 'Lütfen şifenizi giriniz.')) return;
    if ($("#n_userpass").val() != $("#n_userpass2").val()) {
        alert('Şifreyi tekrar girişiniz hatalı.');
        return;
    }
    if (!ControlFormElement($("#n_phone"), 'Lütfen soyadınızı giriniz.')) return;
    if (!ControlFormElement($("#n_usernaddress"), 'Lütfen adresinizi giriniz.')) return;
    if (!ControlFormElement($("#n_usernaddresst"), 'Lütfen adresinizi kısaca tarif ediniz.')) return;

    AjaxMethods.ControlUserEMail($("#n_username").val(), $("#n_usermail").val(), $("#n_ctrl").val(), cbControlUserEMail);

}

function cbControlUserEMail(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '2') {
        alert('Girilen kod yanlış. Lütfen doğru kodu giriniz.');
        $("#n_ctrl").focus();
        $("#CodeDiv").html("<img src='JpegImage.aspx?" + (new Date()) + "' id='CtrlImage'>");
        return;
    }

    if (result.value == '-1') {
        alert('Girilen kullanıcı adı sistemde mevcut. Lütfen başka bir kullanıcı adı giriniz.');
        $("#n_username").focus();
        return;
    }

    if (result.value == '-2') {
        alert('Girilen email sistemde mevcut. Lütfen başka bir kullanıcı adı giriniz.');
        $("#n_usermail").focus();
        return;
    }
    if (result.value != '0') {
        alert('Lütfen uygun bir e-mail adresi giriniz.');
        $("#n_usermail").focus();
        return;
    }
    AjaxMethods.MemberOptions($("#n_name").val(), $("#n_sname").val(), $("#n_usermail").val(), $("#n_username").val(), $("#n_userpass").val(), $("#n_phone").val(), $("#n_usernaddress").val(), $("#n_usernaddresst").val(), cbMember);
}

function prControlUpdateMember() {
    if (!ControlFormElement($("#n_name"), 'Lütfen adınızı giriniz.')) return;
    if (!ControlFormElement($("#n_sname"), 'Lütfen soyadınızı giriniz.')) return;
    if (!ControlFormElement($("#n_usermail"), 'Lütfen e-mail adresinizi giriniz.')) return;
    if (!ControlFormElement($("#n_username"), 'Lütfen kullanıcı adınızı giriniz.')) return;
    if (!ControlFormElement($("#n_userpass"), 'Lütfen şifenizi giriniz.')) return;
    if ($("#n_userpass").val() != $("#n_userpass2").val()) {
        alert('Şifreyi tekrar girişiniz hatalı.');
        return;
    }
    if (!ControlFormElement($("#n_phone"), 'Lütfen telefon numaranızı giriniz.')) return;
    if (!ControlFormElement($("#n_usernaddress"), 'Lütfen adresinizi giriniz.')) return;
    if (!ControlFormElement($("#n_usernaddresst"), 'Lütfen adresinizi kısaca tarif ediniz.')) return;

    AjaxMethods.ControlUpdateEMail($("#n_username").val(), $("#n_usermail").val(), cbControlUpdateEMail);

}

function cbControlUpdateEMail(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }

    if (result.value == '-1') {
        alert('Girilen kullanıcı adı sistemde mevcut. Lütfen başka bir kullanıcı adı giriniz.');
        $("#n_username").focus();
        return;
    }

    if (result.value == '-2') {
        alert('Girilen email sistemde mevcut. Lütfen başka bir kullanıcı adı giriniz.');
        $("#n_usermail").focus();
        return;
    }
    if (result.value != '0') {
        alert('Lütfen uygun bir e-mail adresi giriniz.');
        $("#n_usermail").focus();
        return;
    }
    AjaxMethods.MemberOptions($("#n_name").val(), $("#n_sname").val(), $("#n_usermail").val(), $("#n_username").val(), $("#n_userpass").val(), $("#n_phone").val(), $("#n_usernaddress").val(), $("#n_usernaddresst").val(), cbMember);
}

function cbMember(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function prSendCustomerMail() {
    if (!ControlFormElement($("#n_name"), 'Lütfen adınızı giriniz.')) return;
    if (!ControlFormElement($("#n_sname"), 'Lütfen soyadınızı giriniz.')) return;
    if (!ControlFormElement($("#n_usermail"), 'Lütfen e-mail adresinizi numaranızı giriniz.')) return;
    if (!ControlFormElement($("#n_phone"), 'Lütfen telefon numaranızı giriniz.')) return;
    if (!ControlFormElement($("#n_notes"), 'Lütfen notunuzu giriniz.')) return;

    AjaxMethods.ControlCustomerMail($("#n_usermail").val(), cbControlCustomerMail);
}

function cbControlCustomerMail(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }

    if (result.value != '0') {
        alert('Lütfen uygun bir e-mail adresi giriniz.');
        $("#n_usermail").focus();
        return;
    }
    AjaxMethods.SendMail($("#n_name").val(), $("#n_sname").val(), $("#n_usermail").val(), $("#n_phone").val(), $("#n_notes").val(), cbSendMail);
}

function cbSendMail(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function prChangeMyDetail() {
    AjaxMethods.ChangeMyDetail(cbChangeMyDetail);
}

function cbChangeMyDetail(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentPanel").html(result.value);
}

function cbLoadingUserPanel(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#UserPanel").html(result.value);
}


function cbLoadShopPanel(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ShopPanel").html(result.value);
}

function cbLogIn(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    eval(result.value);
}

function cbLogOut(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    eval(result.value);
}

function cbGetMarquee(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#MarqueeDiv").html(result.value);
}

function Init() {
    if (!ActivateMember) MClick('AnaSayfa');
    AjaxMethods.LoadUserPanel('1', cbLoadingUserPanel);
    AjaxMethods.LoadShopPanel(cbLoadShopPanel);
    AjaxMethods.GetMarquee(cbGetMarquee);
    ActivateMember = false;
}

function AInit() {
    AjaxMethods.LoadAdminLogIn(cbLoadAdminLogIn);
}

function cbLoadAdminLogIn(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ContentWindow").html(result.value);
}

function ControlAdminLogon() {
    if (!ControlFormElement($("#uname"), 'Lütfen adınızı giriniz.')) return;
    if (!ControlFormElement($("#passwd"), 'Lütfen şifenizi giriniz.')) return;

    AjaxMethods.ControlAdmin($("#uname").val(), $("#passwd").val(), cbControlAdmin);
}

function cbControlAdmin(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value != '0') {
        alert('Hatalı Giriş.');
        $("#uname").focus();
        return;
    }
    $("#ContentWindow").html('');
}

function openImage(param) {
    newWindow = window.open("", "newWindow", "width=1,height=1");
    newWindow.document.open();
    newWindow.document.write('<html><title>][</title><head>');
    newWindow.document.write('<sc' + 'ript type="text/javasc' + 'ript">');
    newWindow.document.write('function reDimension(x, y){');
    newWindow.document.write('	window.resizeTo(x, y);');
    newWindow.document.write('	window.moveTo((screen.width - x)/2, (screen.height-y)/2);');
    newWindow.document.write('}');
    newWindow.document.write('</scr' + 'ipt>');
    newWindow.document.write('</head>	<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>');
    newWindow.document.write('<img src="' + param + '" onload="reDimension(this.width, this.height);">');
    newWindow.document.write('</body>	</html>');
    newWindow.document.close();
    newWindow.focus();
}

function mOvr(src, clrOver) {
    src.style.cursor = 'hand';
    src.bgColor = clrOver;
}

function mOut(src, clrIn) {
    src.style.cursor = 'default';
    src.bgColor = clrIn;
}

var stt = null;
function GoToPage(x, y, z) {
    stt = x;
    eval("AjaxMethods." + z + "(x, y, cbAGetStatus);");
}

function GoTo5Page(x, y, z, a, b, c) {
    stt = x;
    eval("AjaxMethods." + z + "(x, y, a, b, c, cbAGetStatus);");
}

function cbAGetStatus(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (stt != null) $("#Status" + stt).outerHTML = result.value;
    stt = null;
}

function prCourierSelect(x) {
    AjaxMethods.CourierSelect(x, cbCourierSelect);
}

function cbCourierSelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prMemberSelect(x) {
    AjaxMethods.AMemberSelect(x, cbMemberSelect);
}

function cbMemberSelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prADeleteMember(x) {
    if (confirm('Üye Kalıcı olarak Silinecektir.\n\nSilmek İstediğinizden Emin Misiniz?')) AjaxMethods.ADeleteMember(x, cbADeleteMember);
}
function cbADeleteMember(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    AClick(1);
}

function prAUpdateMember(x) {
    if (confirm('Üye bilgileri kalıcı olarak olarak değiştirilecektir.\n\nDeğiştirmek istediğinizden Emin Misiniz?')) AjaxMethods.AUpdateMember(x, $("#n_name").val(), $("#n_sname").val(), $("#n_usermail").val(), $("#n_username").val(), $("#n_userpass").val(), $("#n_phone").val, $("#n_usernaddressid").val(), $("#n_usernaddress").val(), $("#n_usernaddresst").val(), $("#n_userbonus").val(), $('#n_userstatus').is(':checked') ? "1" : "0", cbAUpdateMember);
}
function cbAUpdateMember(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    if (result.value == '0')
        alert('Bilgiler güncellendi');
    else
        alert('Bilgilerde bir hata mevcut, lütfen kontrol ederek tekrar deneyiniz.');
    AClick(1);
}

function prAUpdateCourier(x) {
    AjaxMethods.AUpdateCourier(x, $("#c_name").val(), $("#c_sname").val(), $('#c_status').is(':checked') ? 1 : 0, cbAUpdateCourier);
}

function cbAUpdateCourier(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(7);
}

function prReportCourier(x) {
    AjaxMethods.ReportCourier(x, $("#xday").val(), $("#xmonth").val(), $("#xyear").val(), $("#yday").val(), $("#ymonth").val(), $("#yyear").val(), cbReportCourier);
}

function cbReportCourier(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prShoppingSelect(x) {
    AjaxMethods.AShoppingSelect(x, cbAShoppingSelect);
}

function cbAShoppingSelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}


function prAGetSiparis(x, y, z) {
    AjaxMethods.AGetSiparis(x, y, z, cbAShoppingSelect);
}

function cbAGetSiparis(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function cbAShoppingSelectPR(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
    window.print(false);
}

function prChangeShopStatus(x) {
    AjaxMethods.AChangeShopStatus(x, $("#ShopStatus").val(), $("#Courier").val(), cbAChangeShopStatus);
}

function cbAChangeShopStatus(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(5);
}

function prAMailingSelect(x) {
    AjaxMethods.AMailingSelect(x, cbMailingSelect);
}

function cbMailingSelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prCategorySelect(x) {
    AjaxMethods.ACategorySelect(x, cbACategorySelect);
}

function cbACategorySelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prAUpdateCategory(x) {
    if (x == $("#n_category").val()) { alert('Kategoriyi seçimi hatalı'); return; }
    AjaxMethods.AUpdateCategory(x, $("#n_name").val(), $("#n_category").val(), $('#n_status').is(':checked') ? 1 : 0, cbAUpdateCategory);
}

function cbAUpdateCategory(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(2);
}

function prProductSelect(x) {
    AjaxMethods.AProductSelect(x, cbAProductSelect);
}

function cbAProductSelect(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    $("#ArticlesDetail").html(result.value);
}

function prAUpdateProduct(x) {
    AjaxMethods.AUpdateProduct(x, $("#n_name").val(), $("#n_category").val(), $("#n_info").val(), $("#n_price").val(), $("#n_photo").val(), $('#n_status').is(':checked') ? 1 : 0, $('#n_portion').is(':checked') ? 1 : 0, cbAUpdateProduct);
}

function cbAUpdateProduct(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(3);
}

function prADeleteProduct(x) {
    if (confirm('Ürün Kalıcı olarak Silinecektir.\n\nSilmek İstediğinizden Emin Misiniz?')) AjaxMethods.ADeleteProduct(x, cbADeleteProduct);
}

function cbADeleteProduct(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(3);
}

function prAUpdateMailing(x) {
    AjaxMethods.AUpdateMailing(x, $("#m_username").val(), $("#m_email").val(), cbAUpdateMailing);
}

function cbAUpdateMailing(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
    AClick(4);
}

function prADeleteMailing(x) {
    if (confirm('Mail Adresi Kalıcı olarak Silinecektir.\n\nSilmek İstediğinizden Emin Misiniz?')) AjaxMethods.ADeleteMailing(x, cbAUpdateMailing);
}

function prAUpdateProductPhoto(x) {
    var x = 335;
    var y = 170;
    window.open("../FileUpload.aspx?PID=" + x, "fU", "width=" + x + ",height=" + y + ", left=" + (screen.width - x) / 2 + ",  top=" + (screen.height - y) / 2);
}


function prAUptadePRGParameter() {
    AjaxMethods.AUptadePRGParameter($("#prmtr_0").val(), $("#prmtr_1").val(), $("#prmtr_2").val(), $("#prmtr_3").val(), $("#prmtr_4").val(), $("#prmtr_5").val(), $("#prmtr_6").val(), $("#prmtr_7").val(), $("#prmtr_8").val(), $("#prmtr_9").val(), cbAUptadePRGParameter);
}

function cbAUptadePRGParameter(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    alert(result.value);
}

function cbSetMailUserAP(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
}

function cbSetMailUserAllAP(result) {
    if (result.error != null) {
        alert('Hata!..');
        return;
    }
    AClick(4);
}



function anyMask(event, sMask) {
    var KeyTyped = String.fromCharCode(getKeyCode(event));
    var targ = getTarget(event);

    keyCount = targ.value.length;
    while (0 == 0) {
        if (keyCount < sMask.length - 1) {
            if ((sMask.charAt(keyCount) != '#') && (sMask.charAt(keyCount) != 'A') && (sMask.charAt(keyCount) != '?')) {
                targ.value += sMask.charAt(keyCount);
                keyCount++
            }
            else break;
        }
        else break;
    }
    keyCount = targ.value.length;

    if (sMask.charAt(keyCount) == '*') return true;
    if (sMask.charAt(keyCount) == KeyTyped) return true;
    if ((sMask.charAt(keyCount) == '#') && isNumeric(KeyTyped)) return true;
    if ((sMask.charAt(keyCount) == 'A') && isAlpha(KeyTyped)) return true;
    if ((sMask.charAt(keyCount) == '?') && isPunct(KeyTyped)) return true;
    if (KeyTyped.charCodeAt(0) < 32) return true;

    return false;
}

function getTarget(e) {
    if (e.srcElement) { return e.srcElement; }
    if (e.target) { return e.target; }
}

function getKeyCode(e) {
    if (e.srcElement) { return e.keyCode; }
    if (e.target) { return e.which; }
}

function isNumeric(c) {
    var sNumbers = "01234567890";
    if (sNumbers.indexOf(c) == -1) return false;
    else return true;
}

function isAlpha(c) {
    var lCode = c.charCodeAt(0);
    if (lCode >= 65 && lCode <= 122) { return true; }
    else return false;
}

function isPunct(c) {
    var lCode = c.charCodeAt(0);
    if (lCode >= 32 && lCode <= 47) { return true; }
    else return false;
}

function Change_Cam_Source(form) {
    document.applets.StreamApplet.ChangeCamSrc($('#srcSelect').val());
}
