function dodajPole(){


    var x = document.getElementById("iloscPol");
    
    var wiecej = Number(x.value) + 1;
    
    var id = x.value
    
    x.value = wiecej.toString();
    
    document.getElementById("iloscPol").value = x.value;
    
    var nowyElement = document.createElement('li');
    
    nowyElement.setAttribute('id', 'pole' + id)
    
    nowyElement.innerHTML = '<input type="text" name="pole' + id + '" /><a onclick="usunPole(\'pole' + id + '\')">Usun pole</a>'
    
    document.getElementById('lista').appendChild(nowyElement);
    
}

function usunPole(id){


    var x = document.getElementById("iloscPol");
    
    var pierwotnie = x.value;
    
    var mniej = Number(x.value) - 1;
    
    x.value = mniej.toString();
    
    document.rem
    
    document.getElementById("iloscPol").value = x.value;
    
    doKasacji = document.getElementById(id)
    
    document.getElementById('lista').removeChild(doKasacji)
    
}


function wyslijFormularz(){



    var x = document.forms;
    
    var licznosc = x.length;
    
    var nrKomorki = licznosc - 1;
    
    document.forms[nrKomorki].submit();
}

function formularzKontaktowy(){

    var x = document.forms;
    
    var licznosc = x.length;
    
    var nrKomorki = licznosc - 2;
    
    
    
    if (!document.forms[nrKomorki].elements['osoba'].value.length) {
        document.forms[nrKomorki].elements['osoba'].focus();
        alert('Podanie danych osobowych jest obowiÄzkowe.');
        return false;
    }
    
    if (!document.forms[nrKomorki].elements['telefon'].value.length) {
    
        document.forms[nrKomorki].elements['telefon'].focus();
        alert('Podanie numeru telefonu jest obowiÄzkowe.');
        return false;
    }
    
    if (!document.forms[nrKomorki].elements['email'].value.length) {
    
        document.forms[nrKomorki].elements['email'].focus();
        alert('Podanie adresu e-mail jest obowiÄzkowe.');
        return false;
    }
}

function isValidEmail(email, required){
    if (required == undefined) { // if not specified, assume it's required
        required = true;
    }
    if (email == null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length == 0) {
        if (required) {
            return false;
        }
        return true;
    }
    if (!allValidChars(email)) { // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    }
    else 
        if (email.lastIndexOf(".") <= email.indexOf("@")) { // last dot must be after the @
            return false;
        }
        else 
            if (email.indexOf("@") == email.length) { // @ must not be the last character
                return false;
            }
            else 
                if (email.indexOf("..") >= 0) { // two periods in a row is not valid
                    return false;
                }
                else 
                    if (email.indexOf(".") == email.length) { // . must not be the last character
                        return false;
                    }
    return true;
}

function allValidChars(email){
    var parsed = true;
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
    for (var i = 0; i < email.length; i++) {
        var letter = email.charAt(i).toLowerCase();
        if (validchars.indexOf(letter) != -1) 
            continue;
        parsed = false;
        break;
    }
    return parsed;
}

function sprawdzEmail(email){

    if (isValidEmail(email)) {
    
        document.getElementById('formularzNewsletter').submit();
    }
    else {
    
        alert('Nie wpisano adresu e-mail lub jest w nim błąd');
        
    }
}

function pokazStrone(strona, iloscStron){



    for (var i = 0; i < iloscStron; i++) {
    
    
        if (strona == i) {
        
            document.getElementById("strona" + i).style.display = "block";
            document.getElementById("odnosnikDoStrony" + i).style.fontWeight = "bold";
            
            if ((i - 1) > 0) {
            
                document.getElementById("nawigatorWstecz").href = "javascript: pokazStrone(" + (i - 1) + ", " + iloscStron + ")";
            }
            else{
                
                document.getElementById("nawigatorWstecz").href = "javascript: pokazStrone(0, " + iloscStron + ")";
            }
            if ((i + 1) < iloscStron) {
            
                document.getElementById("nawigatorNaprzod").href = "javascript: pokazStrone(" + (i + 1) + ", " + iloscStron + ")";
            }
            
        }
        else {
        
            document.getElementById("strona" + i).style.display = "none";
            document.getElementById("odnosnikDoStrony" + i).style.fontWeight = "normal";
        }
        
    }
    
    
    
    
}

