﻿
function Anmeldung_Registrieren(name, vorname, strasse, ort, telefon, email, pw, pw2) {
    if (name == "" || vorname == "" || strasse == "" || ort == "" || telefon == "" || email == "" || pw == "" || pw2 == "") {
        info('Es sind nicht alle Felder ausgefüllt');
    }
    else {
        $.ajax({
            type: "POST",
            url: "/Webservice.asmx/Anmeldung_Registrieren",
            data: "{'name' : '" + name +
              "', 'vorname': '" + vorname +
              "', 'strasse': '" + strasse +
              "', 'ort': '" + ort +
              "', 'telefon': '" + telefon +
              "', 'pw': '" + pw +
              "', 'pw2': '" + pw2 +
              "', 'email': '" + email + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                AjaxSucceeded(msg);
            },
            error: AjaxFailed
        });
    }
}

function LobTadel_Speichern(login, besid, lobid, name, geburtstag, lob, tadel) {
    if (name == "" || lob == "") {
        info('Es sind nicht alle Felder ausgefüllt');
    }
    else {
        $.ajax({
            type: "POST",
            url: "/Webservice.asmx/LobTadel_Speichern",
            data: "{'login' : '" + login +
              "', 'besid': '" + besid +
              "', 'lobid': '" + lobid +
              "', 'name': '" + name +
              "', 'geburtstag': '" + geburtstag +
              "', 'lob': '" + lob +
              "', 'tadel': '" + tadel + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                AjaxSucceeded(msg);
            },
            error: AjaxFailed
        });
    }
}

function MeineDaten_Speichern(login, name, vorname, strasse, ort, telefon, email) {
    if (name == "" || vorname == "" || strasse == "" || ort == "" || telefon == "" || email == "") {
        info('Es sind nicht alle Felder ausgefüllt');
    }
    else {
        $.ajax({
            type: "POST",
            url: "/Webservice.asmx/MeineDaten_Speichern",
            data: "{'login' : '" + getLoginData() +
              "', 'name' : '" + name +
              "', 'vorname': '" + vorname +
              "', 'strasse': '" + strasse +
              "', 'ort': '" + ort +
              "', 'telefon': '" + telefon +
              "', 'email': '" + email + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                AjaxSucceeded(msg);
            },
            error: AjaxFailed
        });
    }
}
function Passwort_Aendern(login, oldpw, pw, pw2, tbLoginId) {
    if (pw == "" || pw2 == "") {
        info('Es sind nicht alle Felder ausgefüllt');
    }
    else {
        $.ajax({
            type: "POST",
            url: "/Webservice.asmx/Passwort_Aendern",
            data: "{'login' : '" + getLoginData() +
              "', 'oldpw' : '" + oldpw +
              "', 'pw': '" + pw +
              "', 'pw2': '" + pw2 + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                if (msg.d.indexOf('/') > -1) {
                    var userkennung = msg.d.substring(msg.d.indexOf('/') + 1);
                    $(tbLoginId).val(userkennung);
                    msg.d = msg.d.substring(0, msg.d.indexOf('/'));
                }
                AjaxSucceeded(msg);
            },
            error: AjaxFailed
        });
    }
}

function AjaxSucceeded(result) {
    if (result.d != '') {
        info(result.d);
    }    
}
function AjaxFailed(result) {
    info(result.status + ' ' + result.statusText);
}

function info(msg) {
    //alert(msg);
    msg = "<p align='center'>" + msg + "<br /><br /><input type='button' value='OK' class='nyroModalClose' onclick='hideInfo();' /></p>";
    $.nyroModalManual({
        bgColor: '#3333cc',
        content: msg,
        bgColor: '#000000',
        autoSizable: false
    });
    
   // $('#messageBox').show().html(msg);
}
function hideInfo() {
    $('#messageBox').fadeOut();
}

