function ShowRC() {
	document.getElementById('div_rc').style.display = 'block';
	document.getElementById('rodne_cislo').value="";
}	

function HideRC() {
	document.getElementById('div_rc').style.display = 'none';
	document.getElementById('rodne_cislo').value="Cizinec";
}

function ShowDN() {
	document.getElementById('div_dn').style.display = 'block';
	document.getElementById('datum_narozeni').value="";
}	

function HideDN() {
	document.getElementById('div_dn').style.display = 'none';
	document.getElementById('datum_narozeni').value="Rezident";
}

// kódy kláves pro filtrování
// Left, Up, Right, Down:   37,38,39,40
// BackSpace:                         8
// Tab:                               9
// Num:                         48 - 57
// ,                                 44
// +                                 43
// .                                 46
// Space:                            32   

function cipherOnly(e)
{
  var code;
  if (!e) e = window.event; // nastaveni pro IE
  if (e.keyCode)
    code = e.keyCode; // IE a Opera
  else if (e.which) 
     code = e.which; // NN4, Mozilla
  if (!(code==8 || code==9 || (code>36 && code<41) || (code>=48 && code<=57)))
    return false;
}

function cipherOnly1(e)
{
  var code;
  if (!e) e = window.event; // nastaveni pro IE
  if (e.keyCode)
    code = e.keyCode; // IE a Opera
  else if (e.which) 
     code = e.which; // NN4, Mozilla
  if (!(code==8 || code==9 || (code>36 && code<41) || code==46 || (code>=48 && code<=57)))
    return false;
}
    
function cipherOnly2(e)
{
  var code;
  if (!e) e = window.event; // nastaveni pro IE
  if (e.keyCode)
    code = e.keyCode; // IE a Opera
  else if (e.which) 
     code = e.which; // NN4, Mozilla
  if (!(code==8 || code==9 || (code>36 && code<41) || code==43 || (code>=48 && code<=57)))
    return false;
}

function cipherOnly3(e)
{
  var code;
  if (!e) e = window.event; // nastaveni pro IE
  if (e.keyCode)
    code = e.keyCode; // IE a Opera
  else if (e.which) 
     code = e.which; // NN4, Mozilla
  if (!(code==8 || code==9 || (code>36 && code<41) || code==32 || (code>=48 && code<=57)))
    return false;
}



function MM_validateForm()
{
  retValue=true;
  prvek = new Array("jmeno_uchazece","prijmeni_uchazece","rodne_cislo",
                    "misto_narozeni","at_ulice","at_mesto", "at_psc",
                    "email","stredni_skola","antispam");
  N=prvek.length;
  I=0;
  narodnost=document.getElementById("rodne_cislo");
  //window.alert(narodnost.value);
  if(narodnost.value=="Cizinec") prvek[2]="datum_narozeni";
  do {
    E=document.getElementById(prvek[I]);
    E.setAttribute("class", "textfield_required");
    E.setAttribute("className", "textfield_required"); 
    //window.alert(prvek[I]);
    //window.alert(E);
    if(E.value.length<=0)
    {
      E.focus(); 
      E.setAttribute("class", "textfield_focused");
      E.setAttribute("className", "textfield_focused"); 
      window.alert("Pole musí být vyplněno!");
      retValue=false;
    }; //endif povinné pole
    if((prvek[I]=="email") && retValue){
      if(E.value.indexOf("@")<1)
      {
        E.focus(); 
        E.setAttribute("class", "textfield_focused");
        E.setAttribute("className", "textfield_focused"); 
        window.alert("Zadejte platnou e-mailovou adresu!");
        retValue=false;
      };
    }; //endif email
    if((prvek[I]=="rodne_cislo")&& retValue)
    {
      RC=E.value;
      //window.alert(RC);
      //window.alert(RC/11);
      if(Math.abs(RC/11-Math.floor(RC/11))>0.01)
      {
        //window.alert("RC spatne");
        E.focus(); 
        E.setAttribute("class", "textfield_focused");
        E.setAttribute("className", "textfield_focused"); 
        window.alert("Zadejte platné rodné číslo!");
        retValue=false;
      }; //endif
    };
    if((prvek[I]=="antispam")&& retValue)
    {
      AS=E.value;
      AR = document.getElementById("antispam_result");
      ASL = document.getElementById("antispam_example");
      if(AS!=AR.value)
      {
        E.focus(); 
        E.setAttribute("class", "textfield_focused");
        E.setAttribute("className", "textfield_focused"); 
        window.alert(ASL.innerHTML+" bohužel není "+AS+"!");
        retValue=false;
      }; //endif
    };
    I++;
    //window.alert(I);
    //window.alert(retValue);
  } while(retValue && (I<N));
  //window.alert(I);
  //window.alert(retValue);
  document.MM_returnValue=retValue;
}


function MM_resetForm()
{
  retValue=true;
  prvek = new Array("jmeno_uchazece","prijmeni_uchazece","rodne_cislo",
                    "misto_narozeni","adresa_trvala",
                    "email","telefon","stredni_skola","antispam");
  N=prvek.length;
  I=0;
  narodnost=document.getElementById("rodne_cislo");
  //window.alert(narodnost.value);
  if(narodnost.value=="Cizinec") prvek[2]="datum_narozeni";
  do {
    E=document.getElementById(prvek[I]);
    CV="textfield_required";
    if(prvek[I]=="telefon") CV="textfield";
    E.setAttribute("class", CV);
    E.setAttribute("className", CV); 
    I++;
    //window.alert(I);
    //window.alert(retValue);
  } while(retValue && (I<N));
}

function MM_setAntispam()
{
//  window.alert("setAntispam");
  X = 2+Math.round(8*Math.random());
  Y = 2+Math.round(8*Math.random());
//  window.alert(X+" x "+Y);
  AR = document.getElementById("antispam_result");
  AE = document.getElementById("antispam_example");
  AR.value = X*Y;
//  window.alert(AR.value);
  AE.innerHTML = X+" krát "+ Y;
}

