var captcha="";

// generateCapcha
var chars = "23456789abcdefghkmnpqrstuvwxyz";
var string_length = 6;
var randomstring = '';
for (var i=0; i<string_length; i++) 
	{
	var rnum = Math.floor(Math.random() * chars.length);
	captcha += chars.substring(rnum,rnum+1);
	}
var random_text = "<span style=\"font-size:150%;font-weight: bold;\">"+captcha+"</span>";



function sendFrm(theForm){
	mail = new RegExp("^.*[@]+.*[\.]+.{2,4}$");

	if (theForm.jmeno.value=="")
		{
		alert("Zadejte prosím Jméno a příjmení!");
		theForm.jmeno.focus();
		return;
		}

	if (theForm.email.value=="")
		{
		alert("Zadejte prosím E-mail!");
		theForm.email.focus();
		return;
		}
	else
		{
    		if (!mail.test(theForm.email.value))
        		{
        		alert("Neplatný formát E-mail!");
        		theForm.email.focus();
        		return;
        		}
		}

	if (theForm.telefon.value=="")
		{
		alert("Zadejte prosím Telefon!");
		theForm.telefon.focus();
		return;
		}
		
		
		if (theForm.Co_schanite.value=="")
		{
		alert("Zadejte prosím Co schanite!");
		theForm.Co_schanite.focus();
		return;
		}	
		
		if (theForm.Vyrobce_auta.value=="")
		{
		alert("Zadejte prosím Výrobce auta!");
		theForm.Vyrobce_auta.focus();
		return;
		}	
		
		if (theForm.Objem_motoru.value=="")
		{
		alert("Zadejte prosím Objem motoru!");
		theForm.Objem_motoru.focus();
		return;
		}	

		if (theForm.Rok_výroby.value=="")
		{
		alert("Zadejte prosím Rok výroby!");
		theForm.Rok_výroby.focus();
		return;
		}	
		
		if (theForm.captcha.value=="")
		{
		alert("Opište prosím kontrolní text '"+captcha+"' do formuláře!");
		theForm.captcha.focus();
		return;
		}
		else
		{
		if (theForm.captcha.value!=captcha)
			{
			alert("Kontrolní text se neshoduje!");
			theForm.captcha.focus();
			return;
			}
		}
			
	
	theForm.action="http://www.alternator-starter.eu/cgi-bin/email_alternator-starter.cgi";
	theForm.submit();
}
