 function validate(theForm){
	if (theForm.to.value == "" || theForm.to.value.indexOf('@',1)== -1 || theForm.to.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu příjemce.");
		theForm.to.focus();
		return false;
	}
return true;
}

function zkontroluj_uver(theForm){
	if (theForm.jmeno_a_prijmeni.value == "" || theForm.jmeno_a_prijmeni.value.length < 2){
		alert("Prosím zadejte jméno a příjmení.");
		theForm.jmeno_a_prijmeni.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
	if (theForm.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	if (theForm.mesto.value == "" || theForm.mesto.value.length < 2){
		alert("Prosím zadejte město.");
		theForm.mesto.focus();
		return false;
	}
	if (theForm.cena_s_dani.value == "" || theForm.cena_s_dani.value < 180000 || !parseInt(theForm.cena_s_dani.value) || theForm.cena_s_dani.value.indexOf('.') !=-1 || theForm.cena_s_dani.value.indexOf('Kč')!=-1 || theForm.cena_s_dani.value.indexOf('kč')!=-1 || theForm.cena_s_dani.value.indexOf(' ')!=-1){
		alert("Prosím zadejte cenu automobilu. Minimální cena je 180000 Kč, zadávejte pouze číslo.");
		theForm.cena_s_dani.focus();
		return false;
	}
	if (theForm.stari_auta.value == "" ){
		alert("Prosím zadejte stáří auta.");
		theForm.stari_auta.focus();
		return false;
	}
	if (theForm.pocet_splatek.value == "" || theForm.pocet_splatek.value.length < 2){
		alert("Prosím požadovaný počet splátek.");
		theForm.pocet_splatek.focus();
		return false;
	}

return true;
}

function zkontroluj_zahranicni(theForm){
	if (theForm.jmeno_a_prijmeni.value == "" || theForm.jmeno_a_prijmeni.value.length < 2){
		alert("Prosím zadejte jméno a příjmení.");
		theForm.jmeno_a_prijmeni.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
	if (theForm.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	if (theForm.znacka_auta.value == "" || theForm.znacka_auta.value.length < 2){
		alert("Prosím zadejte značku auta.");
		theForm.znacka_auta.focus();
		return false;
	}
	if (theForm.model_auta.value == "" || theForm.model_auta.value.length < 2){
		alert("Prosím zadejte model auta.");
		theForm.model_auta.focus();
		return false;
	}
	if (theForm.rok_vyroby.value == "" || theForm.rok_vyroby.value.length < 2){
		alert("Prosím zadejte rok výroby.");
		theForm.rok_vyroby.focus();
		return false;
	}
	if (theForm.cena.value == "" || theForm.cena.value.length < 2){
		alert("Prosím zadejte cenu.");
		theForm.cena.focus();
		return false;
	}

return true;
}

function zkontroluj_stroje(theForm){
	if (theForm.jmeno_a_prijmeni.value == "" || theForm.jmeno_a_prijmeni.value.length < 2){
		alert("Prosím zadejte jméno a příjmení.");
		theForm.jmeno_a_prijmeni.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
	if (theForm.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	if (theForm.mesto.value == "" || theForm.mesto.value.length < 2){
		alert("Prosím zadejte město.");
		theForm.mesto.focus();
		return false;
	}
	if (theForm.cena_bez_dane.value == "" || theForm.cena_bez_dane.value.indexOf('.') !=-1 || theForm.cena_bez_dane.value.indexOf('Kč')!=-1 || theForm.cena_bez_dane.value.indexOf('kč')!=-1 || theForm.cena_bez_dane.value.indexOf(' ')!=-1){
		alert("Prosím zadejte cenu. Zadávejte pouze číslo.");
		theForm.cena_bez_dane.focus();
		return false;
	}
	if (theForm.stari == "" ){
		alert("Prosím zadejte stáří komodity.");
		theForm.stari.focus();
		return false;
	}
	if (theForm.pocet_splatek.value == "" || theForm.pocet_splatek.value.length < 2){
		alert("Prosím požadovaný počet splátek.");
		theForm.pocet_splatek.focus();
		return false;
	}

return true;
}

function show(object) {
	if (document.getElementById && document.getElementById(object) != null)
	node = document.getElementById(object).style.display='inline';
	else if (document.layers && document.layers[object] != null)
	document.layers[object].display = 'inline';
	else if (document.all)
	document.all[object].style.display = 'inline';
}

function hide(object) {
	if (document.getElementById && document.getElementById(object) != null)
	node = document.getElementById(object).style.display='none';
	else if (document.layers && document.layers[object] != null)
	document.layers[object].display = 'none';
	else if (document.all)
	document.all[object].style.display = 'none';
}


function zmena_typu(){
  form = document.getElementById("form");
	if (form.typ_auta.value == "nákladní")
  {
		show("hmotnost");
		hide("objem_motoru");
	}
	else if (form.typ_auta.value == "osobní" || theForm.typ_auta.value == "užitkové")
	{
		show("objem_motoru");
		hide("hmotnost");
	}
}

