function TinextBGSwitch(tableCellRef,on){
	if (on ==1)
		tableCellRef.style.backgroundColor = '#F3F3F3';
	else
		tableCellRef.style.backgroundColor = '#FFFFFF';
}

function TinextGoTo(url) {
	window.location.href = "/"+url;
}

function TinextMenuClick( tableCellRef, url ) {
	TinextBGSwitch( tableCellRef, 1);
	TinextGoTo( url );
}


function Form_Validator(theForm)
{

  if (theForm.nome.value == "")
  {
    alert("Inserire un valore per il campo \"Nome\".");
    theForm.nome.focus();
    return (false);
  }

  if (theForm.nome.value.length < 3)
  {
    alert("Inserire almeno 3 caratteri nel campo \"Nome\".");
    theForm.nome.focus();
    return (false);
  }

  if (theForm.cognome.value == "")
  {
    alert("Inserire un valore per il campo \"Cognome\".");
    theForm.cognome.focus();
    return (false);
  }

  if (theForm.cognome.value.length < 3)
  {
    alert("Inserire almeno 3 caratteri nel campo \"Cognome\".");
    theForm.cognome.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Inserire un valore per il campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Inserire almeno 6 caratteri nel campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.servizio.selectedIndex < 0)
  {
    alert("Selezionare una delle opzioni di \"Tipo servizio\".");
    theForm.servizio.focus();
    return (false);
  }

  if (theForm.servizio.selectedIndex == 0)
  {
    alert("La prima opzione di \"Tipo servizio\" non è una selezione valida. Scegliere un'altra opzione.");
    theForm.servizio.focus();
    return (false);
  }

  if (theForm.commenti.value == "")
  {
    alert("Inserire un valore per il campo \"Ci scriva\".");
    theForm.commenti.focus();
    return (false);
  }

  if (theForm.commenti.value.length < 3)
  {
    alert("Inserire almeno 3 caratteri nel campo \"Ci scriva\".");
    theForm.commenti.focus();
    return (false);
  }
  
  if (theForm.captcha.value == "")
  {
    alert("Codice non inserito");
    theForm.captcha.focus();
    return (false);
  }
  return (true);
}



function Event_Form_Validator(theForm)
{

  if (theForm.iscritto[0].checked){
	  if (theForm.data.selectedIndex == 0)
	  {
	    alert("Inserire un valore per il campo \"Data scelta\".");
	    theForm.data.focus();
	    return (false);
	  }
	  
	  if(theForm.n_partecipanti.selectedIndex == 0)
	  {
	    alert("Inserire un valore per il campo \"No partecipanti\".");
	    theForm.n_partecipanti.focus();
	    return (false);
	  }
  }
  
  if (theForm.societa.value == "")
  {
    alert("Inserire un valore per il campo \"Società\".");
    theForm.societa.focus();
    return (false);
  }
  
  if (theForm.soc_indirizzo.value == "")
  {
    alert("Inserire un valore per il campo \"Indirizzo\".");
    theForm.soc_indirizzo.focus();
    return (false);
  }
  
  if (theForm.soc_telefono.value == "")
  {
    alert("Inserire un valore per il campo \"Telefono\".");
    theForm.soc_telefono.focus();
    return (false);
  }

  if (theForm.soc_email.value == "")
  {
    alert("Inserire un valore per il campo \"E-mail\".");
    theForm.soc_email.focus();
    return (false);
  }

  if (theForm.soc_email.value.length < 6)
  {
    alert("Inserire almeno 6 caratteri nel campo \"E-mail\".");
    theForm.soc_email.focus();
    return (false);
  }
  
  if (theForm.nome.value == "")
  {
    alert("Inserire un valore per il campo \"Persona di riferimento\".");
    theForm.nome.focus();
    return (false);
  }

  return (true);
}




// JS function for uncrypting spam-protected emails:
function cryptMailto(s) {	//
alert("step 1");
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n+(1));
	}
	alert(r);
}


// JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}

  // JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s)	{	//
	location.href=UnCryptMailto(s);
}

function check_search_key(){
	if(document.cerca.q.value.length != 0) {return true;}
	return false;
}


function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
