function pageLoad()
{
  $('newsform').action = 'javascript: void(0)';
	attachDomEvent('newsform', 'submit', controllo, true);
}

function controllo(){
  frm = $('newsform');
  if(frm.nome.value == ''){ alert('family name is required'); frm.nome.focus(); return false; }
  if(frm.cognome.value == ''){ alert('given name is required'); frm.cognome.focus(); return false; }
  if(frm.email.value == ''){ alert("email is required"); frm.email.focus(); return false; }
  frm.action = 'formInvio.php';
  frm.submit();
}

if(window.attachEvent)
{
	window.attachEvent('onload', function(e)
		{
			pageLoad();
		}
	);
}
else
{
	window.addEventListener('load', function(e)
		{
			pageLoad();		
		}, true	
	);
}

function $(stringId)
{
	return document.getElementById(stringId);
}

function attachDomEvent(ElementId, EventType, ClientFunction, UseCapture)
{
	var ClientEventType;
	if(window.attachEvent)
	{
		ClientEventType = 'on' + EventType;
		document.getElementById(ElementId).attachEvent(ClientEventType, ClientFunction)
	}
	else
	{
		document.getElementById(ElementId).addEventListener(EventType, ClientFunction, UseCapture);
	}
}

