function validate(theForm) {
       if (searchString.value==null||searchString.value=="") {
            alert("Nevypln\u011bné pole!\n");
            searchString.style.background = 'Yellow';
            return false;
        } else {
            return true;
        }

    }

function validateEditFormOnSubmit(theForm) {
    var reason = "";

    reason += validateCena(theForm.cena);
    reason += validateRozloha(theForm.rozloha);
    reason += validatePopis(theForm.popis);
    reason += validateLoznice(theForm.loznice);
      
    if (reason != "") {
        alert("N\u011bkterá pole nejsou vyplněna správně:\n" + reason);
        return false;
    }

    return true;
}

function validateFormOnSubmit(theForm) {
    var reason = "";

    reason += validateCena(theForm.cena);
    reason += validateRozloha(theForm.rozloha);
    reason += validatePopis(theForm.popis);
    reason += validateKategorie(theForm.idkategorie );
    reason += validateLoznice(theForm.loznice);
      
    if (reason != "") {
        alert("N\u011bkterá pole nejsou vyplněna správně:\n" + reason);
        return false;
    }

    return true;
}

function validateKategorie(fld) {
    var error = "";
    if(fld.value == 0){
        error = "Nebyla vybrána kategorie!\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validateCena(fld) {
    var error = "";
	if (fld.value==null||fld.value=="") {
        error = "Cena nebyla zadána!\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }

    return error;
}


function validateRozloha(fld) {
    var error = "";
    var numericExpression = /^[0-9]+$/;

    if (fld.value==null||fld.value=="") {
        error = "Rozloha nebyla zadána!\n";
        fld.style.background = 'Yellow';
    } else if(!(fld.value.match(numericExpression))){
        error = "Neplatná rozloha!\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }

    return error;
}

function validatePopis(fld) {
    var error = "";

    if (fld.value==null||fld.value=="") {
        error = "Popis nebyl zadán!\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }

    return error;
}

function validateLoznice(fld) {
    var error = "";
    var numericExpression = /^[0-9]+$/;
    if (fld.value==null||fld.value=="") {

    } else if(!(fld.value.match(numericExpression))){
        error = "Neplatný po\u010det ložnic!\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }

    return error;
}

function MM_openBrWindow(theURL,winName,features) { 
    window.open(theURL,winName,features);
    return false;
}

function show_confirm()
{
    var r=confirm("Jste si jistý?");
    if (r==true)
    {
        return true;
    }
    else
    {
        return false;
    }
}
