function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600');");
}

function popUp2(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=670,height=670');");
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
};

function msg(fld,     // id of element to display message in
             message) // string to display
{

  // setting an empty string can give problems if later set to a 
  // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
  // simply use a space, but IE demands something more, like a non-breaking space.)
  var dispmessage;
  if (message == "") 
    dispmessage = String.fromCharCode(0x00a0); //nbsp = 160
  else  
    dispmessage = message;

  var elem = document.getElementById(fld);
  elem.firstChild.nodeValue = dispmessage;  
  
  //elem.className = msgtype;   // set the CSS class to adjust appearance of message
};


function verify() {

var form_ok = true;

if (document.forms['cc'].spol.value=="") {
  msg("f_spol", "povinné");
  form_ok = false;
}
  else msg("f_spol", "");
  

if (document.forms['cc'].adr.value=="") {
  msg("f_adr", "povinné");
  form_ok = false;
}
  else msg("f_adr", "");


if ((document.forms['cc'].obec.value=="") || (document.forms['cc'].psc.value=="")) {
  msg("f_obec", "povinné");
  form_ok = false;
}
  else msg("f_obec", "");

if (document.forms['cc'].osoba.value=="") {
  msg("f_os", "povinné");
  form_ok = false;
}
  else msg("f_os", "");

if (document.forms['cc'].tel.value=="") {
  msg("f_tel", "povinné");
  form_ok = false;
}
  else msg("f_tel", "");


var tfld = trim(document.forms['cc'].email.value);

var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/

if (document.forms['cc'].email.value=="") {
  msg("f_email", "povinné");
  form_ok = false;
  }
  else if (!email.test(tfld)) {
      msg ("f_email", "neplatná");  
      form_ok = false;
      } 
      else
        msg("f_email", "");

  


var poc_cb = document.forms['cc'].poc_ch.value;
var ch_ok = false;
for (ic = 1; ic <= poc_cb; ic++) {
if (document.forms['cc'].elements[ic+7].checked) 
    ch_ok = true;
}

if (ch_ok == false)
{
  form_ok = false;
  msg("f_cena", "povinné");

} else   
  msg("f_cena", "");


//alert if fields are empty and cancel form submit
if (form_ok == true)
  document.forms['cc'].submit();
else 
  {
    //alert("Prosím vyplňte povinné údaje.");
    return false;
   }
}

