var colorOk="#F5F5F4";
var borderOk="#6F6E6C";
var colorN="#fbaeae";
var borderN="#ff0000";
function odznacz(element)
{
	document.getElementById(element).style.backgroundColor=colorOk;
	document.getElementById(element).style.borderColor=borderOk;
}
function sprawdz() 
{
	var komunikat='';
	d=document;
	valid=0;
	
	/*Data spotkania*/
	if(d.getElementById('data_spotkania').value == "") 
	{
		valid=1;
		komunikat=komunikat+"Proszę wybrać datę spotkania. \n";
	}
	
	/* imie i nazwisko */
	if(d.getElementById('imie_nazwisko').value == "") 
	{
		valid=2;
		komunikat=komunikat+"nie podano imienia i nazwiska lub marki. \n";
		d.getElementById('imie_nazwisko').focus();
		d.getElementById('imie_nazwisko').style.borderColor=borderN;
		d.getElementById('imie_nazwisko').style.backgroundColor=colorN;
	}
	/* email */
	if(d.getElementById('t_email').value == "") 
	{
		valid=3;
		komunikat=komunikat+"Nie podano adresu email.\n";
	} 
	else 
	{
		em = d.getElementById('t_email').value;
		if(em.indexOf("@")<2) 
		{
			valid=3;
			komunikat=komunikat+"\npodany adres email jest chyba niepoprawny.\n proszę sprawdzić prefiks przez znakiem '@'.\n\n";
		}
	}
	if(valid==3) 
	{ 
		d.getElementById('t_email').focus();
		d.getElementById('t_email').style.borderColor=borderN;
		d.getElementById('t_email').style.backgroundColor=colorN; 
	}
	/* telefon */
	if(d.getElementById('t_tel').value == "") 
	{
		valid=4;
		komunikat=komunikat+"Nie podano numeru telefonu. \n";
		d.getElementById('t_tel').focus();
		d.getElementById('t_tel').style.borderColor=borderN;
		d.getElementById('t_tel').style.backgroundColor=colorN;
	}
	/* Miasto */
	if(d.getElementById('miasto').value == "") 
	{
		valid=5;
		komunikat=komunikat+"Nie podano miejsca spotkania. \n";
		d.getElementById('miasto').focus();
		d.getElementById('miasto').style.borderColor=borderN;
		d.getElementById('miasto').style.backgroundColor=colorN;
	}
	
	if(valid==0) 
	{
		d.forms['rezerwuj'].submit();
	}
	else
	{
		alert(komunikat);
		komunikat='';
	}
}
