function showLoginForm() {
    // wyswietla formularz logowania
    //document.getElementById("nav").innerHTML =
    //    '<div id="login_form"><h4>Zaloguj się, aby móc edytować</h4>' +
    //    '    <p>Login: <input type="text" name="login" style="width:180px; position:absolute; right:0px"/></p>' +
    //    '    <p>Hasło: <input type="password" name="password" style="width:180px; position:absolute; right:0px"/></p>' +
    //    '    <div class="buttons">' +
    //    '       <input type="button" value="Anuluj" />' +
    //    '       <input type="button" value="Zaloguj" />' +
    //    '    </div>' +
    //    '</div>' +
    //    '<div id="info"></div>' +
    //    '<div id="echo"></div>';
    //return;
    document.getElementById("login_form").style.display = "block";
    document.getElementById("txtLogin").focus();
    document.getElementById("lnkZaloguj1").onclick = function() {hideLoginForm()};
    document.getElementById("lnkZaloguj2").onclick = function() {hideLoginForm()};
}

function hideLoginForm() {
    document.getElementById("login_form").style.display = "none";
    document.getElementById("lnkZaloguj1").onclick = function() {showLoginForm()};
    document.getElementById("lnkZaloguj2").onclick = function() {showLoginForm()};
}

function showInvitationForm() {
    document.getElementById("nav").innerHTML =
        '<div id="invitation"><h4>Wyślij zaproszenie</h4>' +
        '    e-mail: <input id="txtEmail" type="text" style="width:210px; margin-left:24px" />' +
        '    <div class="buttons">' +
        '       <input id="btnWyslij" type="button" value="Wyślij" onclick="sendInvitation();" />' +
        '       <input id="btnAnuluj" type="button" value="Anuluj" onclick="objSC.showDefaultNav();" />' +
        '    </div>' +
        '</div>' +
        '<div id="info"></div>' +
        '<div id="echo"></div>';
}

function sendInvitation() {
    var email = document.getElementById("txtEmail").value.split("@");
    if (document.getElementById("txtEmail").value == "") {
        alert("Nie podano adresu e-mail.");
        return;
    }
    else if (email.length != 2 || email[0] == "" || email[1] == "") {
        alert("Nieprawidłowy adres e-mail.");
        return;
    }
    var xmlhttp = GetXmlHttpObject();
    if (xmlhttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "src/user.php";
    url += "?f=3";
    url += "&m=" + document.getElementById("txtEmail").value;
    // porzucenie edycji jesli byla rozpoczeta
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 1) {
            document.getElementById("btnWyslij").value = "Czekaj";
            document.getElementById("btnWyslij").disabled = "disabled";
        }
        if (xmlhttp.readyState == 4) {
            objSC.showDefaultNav();
        }
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}

function logout() {
    var xmlhttp = GetXmlHttpObject();
    if (xmlhttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "src/schemas.php";
    url += "?f=8";
    url += "&sid=" + Math.random();
    // porzucenie edycji jesli byla rozpoczeta
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            var xmlhttp2 = GetXmlHttpObject();
            if (xmlhttp2 == null) {
                alert("Your browser does not support AJAX!");
                return;
            }
            var url2 = "src/user.php";
            url2 += "?f=2";
            url2 += "&sid=" + Math.random();
            // zakonczenie sesji
            xmlhttp2.onreadystatechange = function() {
                if (xmlhttp2.readyState == 4) {
                    window.location.replace("/");
                }
            };
            xmlhttp2.open("GET", url2, true);
            xmlhttp2.send(null);
        }
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}


