var ctverec_plny = new Image();
var ctverec_prazdny = new Image();
var ctverec_aktualni = new Image();

function vymen() {
	ctverec_plny.src = "obr/ctverec_plny.gif";
	ctverec_prazdny.src = "obr/ctverec_prazdny.gif";
	ctverec_aktualni.src = "obr/ctverec_aktualni.gif";
}

function okenko(fotka,nazev,x,y) {
  if (typeof(pohled) != "undefined") pohled.close();
  pohled=window.open("","Fotografie","width=" + x + ",height=" + y);
  pohled.focus();
  pohled.document.write("<html><head><title>" + nazev + "</title></head>");
  pohled.document.write("<body background=" + fotka + "></center></body></html>");
  pohled.document.close();
}

function valEmail (strng) {
var error="";
if (strng == "") {
   error = "Nezadali jste e-mailovou adresu.\n";
}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Zadejte platnou e-mailovou adresu.\n";
    }
    else {
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "E-mailová adresa obsahuje neplatné znaky.\n";
       }
    }
return error;    
}

function valPSC (strng) {
var error = "";
if (strng == "") {
   error = "Nezadali jste PSČ.\n";
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); 
    if (isNaN(parseInt(stripped))) {
       error = "PSČ obsahuje neplatné znaky.";
    }
    if (!(stripped.length == 5)) {
	error = "PSČ nemá správný počet číslic (5).\n";
    } 
return error;
}

function valHeslo (strng) {
var error = "";
if (strng == "") {
   error = "Nezadali jste heslo.\n";
}
    var illegalChars = /[\W_]/; 
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "Heslo nemá správný počet znaků.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "Heslo obsahuje neplatné znaky.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "Heslo musí obsahovat nejméně jedno velké písmeno, jedno malé písmeno a jednu číslici.\n";
    }  
return error;    
}    

function valJmeno (strng) {
var error = "";
if (strng == "") {
   error = "Nezadali jste jméno.\n";
}
    var illegalChars = /[\t\n\r\f\d]/; 
    if ((strng.length < 4) || (strng.length > 30)) {
       error = "Jméno je špatně uvedeno.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Jméno obsahuje neplatné znaky.\n";
    } 
return error;
}       

function valUlice (strng) {
var error = "";
if (strng == "") {
   error = "Nezadali jste ulici.\n";
}
    var illegalChars = /[\t\n\r\f]/; 
    if (strng.length < 4) {
       error = "Název ulice není dostatečně dlouhý.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Název ulice obsahuje neplatné znaky.\n";
    } 
return error;
}       

function valMesto (strng) {
var error = "";
if (strng == "") {
   error = "Nezadali jste město.\n";
}
    var illegalChars = /[\t\n\r\f]/; 
    if (strng.length < 2) {
       error = "Název města není dostatečně dlouhý.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Název města obsahuje neplatné znaky.\n";
    } 
return error;
}       

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Musíte vyplnit všechny položky.\n"
  }
return error;	  
}

function validace (theForm) {
    var why = "";
    why += valEmail(theForm.Posta.value);
    why += valJmeno(theForm.Jmeno.value);
    why += valUlice(theForm.Ulice.value);
    why += valMesto(theForm.Mesto.value);
    why += valPSC(theForm.PSC.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}    

function test (jmeno) {
  alert(jmeno.Mesto.value);
  return false;
}