﻿defaultStrings = new Array ("Azienda *","Nome *","Città | Località *","e-mail *","Telefono","Messaggio","Fax");

function defaultInputText (myFiled,defString)
	{	
	if (myFiled.value=="")
		myFiled.value=defString;
	}
	
function resetInputText (myFiled,defString)
	{		
	if (myFiled.value==defString)
		myFiled.value="";
	}

function initFields(myStrings)
	{	
	myform=document.myForm;
	myform.azienda.value=myStrings[0];
	myform.nome.value=myStrings[1];
	myform.citta.value=myStrings[2];
	myform.email.value=myStrings[3];
	myform.telefono.value=myStrings[4];
	myform.messaggio.value=myStrings[5];
	myform.fax.value=myStrings[6];
	}


function ControllaForm(myStrings) 
	{
	var msg="";				
	myform=document.myForm;
	if (myform.azienda.value == "" || myform.azienda.value==myStrings[0]) 
			{
			controllo=true;
			msg+="Il campo Azienda è obbligatorio.\n";
			}
	if (myform.nome.value == "" || myform.nome.value==myStrings[1]) 
			{
			controllo=true;
			msg+="Il campo Nome è obbligatorio.\n";
			}
	if (myform.citta.value == "" || myform.citta.value==myStrings[2]) 
			{
			controllo=true;
			msg+="Il campo Città è obbligatorio.\n";
			}
	if (myform.email.value == "" || myform.email.value==myStrings[3]) 
		{
		controllo=true;
		msg+="Il campo e-mail è vuoto.\n";
		}
	else
		{
		if (myform.email.value.indexOf("@") == -1 ) 
			{
			controllo=true;
			msg+="L'e-mail inserita non è valida.\n";
			}		
		}			
			
	if (msg.length)
		{alert(msg);}
	else
		{
		xmlhttpPost('email.php', 'myForm', 'contactsForm', '');
		document.getElementById('id11').style.visibility = 'hidden';
		document.getElementById('id32').style.visibility = 'hidden';
		}
	} 	