/*
estrae il nome della pagina completo di parametri
*/
function getCurrentPage(){
	page = location.href;
	re = /(.+)\/(.+)$/g;
	complete_url = page.replace(re,"$2");

	str = complete_url.split("?");

	if( str[0].match( ".php" ) )
		pagename = str[0];
	else
		pagename = 'index.php'

	params = str[1];

	if( params==undefined )
		params = "";

	//tolgo il parametro lang
	re = /lang=[a-z]{2}/g;
	params = params.replace(re,"");

	//tolgo il & se č all'inizio
	re = /^&/g;
	params = params.replace(re,"");

	return pagename+"?"+params+"&";
}

function ridimensiona(self,w){
	if( self.width>w )
		self.width=w;
}

function toggleDiv(id){
	if( GID(id).style.display=="block" )
		hide(id);
	else
		show(id);
}

function show(div){
	GID(div).style.display="block";
}
function hide(div){
	GID(div).style.display="none";
}

/*
Abbreviazione per document.getElementById(nomediv)
*/
function GID(id){
	return document.getElementById(id);
}

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

	checkmail="Controlla l'indirizzo email inserito!"
	Email=GID(email).value;
	if( !Filtro.test(Email) ){
		alert(checkmail);
		GID(email).focus();
		return false;
	}
	return true;
}


/*
Mostra un warning se l'immagine non č delle dimensioni corrette
Se metto un * al posto di w o h va bene qualsiasi numero, verrā adattata
*/
function checkSize(self,w,h,warndiv){
	DIV=GID(warndiv);
	if( self.width>w || self.height>h ){
		if( w!="*" )
			self.width=w;
		if( h!="*" )
			self.height=h;
		DIV.innerHTML="<span style=\"font-family:Verdana;font-size:10px;color:#FF0000;\">L'immagine non rispetta le dimensioni massime, pertanto &eacute; stata scalata.</span>";
		DIV.style.display="block";
	}
}


function getTime(){
	now = new Date();
	hour = now.getHours();
	min = now.getMinutes();
	sec = now.getSeconds();
	dayName = new Array ("Domenica", "Luned&igrave;", "Marted&igrave;", "Mercoled&igrave;", "Gioved&igrave;", "Venerd&igrave;", "Sabato");

	day = dayName[now.getDay()];
	data = now.getDate()+"/"+(now.getMonth()+1)+"/"+now.getYear();

	if( min<=9 )
		min = "0"+min;
	if( sec<=9 )
		sec = "0"+sec;

	GID('time').innerHTML = day+" "+data+" "+((hour<=9) ? "0"+hour : hour) + ":" + min + ":" + sec;
	setTimeout("getTime()", 1000);
}



//CONTROLLA DATI PER NEWSLETTER
function ControllaDatiNews(TipoForm){
	checkmail="Controlla l'indirizzo email inserito!"
	accept196="Devi accettare il trattamento dei dati personali leggendo l'informativa sottostante sulla privacy!";
	checkname="Il campo Nome e' obbligatorio!";
	checksurname="Il campo Cognome e' obbligatorio!";
	checkaddress="Il campo Indirizzo e' obblogatorio!";
	checkcap="Il campo C.A.P. e' obbligatorio!";
	checkcomuni="Il campo Comune e' obbligatorio!";
	checknazioni="Il campo Nazione e' obbligatorio!";
		
	
   var lung=null;
   var stringa=null;

   if (TipoForm == 'new'){
     if (GID('acce').checked==false){
       alert(accept196);
       GID('registrati').focus();
       return false;
    }
   }

   stringa=GID('registrati').nome.value;
   lung=stringa.length;
   if (lung<=0){ 
     alert(checkname);
     GID('registrati').nome.focus();
     return false;
   }
   
   stringa=GID('registrati').cognome.value;
   lung=stringa.length;
   if (lung<=0){ 
     alert(checksurname);
     GID('registrati').cognome.focus();
     return false;
   }
   
   stringa=GID('registrati').indirizzo.value;
   lung=stringa.length;
   if (lung<=0){ 
     alert(checkaddress);
     GID('registrati').indirizzo.focus();
     return false;
   }
   
   stringa=GID('registrati').cap.value;
   lung=stringa.length;
   if (lung<=0){ 
     alert(checkcap);
     GID('registrati').cap.focus();
     return false;
   }
     
   stringa=GID('registrati').comuni.value;
   if (stringa==0){ 
     alert(checkcomuni);
     GID('registrati').comuni.focus();
     return false;
   }
   
   stringa=GID('registrati').nazioni.value;
   if (stringa==0){ 
     alert(checknazioni);
     GID('registrati').nazioni.focus();
     return false;
   }

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

   Email = GID('registrati').email.value;
   if( !Filtro.test(Email) ){
      alert(checkmail);
      GID('registrati').email.focus();
      return false;
   }
   
   /*pwd1 = GID('pwd').value;
   pwd2 = GID('pwd2').value;
   if( pwd1.length<=0 || pwd2.length<=0 ){
      alert(checkpass);
      GID('pwd').focus();
      return false;
   }
   if( pwd1!=pwd2 ){
      alert(checkpass);
      GID('pwd').focus();
      return false;
   }
   
   */
   return true;
}

function createMailto(name,domain,text,style){
	var STYLE="";
	EMAIL=name+"@"+domain;
	if( text )
		TESTO=text;
	else
		TESTO=EMAIL;
	if( style )
		STYLE="style=\""+style+"\"";
	document.write("<a class=\"mail\" href=\"mailto:"+EMAIL+"\""+STYLE+">"+TESTO+"</a>");
}



<!-- FUNZIONE PER INSERIMENTO SOLO NUMERI -->
function onlyDigits(fld) {
  fld.value = fld.value.replace(/\D/ig, "");
}


