// seznam mailu

  var cast1 = "mail";
  var cast2 = "to:";
  
  var name_in = "info";


  var server = "osobnidoprava";
  var domena = "cz";
  

  /**
   * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
   */
  // Declaring valid date character, minimum year and maximum year
  var dtCh= ".";
  var minYear=2009;
  var maxYear=2012;

  function isInteger(s){
  	var i;
      for (i = 0; i < s.length; i++){   
          // Check that current character is number.
          var c = s.charAt(i);
          if (((c < "0") || (c > "9"))) return false;
      }
      // All characters are numbers.
      return true;
  }

  function stripCharsInBag(s, bag){
  	var i;
      var returnString = "";
      // Search through string's characters one by one.
      // If character is not in bag, append to returnString.
      for (i = 0; i < s.length; i++){   
          var c = s.charAt(i);
          if (bag.indexOf(c) == -1) returnString += c;
      }
      return returnString;
  }

  function daysInFebruary (year){
  	// February has 29 days in any year evenly divisible by four,
      // EXCEPT for centurial years which are not also divisible by 400.
      return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
  }
  function DaysArray(n) {
  	for (var i = 1; i <= n; i++) {
  		this[i] = 31
  		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
  		if (i==2) {this[i] = 29}
     } 
     return this
  }

  function isDate(dtStr){
  	var daysInMonth = DaysArray(12)
  	var pos1=dtStr.indexOf(dtCh)
  	var pos2=dtStr.indexOf(dtCh,pos1+1)
  	var strDay=dtStr.substring(0,pos1)
  	var strMonth=dtStr.substring(pos1+1,pos2)
  	var strYear=dtStr.substring(pos2+1)
  	strYr=strYear
  	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
  	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
  	for (var i = 1; i <= 3; i++) {
  		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
  	}
  	month=parseInt(strMonth)
  	day=parseInt(strDay)
  	year=parseInt(strYr)
  	if (pos1==-1 || pos2==-1){
  		alert("Datum musí být ve formátu : dd.mm.yyyy")
  		return false
  	}
  	if (strMonth.length<1 || month<1 || month>12){
  		alert("Zadejte platný měsíc")
  		return false
  	}
  	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  		alert("Zadejte platný den")
  		return false
  	}
  	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
  		alert("Zadejte rok mezi "+minYear+" a "+maxYear)
  		return false
  	}
  	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
  		alert("Zadejte platné datum")
  		return false
  	}
  return true
  }

  function ValidateForm(){
  	var dt=document.frmSample.txtDate
  	if (isDate(dt.value)==false){
  		dt.focus()
  		return false
  	}
      return true
   }

 
  
function pokracuj(eid,prepinej) {
	if(document.forms[0].elements[eid].style.display == 'none')
		document.forms[0].elements[eid].style.display='block';
	else if(prepinej)
		document.forms[0].elements[eid].style.display='none';		
}

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 checkform ( form )
{
  var chyba = "";
  if (form.firma.value == "") {
	    chyba += "Vyplňte firmu. \n";
	  }
  if (form.popis.value == "") {
	    chyba += "Vyplňte popis. \n";
	  } 
  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.fa_stejna.checked) {  
	  if (form.fa_jmeno.value == "") {
		  chyba += "Vyplňte fakturační firma / jméno a příjmení. \n";
	  }
	  /*
	  if (form.fa_prijmeni.value == "") {
		  chyba += "Vyplňte fakturační příjmení. \n";
	  }
	  */
	  
	  if (form.fa_ulice.value == "") {
		  chyba += "Vyplňte fakturační ulice. \n";
	  } 
	  if (form.fa_mesto.value == "") {
		  chyba += "Vyplňte fakturační město. \n";
	  }   
	  if (form.fa_psc.value == "") {
		  chyba += "Vyplňte fakturační PSČ. \n";
	  }   
	}
  if (form.ico.value == "") {
	  chyba += "Vyplňte IČ. \n";
  }
  /*
  if (form.dic.value == "") {
	  chyba += "Vyplňte DIČ. \n";
  } */  
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}


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

  if ((form.heslo.value != "")&&((form.heslo_2.value == ""))) {
	  chyba += "Vyplňte zadejte znovu nové heslo. \n";
  }
  
  if ((form.heslo.value != "")&&((form.heslo_2.value != ""))&&(form.heslo_2.value != form.heslo.value)) {
	  chyba += "Naopsali jste správně nové heslo. \n";
  }
  
  if (form.firma.value == "") {
	    chyba += "Vyplňte firmu. \n";
	  }
  if (form.popis.value == "") {
	    chyba += "Vyplňte popis. \n";
	  } 
  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.fa_jmeno.value == "") {
	  chyba += "Vyplňte fakturační jméno a příjmení. \n";
  }

  if (form.fa_ulice.value == "") {
	  chyba += "Vyplňte fakturační ulice. \n";
  } 
  if (form.fa_mesto.value == "") {
	  chyba += "Vyplňte fakturační město. \n";
  }   
  if (form.fa_psc.value == "") {
	  chyba += "Vyplňte fakturační PSČ. \n";
  }   
  if (form.ico.value == "") {
	  chyba += "Vyplňte IČ. \n";
  } 
  if (form.dic.value == "") {
	  chyba += "Vyplňte DIČ. \n";
  }   
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}

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 checkformpridatvozidlo ( form )
{
  var chyba = "";
  var d = new Date();

  if (form.nazev.value == "") {
	    chyba += "Vyplňte název vozidla. \n";
  }

  if ((form.rokvyroby.value == "")||(!IsNumeric(form.rokvyroby.value))) {
		chyba += "Vyplňte rok výroby. \n";
  }
  else {
  	var pom = parseInt(form.rokvyroby.value,10);
  	var rok = d.getFullYear();

  	if((pom<1900)||(pom>rok))
  		chyba += "Vyplňte rok výroby. \n";
  	else {
  		form.rokvyroby.value = pom;	
  	}
  }
  
  if ((form.osob.value == "")||(!IsNumeric(form.osob.value))) {
	  chyba += "Vyplňte maximální počet osob. \n";
  }
  else {
	  var pom = parseInt(form.osob.value,10);
	  if((pom < 1)||(pom>300)) {
		  chyba += "Vyplňte maximální počet osob. \n";
	  }
	  else {
		  form.osob.value = pom;  
	  }
  }
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}

