// JavaScript Document

newAlfa=0;
fineAlfa=80;
fineAlfa1=100;
function sfondoAlfa()
{
	newAlfa+=4;
	document.getElementById("sfondoalpha").style.display="block";
	document.getElementById("lay_dw").style.display="block";
	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		if(newAlfa<=fineAlfa)
		  document.getElementById("sfondoalpha").style.filter="alpha(opacity="+newalfa+")";
		  
		  document.getElementById("lay_dw").style.filter="alpha(opacity="+newalfa+")";

	}else
	  {
		if(newAlfa<=fineAlfa)
		{
			document.getElementById("sfondoalpha").style.MozOpacity=newAlfa/100;
			document.getElementById("sfondoalpha").style.opacity=newAlfa/100;
		}
		
		document.getElementById("lay_dw").style.MozOpacity=newAlfa/100;
		document.getElementById("lay_dw").style.opacity=newAlfa/100;
		
	  }
	  
	//counter=setTimeout ("sfondoAlfa()", 10);
	
	if(newAlfa>=fineAlfa1)
	  clearTimeout(counter);
	  
}

function closeDW()
{
	newAlfa=0;
	document.getElementById("sfondoalpha").style.display="none";
	document.getElementById("lay_dw").style.display="none";
}

function openDW()
{
	counter=setInterval ("sfondoAlfa()", 10);
}



function valida_log(){
user=document.logon.user.value;
pass=document.logon.pass.value;

if (user==""){alert("Immettere username"); return false}
if (pass==""){alert("Immettere Password"); return false}
}

function valid_cerca()
{
	p_ric=document.cerca.p_ric.value;
	if (p_ric=="")
	{
      alert("Inserire i dati per la ricerca"); return false
    }
}


function valida_job_opp()
{
	mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	Arr_campi=new Array("nome","cognome", "mittente");
	Arr_risp=new Array("Nome","Cognome", "Mittente");
	
    for (i=0; i<=Arr_campi.length-1; i++)
	 {
		campo=eval("document.registra."+Arr_campi[i]+".value");
		 if (campo=="")
		 {
		  alert("Inserire i dati nel campo " +Arr_risp[i]); return false
		 }
	 }
	 
	  mail=document.registra.mittente.value; 
	 if (mail!="")
	 {
		  if (!mail_reg_exp.test(mail) || (mail == "undefined")) 
             {
            	alert("Indirizzo e-mail non corretto."); return false;
   		     }

	 }
	 
	 allegato=document.registra.allegato.value;
	 
	 if (allegato=="" || allegato=="undefined")
		 {
		  alert("Utilizzando il tasto sfoglia allega il tuo curriculum"); return false
		 }

	 
	 if (!document.registra.privacy.checked)
	 {
       	alert("Per proseguire č necessario accettare la normativa sulla privacy"); return false;
	 }

	
	 show_div('reg');
	 //document.registra.submit();

}


function valida_contatti()
{
	mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	Arr_campi=new Array("nome","cognome", "mittente", "messaggio");
	Arr_risp=new Array("Nome","Cognome", "e-mail", "Messaggio");
	
    for (i=0; i<=Arr_campi.length-1; i++)
	 {
		campo=eval("document.registra."+Arr_campi[i]+".value");
		 if (campo=="")
		 {
		  alert("Inserire i dati nel campo " +Arr_risp[i]); return false
		 }
	 }
	 
	  mail=document.registra.mittente.value; 
	 if (mail!="")
	 {
		  if (!mail_reg_exp.test(mail) || (mail == "undefined")) 
             {
            	alert("Indirizzo e-mail non corretto."); return false;
   		     }

	 }
	 

	
	 
	 //document.registra.submit();

}


function show_div(param)
{
	e=document.getElementById(param).style.display;
	if (e=="none")
	{
	  document.getElementById(param).style.display="block";
  	  for(i=1; i<=tot_div; i++)
	  {
		if (param!=("ord"+i))
	    document.getElementById("ord"+i).style.display="none";

	  }
	}else
	 {
	  document.getElementById(param).style.display="none";
	 }
	 
}



//================================================================================================================================
// FUNZIONI GENERICHE (cioč che possono essre richiamate da script in pagine diverse)


function checkall(param)   //select all checkbox
  {
   sa=false;
  if(eval("document."+param+".check_all.checked"))
    sa=true;

  for (i=0;i<eval("document."+param+".elements.length");i++)
    {
   
      if(sa)
         eval("document."+param+".elements["+i+"].checked=true");
      else
         eval("document."+param+".elements["+i+"].checked=false");
    }
  }
  
  cek=false;
  function anchor_checkall(param)   //select all checkbox
  {
   
  	if(!cek)
    	cek=true;
  	else
    	cek=false;

  	for (i=0;i<eval("document."+param+".elements.length");i++)
    	{
   
      		if(cek)
         		eval("document."+param+".elements["+i+"].checked=true");
      		else
        		eval("document."+param+".elements["+i+"].checked=false");
    	}
  }

countwin=1;
function update_win(param)
{
	 win_upd=window.open(param, "win"+countwin, 'width=600, height=580, ,toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no');
	 win_upd.focus();
	 //countwin++;
}

//================================================================================================================================

