function myCheckForm(obj)
{
	if (obj.messaggio !=null && obj.messaggio.value == '')
	{
		alert('Scrivi un messaggio da inviare al venditore!');
		return false;
	}
	if (obj.strCheckCaptcha != null && obj.strCheckCaptcha.value == '')
	{
		alert('Inserire il codice di controllo AntiSPAM!');
		return false;
	}
	if (obj.checkPrivacy != null && obj.checkPrivacy.checked != true)
	{
		alert('E\' necessario leggere l\'Informativa sulla Privacy ed accettare le Condizioni Generali spuntando la casella di controllo!');
		return false;
	}
	if (obj.email != null){
		return validEmail(obj.email_contact.value);
	}
	if (obj.titolo != null && obj.titolo.value == ''){
		alert('Inserire il titolo!');
		return false;
	}
	/*if (obj.descrizione != null && obj.descrizione.value == ''){
		alert('Inserire la descrizione!');
		return false;
	}*/
	if (obj.prezzo != null && obj.prezzo.value == ''){
		alert('Inserire il prezzo!');
		return false;
	}
	if (obj.categoria != null && obj.categoria.value == ''){
		alert('Selezionare una categoria!');
		return false;
	}
}


function validEmail(email)
{
   //controlla che la e-mail non sia vuota
   if (email == "")
   {
      alert('Inserire una Email!');
	  return false;
   }

   // controllo della presenza del carattere '@'
   var index     = email.indexOf('@', 0);
   var address   = "";
   var ok = true;

   if (index == -1)
   {
      ok = false;
   }
   else
   {
      var size = email.length;
      address = email.substring(size + 1, index + 1);
      userid =  email.substring(1, index);

      // controlla: l'unicità del carattere "@";
      // - la presenza del "." nella parte DX dell'indirizzo;
      // - l'assenza di spazi e
      // - che la stringa non sia del tipo userid@.address o userid.@address
      if ((address.indexOf('@') != -1) || (userid.indexOf('@') != -1) ||
          (address.indexOf('.') == -1) || (!nospace(email)) ||
          (email.charAt(index - 1) == '.') || (email.charAt(index + 1) == '.'))
      {
         ok = false;
      }
   }
   if (ok == false)
   {
      alert("Indirizzo E-mail non valido!\n (Inserisci un indirizzo nella forma utente@dominio.it)");
      return false;
   }
   else
   {
      return true;
   }
}

function hideShowSearch(){
	if (window.document.getElementById('ric_avanzata').style.display=='none'){
		window.document.getElementById('ric_avanzata').style.display='table-row';
		window.document.getElementById('ric_avanzata_selector').innerHTML='[-] Ricerca Semplice';
		window.document.getElementById('ric_avanzata_show').value='table-row';
	}else{
		window.document.getElementById('ric_avanzata').style.display='none';
		window.document.getElementById('ric_avanzata_selector').innerHTML='[+] Ricerca Avanzata';
		window.document.getElementById('ric_avanzata_show').value='none';
	}
}