function checkformvozidlo ( form )
{
  var chyba = "";
  var d = new Date();

  if (form.nazev.value == "") {
	    chyba += "Vyplňte název vozidla. \n";
  }

  if ((form.rokvyroby.value == "")||(!IsNumeric(form.rokvyroby.value))) {
		chyba += "Vyplňte rok výroby. \n";
  }
  else {
  	var pom = parseInt(form.rokvyroby.value,10);
  	var rok = d.getFullYear();

  	if((pom<1900)||(pom>rok))
  		chyba += "Vyplňte rok výroby. \n";
  	else {
  		form.rokvyroby.value = pom;	
  	}
  }
  
  if ((form.osob.value == "")||(!IsNumeric(form.osob.value))) {
	  chyba += "Vyplňte maximální počet osob. \n";
  }
  else {
	  var pom = parseInt(form.osob.value,10);
	  if((pom < 1)||(pom>300)) {
		  chyba += "Vyplňte maximální počet osob. \n";
	  }
	  else {
		  form.osob.value = pom;  
	  }
  }

  if ((form.do100.value != "")&&(!IsNumeric(form.do100.value))) {
	  chyba += "Vyplňte cenu do 100 km. \n";
  }
  else {
	  var pom = parseInt(form.do100.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu do 100 km. \n";
	  }
	  else {
		  form.do100.value = pom;  
	  }
  }
 
  if ((form.do500.value != "")&&(!IsNumeric(form.do500.value))) {
	  chyba += "Vyplňte cenu do 500 km. \n";
  }
  else {
	  var pom = parseInt(form.do500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu do 500 km. \n";
	  }
	  else {
		  form.do500.value = pom;  
	  }
  }  
 
  if ((form.nad500.value != "")&&(!IsNumeric(form.nad500.value))) {
	  chyba += "Vyplňte cenu nad 500 km. \n";
  }
  else {
	  var pom = parseInt(form.nad500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu nad 500 km. \n";
	  }
	  else {
		  form.nad500.value = pom;  
	  }
  }    
  
  if ((form.nad1500.value != "")&&(!IsNumeric(form.nad1500.value))) {
	  chyba += "Vyplňte cenu nad 1500 km. \n";
  }
  else {
	  var pom = parseInt(form.nad1500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu nad 1500 km. \n";
	  }
	  else {
		  form.nad1500.value = pom;  
	  }
  }  
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}

