function check_form(theForm)
{
    var why = "";
    why += jmeno(theForm.jmeno.value);
    why += ulice(theForm.ulice.value);
    why += mesto(theForm.mesto.value);
    why += checkPhone(theForm.telefon.value);
    why += psc(theForm.psc.value);
    why += email(theForm.email.value);
    if (why != "") {
        alert(why);
        return false;
    }
    return true;
}
function check_dilec(theForm)
{
    var why = "";
    why += vyska(theForm.vyska.value);
    why += sirka(theForm.sirka.value);
    why += pocet(theForm.pocet.value);
    why += vzorek(theForm.vzorek.selectedIndex);
	
    if (why != "") {
        alert(why);
        return false;
    }
    return true;
}
function vzorek(strng) {
    var error = "";
    if (strng == 0) {
        error = "Vyberte prosím vzorek.\n";
    }
    return error;
}
function pocet(strng) {
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //odebereme jiné znaky než čísla
    if (strng == "") {
        error = "Vložte prosím počet.\n";
    }
    return error;
}
function sirka(strng) {
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //odebereme jiné znaky než čísla
    if (strng == "") {
        error = "Vložte šířku.\n";
    }else if (strng > 2080){
        error = "Šířka nesmí být větší než 2080mm\n";
    }
    return error;
}
function vyska(strng) {
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //odebereme jiné znaky než čísla
    if (strng == "") {
        error = "Vložte výšku.\n";
    }else if (strng > 2790){
        error = "Výška nesmí být větší než 2790mm\n";
    }
    return error;
}
// telefoní číslo, kontrola minimum 9 znaku
function checkPhone (strng) {
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (strng == "") {
        error = "Vyplňte prosím váš telefon.\n";
    }
    else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.";
  
    }
    else if (stripped.length < 9) {
        error = "Telefon má špatnou délku.\n";
    } 
    return error;
}
function ulice(strng) {
    var error = "";
    if (strng.length == 0) {
        error = "Vyplňte prosím vaši ulici.\n"
    }
    return error;
}
function mesto(strng) {
    var error = "";
    if (strng.length == 0) {
        error = "Vyplňte prosím vaše město.\n"
    }
    return error;
}
function jmeno(strng) {
    var error = "";
    if (strng.length == 0) {
        error = "Vyplňte prosím vaše jméno.\n"
    }
    return error;
}
function psc(strng) {
    var error = "";
    if (strng.length == 0) {
        error = "Vyplňte prosím vaše PSC.\n"
    }
    return error;
}
function email(strng) {
    var error="";
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (strng == "") {
        error = "Vyplňte prosím váš email.\n";
    }
    else if (!(emailFilter.test(strng))) {
        error = "Váš email není platný.\n";
    }
    else {
        //test email for illegal characters
        var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
        if (strng.match(illegalChars)) {
            error = "Email obsahuje nepolovené znaky\n";
        }
    }
    return error;
}



