String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function toggle_visibility(){
        var inputform = document.getElementById("inputform");

        /*if ( inputform.branza.value == "salon")
                document.getElementById("salon").style.visibility = "visible";
        else
                document.getElementById("salon").style.visibility = "hidden";*/
                
        if ( inputform.branza.value == "automatyka"){
                inputform.paliwo.disabled = true;
                inputform.kubatura.disabled = true;
                inputform.powierzchnia.disabled = true;
                inputform.mockotla.disabled = true;
                inputform.instalacja.disabled = true;
                inputform.podgrzewacz.disabled = true;
                inputform.iloscosob.disabled = true;
                document.getElementById("salon_etykiety").style.color = "#ACA899";
        } else {
                document.forms['inputform'].paliwo.disabled = false;
                inputform.kubatura.disabled = false;
                inputform.powierzchnia.disabled = false;
                inputform.mockotla.disabled = false;
                inputform.instalacja.disabled = false;
                inputform.podgrzewacz.disabled = false;
                inputform.iloscosob.disabled = false;
                document.getElementById("salon_etykiety").style.color = "#676767";                
        }
}

function checkQuestionInput() {
    var user = document.getElementById("inputform");
    
    user.imienazwisko.value = user.imienazwisko.value.trim();
    var tekst = user.imienazwisko.value;
    if (tekst.length < 4) {
        window.alert('Wpis "Imię i nazwisko" ma za mało znaków!');
        return 0;
    }
        
    if ((user.email.value.indexOf('@') == -1) || (user.email.value.length < 6)) {
        window.alert('Podany adres e-mail jest niepoprawny!');
        return 0;
    }   
    
    var tekst = user.tresc.value;
    if (tekst.length < 7) {
        window.alert('Nie wpisano treści!');
        return 0;
    }
    
    user.submit();
}