function checkformpoptavka ( form )
{
  var chyba = "";
  /*
  if (((form.email.value == "")||(!checkEmail(form.email.value)))&&(form.telefon.value == "")) {
	    chyba += "Vyplňte e-mail nebo telefon. \n";
  }
  */
  if ((form.email.value == "")||(!checkEmail(form.email.value))) {
    chyba += "Vyplňte e-mail. \n";
  }
  if ((form.telefon.value == "")||(form.telefon.value == "+420")) {
	    chyba += "Vyplňte telefon. \n";
	  }  
  if (form.odkud.value == "") {
	    chyba += "Vyplňte start cesty. \n";
	  }  
  if (form.kam.value == "") {
	    chyba += "Vyplňte cíl cesty. \n";
	  }    
  if (form.termin.value==""){
	  chyba += "Vyplňte termín. \n";
  }
  if (form.jmeno.value==""){
	  chyba += "Vyplňte jméno. \n";
  }  

  if(chyba != "") {
	alert(chyba);
	return false ;
  }
 
  return true ;
}
/*
function checkformdopravcipoptavka(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.mesto.value == "") {
	  chyba += "Vyplňte město. \n";
  }
  if (form.odkud.value == "") {
	  chyba += "Vyplňte odkud. \n";
  }   
  if (form.kam.value == "") {
	  chyba += "Vyplňte kam. \n";
  }  

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

function checkformdopravcipoptavka(form) {
	  var chyba = "";
/*
	  if (((form.email.value == "@")||(!checkEmail(form.email.value)))&&(form.telefon.value == "+420")) {
	    chyba += "Vyplňte e-mail nebo telefon. \n";
	  }*/
	  
	  if ((form.email.value == "")||(!checkEmail(form.email.value))) {
		    chyba += "Vyplňte e-mail. \n";
		  }
		  if ((form.telefon.value == "")||(form.telefon.value == "+420")) {
			    chyba += "Vyplňte telefon. \n";
		  } 
	  
	  if (form.odkud.value == "") {
		    chyba += "Vyplňte start cesty. \n";
		  }  
	  if (form.kam.value == "") {
		    chyba += "Vyplňte cíl cesty. \n";
		  }    
	  if (form.termin.value==""){
		  chyba += "Vyplňte termín. \n";
	  }
	  if (form.jmeno.value == "") {
		    chyba += "Vyplňte jméno. \n";
		  }

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

function checkformdopravci(form) {
	  var chyba = "";
	  /*
	  var chbx = document.getElementsByTagName('input');
	  //document.forms[0].elements[eid].style.display='none';
	  
	  chyba += "Vyberte nejméně jednoho dopravce kterému chcete poptávku zaslat. \n";
	  var jmeno = "";
	  var pom = 0;
	  for(var i=0;i<chbx.length;i++) {
		jmeno = chbx[i].name;
		pom = jmeno.indexOf('poptavka');
		if((chbx[i].type == "checkbox")&&chbx[i].checked&&(pom==0)) {
			chyba = "";
		}
			//document.forms[0].elements[eid].style.display='block';
	  }
	  */
	  /*
	  if (((form.email.value == "@")||(!checkEmail(form.email.value)))&&(form.telefon.value == "+420")) {
		    chyba += "Vyplňte e-mail nebo telefon. \n";
		  }
	  */
	  
	  if ((form.email.value == "")||(!checkEmail(form.email.value))) {
	    chyba += "Vyplňte e-mail. \n";
	  }
	  if ((form.telefon.value == "")||(form.telefon.value == "+420")) {
		    chyba += "Vyplňte telefon. \n";
		  }  
	  if (form.odkud.value == "") {
		    chyba += "Vyplňte start cesty. \n";
		  }  
	  if (form.kam.value == "") {
		    chyba += "Vyplňte cíl cesty. \n";
		  }
	  /*
	  if (isDate(form.termin.value)==false){
		  chyba += "Vyplňte termín. \n";
	  }*/
	  if (form.termin.value==""){
		  chyba += "Vyplňte termín. \n";
	  }
	  if (form.jmeno.value == ""){
		  chyba += "Vyplňte jméno. \n";
	  }
	  if(chyba != "") {
		alert(chyba);
		return false ;
	  }
	 
	  return true ;
}


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

  if ((form.email.value == "")||(!checkEmail(form.email.value))) {
    chyba += "Vyplňte e-mail. \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(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}



function checkformcenik ( form )
{
  var chyba = "";
  var d = new Date();


  if ((form.do100.value != "")&&(!IsNumeric(form.do100.value))) {
	  chyba += "Vyplňte cenu do 100 km. \n";
  }
  else {
	  var pom = parseInt(form.do100.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu do 100 km. \n";
	  }
	  else {
		  form.do100.value = pom;  
	  }
  }
 
  if ((form.do500.value != "")&&(!IsNumeric(form.do500.value))) {
	  chyba += "Vyplňte cenu do 500 km. \n";
  }
  else {
	  var pom = parseInt(form.do500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu do 500 km. \n";
	  }
	  else {
		  form.do500.value = pom;  
	  }
  }  
 
  if ((form.nad500.value != "")&&(!IsNumeric(form.nad500.value))) {
	  chyba += "Vyplňte cenu nad 500 km. \n";
  }
  else {
	  var pom = parseInt(form.nad500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu nad 500 km. \n";
	  }
	  else {
		  form.nad500.value = pom;  
	  }
  }    
  
  if ((form.nad1500.value != "")&&(!IsNumeric(form.nad1500.value))) {
	  chyba += "Vyplňte cenu nad 1500 km. \n";
  }
  else {
	  var pom = parseInt(form.nad1500.value,10);
	  if(isNaN(pom)) {
		  pom = 0;
	  }	  
	  if((pom < 0)||(pom>99999)) {
		  chyba += "Vyplňte cenu nad 1500 km. \n";
	  }
	  else {
		  form.nad1500.value = pom;  
	  }
  }  
  
	if(chyba != "") {
		alert(chyba);
		return false ;
	}
 
  return true ;
}

