// JavaScript Document
// JavaScript Document
function validacjaTYP(cel,typ)
{
	if($(cel))
	{ 
		var vartosc = $(cel).value;
		
		if(typ=='select')
		{
			if(vartosc=='' || vartosc=='0')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				$(cel).style.backgroundColor="#ECFFEC";
				return true;
			}	
		}

		if(typ=='tekst')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				$(cel).style.backgroundColor="#ECFFEC";
				return true;
			}	
		}
		if(typ=='email')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				if(vartosc.indexOf('@')>-1 && vartosc.indexOf('.')>-1)
				{
					$(cel).style.backgroundColor="#ECFFEC";
					return true;		
				}
				else
				{
					$(cel).style.backgroundColor="#FFD9D9";
					return false;
				}
			}	
		}
		if(typ=='liczba')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				vartosc = parseFloat(vartosc );
				if(isNaN(vartosc))
				{
					$(cel).style.backgroundColor="#FFD9D9";
					return false;	
				}
				else
				{
					$(cel).style.backgroundColor="#ECFFEC";
					return true;	
				}
			}	
		}
	}
}
function JS_kontakt_form_send(indeks)
{
	var blad = '';	
	
	if(validacjaTYP(indeks+'_nazwa_firmy','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_nazwa_firmyT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_adres','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_adresT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_nip','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_nipT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_imie_nazwisko','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_imie_nazwiskoT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_email','email')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_emailT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_telefon','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_telefonT').innerHTML+"' \r\n";}
	if(validacjaTYP(indeks+'_tresc','tekst')!=true)
		{blad+="-"+SLOWNIK_BLAD+" '"+$(indeks+'_trescT').innerHTML+"' \r\n";}
	
	if(blad=='')
	{
		$(indeks+'_operacja').value = indeks+'_wysylka';
		$(indeks+'_form_kontaktowy').action = '';
		$(indeks+'_form_kontaktowy').submit();
	}
	else
		{alert(blad);}
}
