// JavaScript Document
function TloRow(wiersz, akcja, color)
{
  if(akcja == 'on') wiersz.bgColor = color;
  else              wiersz.bgColor = color;

  return true;
}

function ZmienTekst(wiersz, akcja, kolor)
{
  //alert(wiersz.cells.length);
  
  if(akcja == 'on') wiersz.cells[3].style.color = kolor;
  else              wiersz.cells[3].style.color = kolor;

  return true;
}

function checkEmail(emailAddress)
{
	var email = emailAddress;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) {
		return false;
	}
	return true;
}

function check_formgzp()
{
	var komunikat = '';
	var blad = false;

	if(document.getElementById('_imienazwisko').value == '')
	{
		komunikat += 'Wypełnienie pola "Imię i Nazwisko" jest wymagane\n';
		blad = true;
	}

	if(document.getElementById('_nazwafirmy').value == '')
	{
		komunikat += 'Wypełnienie pola "Nazwa firmy" jest wymagane\n';
		blad = true;
	}

	if(!checkEmail(document.getElementById('_email').value))
	{
		komunikat += 'Niepoprawny adres e-mail\n';
		blad = true;
	}		

	if(document.getElementById('_service1').checked == false && document.getElementById('_service2').checked == false && document.getElementById('_service3').checked == false)
	{
		komunikat += 'Zaznaczenie jakiejkolwiek z wymienionych usług jest wymagane\n';
		blad = true;
	}

	if(blad)
	{
		alert('Formularz zawiera błędy!\n' + komunikat);
		return false;
	}
	else
	{
		return true;
	}
}
