//***********
function ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}
 
function trim ( s )
{
	return rtrim(ltrim(s));
}
//****************




function validaricerca_HP()
{
  if (new Number(document.forms[0].parolachiave.value)==0)
    {
      alert("Errore, inserire il testo da ricercare nelle Notizie")
      return false;
    } 
    else
        return true;
}

function visualizza_approf(id_div)
{
    var arr_div = ['approf1','approf2','approf3']
	for (i in arr_div)
	{
		    if (document.getElementById(arr_div[i]))
			{
			    if (arr_div[i] == id_div)
				{
				    if (document.getElementById(arr_div[i]).style.display == 'block')
					   {
					     document.getElementById(arr_div[i]).style.display = 'none';
					   }
				    else
					   {
					     document.getElementById(arr_div[i]).style.display = 'block';
					   }
				}
			    else
				{
				  document.getElementById(arr_div[i]).style.display = 'none';
				}
		   }  
	}

}

function Invia_Richiesta_Contatto()
{
 var obj_form=document.f_contatto
 
 if (new Number(obj_form.nome.value)==0)
    {
      alert("Errore, inserire il nome")
    }
     else
         {
           if (new Number(obj_form.cognome.value)==0)
              {
                alert("Errore, inserire il cognome")
              }
               else
                    {
                        if (new Number(obj_form.email.value)==0 || obj_form.email.value.indexOf('@') < 0 )
                          {
                            alert("Errore, inserire l'indirizzo email")
                          }
                           else
                               {
                                  
				   if (obj_form.area.value==0)
                                    {
                                      alert("Errore, selezionare lo Studio")
                                    }
                                    else
                                         {
               				   if (new Number(eval("obj_form.argomento" + obj_form.area.value +".value"))==0 )
                                             {
                                             alert("Errore, selezionare l'argomento")
                                             }
                                              else
                                                  {
                                                   if (new Number(obj_form.messaggio.value)==0 )
                                                   {
                                                     alert("Errore, inserire il testo del messaggio")
                                                   }
                                                     else
                                                      {
                                                         obj_form.submit();
                                                      }
                                                   }
				          }	
                               }
                    }  
         }

}

function visualizza_argomenti_area()
{
 if (document.f_contatto.area.value=='L')
  {
     document.f_contatto.argomentoL.style.display="block"
     document.f_contatto.argomentoL.style.visibility="visible"
     document.f_contatto.argomentoT.style.display="none" 
  }
   else
        {
          if (document.f_contatto.area.value=='T')
          {
              document.f_contatto.argomentoT.style.display="block" 
              document.f_contatto.argomentoT.style.visibility="visible"
              document.f_contatto.argomentoL.style.display="none" 
          }
            else
                {
                   document.f_contatto.argomentoT.style.display="none" 
                    document.f_contatto.argomentoL.style.display="none"                 

                   alert("Errore, occorre selezionare lo Studio di competenza")
                } 
        }
}


function traducilinktoblank() 
 { 
   for (var i=0; i<document.links.length; i++) 
     {
       if (document.links[i].className=="blank") 
       {
           { document.links[i].target="_blank"; 
           } 
       } 
     }
         
 }
window.onload=traducilinktoblank;
