﻿
$(document).ready(function() {

$("#ctl00_ctMain_btnSave").click(function(e) {

        if ($("#ctl00_ctMain_txtUserName").val() == "") {
            jAlert("Lütfen bir kullanıcı adı tanımlayınız!", "takipet.com", function() {
                $("#ctl00_ctMain_txtUserName").focus();
            });
            return false;
        }

        if ($("#ctl00_ctMain_txtNameSurname").val() == "") {
            jAlert("Lütfen ad soyad alanını doldurunuz", "takipet.com", function() {
                $("#ctl00_ctMain_txtNameSurname").focus();
            });
            return false;
        }

        if ($("#ctl00_ctMain_txtEMail").val() == "" || !isValidEmailAddress($("#ctl00_ctMain_txtEMail").val())) {
            jAlert("Lütfen e-posta adresinizi kontrol ediniz!", "takipet.com", function() {
                $("#ctl00_ctMain_txtEMail").focus();
            });
            return false;
        }

        if ($("#memaggr2").attr('checked') == 0) {
            jAlert("takipet.com üyesi olabilmek için Kullanıcı Sözleşmesini onaylamanız gerekmektedir.", "takipet.com");
            return false;
        }

        return true;
    });

});



function controlUserName(txtUserName) {



    txtUserName = '#' + txtUserName;


    $(txtUserName).blur(function() {

        if ($(txtUserName).val() == "")
            return;

        $.ajax({
            url: 'XHR/_ctr_control_user_name.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'username=' + $(txtUserName).attr("value"),
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("Kullanıcı Adı Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz Kullanıcı Adı, başka bir üyemiz tarafından kullanılmaktadır', 'Takipet',
                     function() {
                         $(txtUserName).select();
                     });

                }
            }
        });



    });


}




function controlUserNameE(MID,txtUserName) {



    txtUserName = '#' + txtUserName;


    $(txtUserName).blur(function() {

        if ($(txtUserName).val() == "")
            return;

        $.ajax({
            url: 'XHR/_ctr_control_user_name.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'username=' + $(txtUserName).attr("value")+'&MID='+MID,
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("Kullanıcı Adı Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz Kullanıcı Adı, başka bir üyemiz tarafından kullanılmaktadır', 'Takipet',
                     function() {
                         $(txtUserName).select();
                     });

                }
            }
        });



    });


}


//*************************************************************************

function controlUserNameforAVM(txtUserName) {



    txtUserName = '#' + txtUserName;

  
        
    $(txtUserName).blur(function() {


        $.ajax({
            url: 'XHR/_ctr_control_user_name.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'username=' + $(txtUserName).attr("value"),
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("Kullanıcı Adı Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz Kullanıcı Adı, başka bir üyemiz tarafından kullanılmaktadır', 'takipet.com',
                     function() {
                         $(txtUserName).select();
                     });

                }
            }
        });



    });


}



//**********************************************************************
//**********************************************************************

function controlEMail(txtEmail) {



    txtEmail = '#' + txtEmail;



    $(txtEmail).blur(function() {

        if ($(txtEmail).val() == "")
            return;

        $.ajax({
            url: 'XHR/_ctr_control_email.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'email=' + $(txtEmail).attr("value"),
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("E-Posta Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz E-Posta, başka bir üyemiz tarafından kullanılmaktadır', 'Altapot',
                     function() {
                         $(txtEmail).select();
                     });

                }
            }
        });



    });


}


function controlEMailE(MID,txtEmail) {



    txtEmail = '#' + txtEmail;



    $(txtEmail).blur(function() {

        if ($(txtEmail).val() == "")
            return;

        $.ajax({
            url: 'XHR/_ctr_control_email.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'email=' + $(txtEmail).attr("value")+"&MID="+MID,
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("E-Posta Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz E-Posta, başka bir üyemiz tarafından kullanılmaktadır', 'Altapot',
                     function() {
                         $(txtEmail).select();
                     });

                }
            }
        });



    });


}
//***************************************************

function controlEMailforAVM(txtEmail) {



    txtEmail = '#' + txtEmail;

    $(txtEmail).blur(function() {


        $.ajax({
            url: '../AltapotRuntime/_ctr_control_email.aspx',
            type: 'GET',
            dataType: 'text',
            data: 'email=' + $(txtEmail).attr("value"),
            cache: false,
            timeout: 10000,
            beforeSend: function() {

                $("#loading").html("E-Posta Kontrol Ediliyor...");
                $("#loading").show();

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                $("#loading").hide();

            },
            success: function(ret) {


                $("#loading").hide();
                if (ret == "not") {

                    jAlert('Girmiş olduğunuz E-Posta, başka bir üyemiz tarafından kullanılmaktadır', 'Altapot',
                     function() {
                         $(txtEmail).select();
                     });

                }
            }
        });



    });


}





