function register(nazwa) {
    document.getElementById('formRegisterBox' + nazwa).submit();
}
function unregister(nazwa, id) {
    var answer = confirm("Czy na pewno chcesz się wyrejstrować?")
    if (answer) {
        //sqlCommand = "delete from `" + nazwa + "` where Id=" + id;
        window.location = "index.php?sqlCommand=" + nazwa + "&logout=1";
    }
}


function dodajNapis(nazwa) {
    var sel = document.getElementById(nazwa);
    value=sel.options[sel.selectedIndex].innerHTML;
    document.getElementById('registerBoxNapisComboBoxSelected' + nazwa).innerHTML = value;

}

function dodajFileName(nazwa,id) {
    var input = document.getElementById(id);
    value = String(input.value).substring(input.value.lastIndexOf("\\")+1);
    document.getElementById('registerBoxNapisFileUploadFileName' + nazwa).innerHTML = value;
    //registerBoxNapisFileUploadFileName
}



function zapiszEdit(nazwa) {
    document.getElementById('form_' + nazwa).submit();
}
function goBack(text) {
    alert(text);
    history.back();
}
function goBackZdjecie() {
    alert('Błędny format zdjęcia');
    history.back();
}

function checkBoxChange(unique, nazwa) {
    sender = document.getElementById(unique + nazwa);
    var j = 0;
    if (sender.checked == true) {
        j = 1;
    }
    document.getElementById('hidden_' + nazwa).value = j;
}

function onChange(sender, rodzaj) {
    var commandString = "";

    if (rodzaj != "id") {
        commandString = sender.id + "='";
    }
    else {
        commandString = "Id_0_" + sender.id + "='";
        commandString = commandString + sender.value + "'";
    }
    if (rodzaj == "value") {
        commandString = commandString + sender.value + "'";
    }

    if (rodzaj == "innerHTML") {
        commandString = commandString + sender.innerHTML + "'";
    }
    if (rodzaj == "checked") {
        var j = 0;
        if (sender.checked == true) {
            j = 1;
        }
        commandString = commandString + j + "'";
    }
    document.getElementById("sqlCommand_" + sender.id).innerHTML = commandString;
}

function liczby(sender, e) {

    var charCode = (e.which) ? e.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57 || e.keyCode == 8 || e.keyCode == 46))
        return false;

    return true;
}

function registerKeyPressed(event, element, nazwa) {
    var e = event ? event : window.event;
    var thisKey;
    if (nav == "Microsoft Internet Explorer") {
        currentElement = e.srcElement;
        thisKey = e.keyCode;
    }
    else {
        currentElement = element;
        thisKey = e.which;
    }

    if (thisKey == 13) {
        register(nazwa);
    }
}
/*var ed = this.editor, formObj, os, i, elementId;
var commandString = new Array();
commandString = "";
commandString = ed.id + "='";
commandString = commandString + ed.innerHTML + "'";
document.getElementById("sqlCommand_" + ed.id).innerHTML = commandString;
*/
