function LZ(n) {
    return (n != null && n < 10 && n >= 0 ? "0" : "") + n;
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}  

function pokracujk(name,eid) {
	var chbx = document.getElementsByName(name);
	document.forms[0].elements[eid].style.display='none';
	for(var i=0;i<chbx.length;i++) {
		if(chbx[i].checked)
			document.forms[0].elements[eid].style.display='block';
	}
}

function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;   
    }else{   
		return false; 
    }
}


function checkformkrok1 ( form )
{
  var chyba = "";

  if ((form.email.value == "")||(!checkEmail(form.email.value))) {
    chyba += "Vyplňte e-mail. \n";
  }
  if (form.telefon.value == "") {
	    chyba += "Vyplňte telefon. \n";
	  }  
  if (form.jmeno.value == "") {
	  chyba += "Vyplňte jméno. \n";
  }
  if (form.prijmeni.value == "") {
	  chyba += "Vyplňte příjmení. \n";
  }  
  if (form.ulice.value == "") {
	  chyba += "Vyplňte ulici. \n";
  } 
  if (form.mesto.value == "") {
	  chyba += "Vyplňte město. \n";
  }  
  if (form.psc.value == "") {
	  chyba += "Vyplňte PSČ. \n";
  }  
  /*
	if(!form.firma_stejna.checked) {  
	  if (form.firma.value == "") {
		  chyba += "Vyplňte firmu. \n";
	  }
	  if (form.firma_ulice.value == "") {
		  chyba += "Vyplňte fakturační ulici. \n";
	  } 
	  if (form.firma_mesto.value == "") {
		  chyba += "Vyplňte fakturační město. \n";
	  }   
	  if (form.firma_psc.value == "") {
		  chyba += "Vyplňte fakturační PSČ. \n";
	  }   
	}
  if (form.ico.value == "") {
	  chyba += "Vyplňte IČO. \n";
  } 
  if (form.dic.value == "") {
	  chyba += "Vyplňte DIČ. \n";
  }   
  */

	if (form.zvire_druh.value == "") {
		  chyba += "Vyplňte druh zvířete. \n";
	}
	if (form.zvire_plemeno.value == "") {
		  chyba += "Vyplňte plemeno zvířete. \n";
	}  
	if (form.zvire_narozeni.value == "") {
		  chyba += "Vyplňte datum narození zvířete. \n";
	} 
	if ((form.zvire_hmotnost.value == "")||(!IsNumeric(form.zvire_hmotnost.value))) {
		  chyba += "Vyplňte hmotnost zvířete. \n";
	}  

  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}


function checkformkrok2 ( form )
{
	//alert('aaaaaa');
  var chyba = "";
  var chbx = document.getElementsByTagName('input');
  //document.forms[0].elements[eid].style.display='none';
  
  chyba += "Vyplňte typ vyšetření. \n";
  for(var i=0;i<chbx.length;i++) {
	if((chbx[i].type == "checkbox")&&chbx[i].checked)
		chyba = "";
		//document.forms[0].elements[eid].style.display='block';
  }
  
  //var hod = parseInt(form.hodina.value);
 // var min = parseInt(form.minuta.value);
  
  var dnes = new Date();
  //dnes.setTime(dnes.getTime() + 1000*60*((dnes.getHours()+2)*60 + dnes.getMinutes()));
  //dnes.setTime(dnes.getTime() + 1000*60*60*24 - 1000*60*((dnes.getHours())*60 + dnes.getMinutes()));
  dnes.setDate(dnes.getDate());
  dnes.setMonth(dnes.getMonth());
  dnes.setFullYear(dnes.getFullYear());
  //alert(dnes.getTime());
  dnes.setTime(dnes.getTime() + 1000*60*60*24);
  dnes.setHours(0,0,0,0);
  //alert(dnes.getTime());
  /*
  var rok = parseInt(dnes.getFullYear());
  var mesic = parseInt(dnes.getMonth()) + 1;
  var den = parseInt(dnes.getDate());
*/
  var datum = form.datum_objednavky.value.toString();
  var dden = parseInt(datum.substring(0,2),10);
  var dmesic = parseInt(datum.substring(3,5),10);
  var drok = parseInt(datum.substring(6,11)); 
  var zadanydatum = new Date();
  zadanydatum.setFullYear(drok,dmesic-1,dden);
  //zadanydatum.setTime(zadanydatum.getTime() + 1000*60*(hod*60 + min));
  zadanydatum.setTime(zadanydatum.getTime());
  var datumtime = zadanydatum.getTime();
  var dnestime = dnes.getTime();
  //alert(zadanydatum.toString());
  //alert(dnes.toString());
  //(datumtime+'  '+dnestime);
  if((datumtime <= dnestime)) {
	  chyba += "Vyplňte platné datum objednávky. \n";
  }
  
  if (form.datum_objednavky.value == "") {
	  chyba += "Vyplňte datum objednávky. \n";
  }   
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}


function checkformkrok3 ( form )
{
	//alert('aaaaaa');
  var chyba = "";
  var chbx = document.getElementsByTagName('input');
  //document.forms[0].elements[eid].style.display='none';
  
  chyba += "Vyberte termín vyšetření. \n";
  for(var i=0;i<chbx.length;i++) {
	if((chbx[i].type == "radio")&&chbx[i].checked)
		chyba = "";
		//document.forms[0].elements[eid].style.display='block';
  }


  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}


function checkformdotaznik ( form )
{
	var chyba = "";
	if ((form.vek.value == "")||(!IsNumeric(form.vek.value))) {
		  chyba += "Vyplňte Váš věk. \n";
	}	
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}

  return true ;
}

