function email(name, text)
{
   var address = name + "\u0040" + "trust-code" + "." + "it";
   var url = "mailto:" + address;

   if( ! text )
   {
      text = address;
   }

   document.write("<a href=\"" + url + "\">" + text + "</a>");
}

function email_contatti(name, text)
{
   var address = name + "\u0040" + "trust-code" + "." + "it";
   var url = "mailto:" + address;

   if( ! text )
   {
      text = address;
   }

   document.write("<a href=\"" + url + "\" style=color:#715f54;>" + text + "</a>");
}

function validate() {
  validity = true; // assume valid
  var colore = "#ffcc00"

  if (!check_empty(document.informazioni.rgs.value))
        { validity = false;
		document.informazioni.elements["rgs"].style.backgroundColor = colore;
		check_rgs.style.display = "block";
			document.informazioni.elements["rgs"].focus(); return false;
		}
	
  if (!check_empty(document.informazioni.nome.value))
        { validity = false;
		document.informazioni.elements["nome"].style.backgroundColor = colore;
		check_nome.style.display = "block";
			document.informazioni.elements["nome"].focus(); return false;
		}

  if (!check_empty(document.informazioni.cognome.value))
        { validity = false;
		document.informazioni.elements["cognome"].style.backgroundColor = colore;
		check_cognome.style.display = "block";
			document.informazioni.elements["cognome"].focus(); return false;}

  if (!check_empty(document.informazioni.tel.value))
        { validity = false;
		document.informazioni.elements["tel"].style.backgroundColor = colore;
		check_cognome.style.display = "block";
			document.informazioni.elements["tel"].focus(); return false;}			
	
  if (!check_email(document.informazioni.mail.value))
        { validity = false; 
		document.informazioni.elements["mail"].style.backgroundColor = colore; 
		check_mail.style.display = "block";
			document.informazioni.elements["mail"].focus(); return false;}		
						
  if (validity)
		return validity;
}

function validateHD() {
  validity = true; // assume valid
  var colore = "#ffcc00"


  if (!check_emptyHD(document.hdForm.nome.value))
        { validity = false;
		document.hdForm.elements["nome"].style.backgroundColor = colore;
		check_nome.style.display = "block";
		document.hdForm.elements["nome"].focus(); return false;
		}

  if (!check_emptyHD(document.hdForm.cognome.value))
        { validity = false;
		document.hdForm.elements["cognome"].style.backgroundColor = colore;
		check_cognome.style.display = "block";
			document.hdForm.elements["cognome"].focus(); return false;}

  if (!check_emptyHD(document.hdForm.tel.value))
        { validity = false;
		document.hdForm.elements["tel"].style.backgroundColor = colore;
		check_tel.style.display = "block";
			document.hdForm.elements["tel"].focus(); return false;}			
	
  if (!check_email(document.hdForm.mail.value))
        { validity = false; 
		document.hdForm.elements["mail"].style.backgroundColor = colore; 
		check_mail.style.display = "block";
			document.hdForm.elements["mail"].focus(); return false;}		
						
  if (validity)
		return validity;
}

function check_emptyHD(text) {
	//check_rgs.style.display = "none";
	check_nome.style.display = "none";
	check_cognome.style.display = "none";
	check_tel.style.display = "none";
	check_mail.style.display = "none";

  return (text.length > 0); // returns false if empty 
}

function check_empty(text) {
	check_rgs.style.display = "none";
	check_nome.style.display = "none";
	check_cognome.style.display = "none";
	check_tel.style.display = "none";
	check_mail.style.display = "none";

  return (text.length > 0); // returns false if empty 
}

function check_email(address) {
  if ((address == "")
    || (address.indexOf ('@') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}

function paginaLegal(num) {
		window.open("/legal.htm","","height=350,width=550,left=120,top=120");
	}
	
	
function validateDistruggi() {
  validity = true; // assume valid
  var colore = "#ffcc00"

	
  if (!check_empty_distruggi_form(document.distruggi_form.nome.value))
        { validity = false;
		document.distruggi_form.elements["nome"].style.backgroundColor = colore;
		check_nome.style.display = "block";
			document.distruggi_form.elements["nome"].focus(); return false;
		}

  if (!check_empty_distruggi_form(document.distruggi_form.cognome.value))
        { validity = false;
		document.distruggi_form.elements["cognome"].style.backgroundColor = colore;
		check_cognome.style.display = "block";
			document.distruggi_form.elements["cognome"].focus(); return false;}

  if (!check_empty_distruggi_form(document.distruggi_form.tel.value))
        { validity = false;
		document.distruggi_form.elements["tel"].style.backgroundColor = colore;
		check_cognome.style.display = "block";
			document.distruggi_form.elements["tel"].focus(); return false;}			
	
  if (!check_email_distruggi_form(document.distruggi_form.mail.value))
        { validity = false; 
		document.distruggi_form.elements["mail"].style.backgroundColor = colore; 
		check_mail.style.display = "block";
			document.distruggi_form.elements["mail"].focus(); return false;}		
						
  if (validity)
		return validity;
}

function check_empty_distruggi_form(text) {
	check_nome.style.display = "none";
	check_cognome.style.display = "none";
	check_tel.style.display = "none";
	check_mail.style.display = "none";

  return (text.length > 0); // returns false if empty 
}

function check_email_distruggi_form(address) {
  if ((address == "")
    || (address.indexOf ('@') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}
	
