//funzioni per mostrare data e ora
vTesti = new Object;
dayName_ita = new Array ("Domenica", "Luned&igrave;", "Marted&igrave;", "Mercoled&igrave;", "Gioved&igrave;", "Venerd&igrave;", "Sabato")
dayName_ing = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
dayName_ted = new Array ("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag")
dayName_ = new Array ("Domenica", "Luned&igrave;", "Marted&igrave;", "Mercoled&igrave;", "Gioved&igrave;", "Venerd&igrave;", "Sabato")
monName = new Array ("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre")
var now = new Date()
var old='fam10';

function showFilled(Value) {
	Value = parseInt(Value);
	return (Value>9) ? ""+Value : "0"+Value;
}
function StartClock24() {
  TheTime = new Date;
  document.getElementById('showTime').value = showFilled(TheTime.getHours()) + ":" + showFilled(TheTime.getMinutes());
  setTimeout("StartClock24()",1000)
}


//fine


function CreaVettore(lang){
	switch(lang){
		case "ing":
			vTesti[0]="Check the written E-Mail address!";
			vTesti[1]="You have to accept the handling of your personal data, in order to register you!";
			vTesti[2]="The field Name is compulsory!";
			vTesti[3]="The field Surname is compulsory!";
			vTesti[4]="The field Company Name is compulsory!";
			vTesti[5]="The field Address is compulsory!";
			vTesti[6]="The field Postcode is compulsory!";
			vTesti[7]="The field Nation is compulsory!";
			vTesti[8]="Check the written Phone Number!";
			vTesti[9]="The field City/Town is compulsory!";
			vTesti[10]="The field Province is compulsory!";
			vTesti[11]="The field Country is compulsory!";
			vTesti[12]="The fields User and Password are compulsory!";
			vTesti[13]="Enter a word to start searching!";
			vTesti[14]="Both passwords aren't the same!";
			break;
		case "ted":
			vTesti[0]="Prüfen Sie bitte ob Sie Ihre E-Mail Adresse richtig eingetragen haben!";
			vTesti[1]="Wenn Sie mit den Datenschutzbedingungen nicht einverstanden sind, können Sie sich leider nicht einschreiben!";
			vTesti[2]="Das Vorname-Feld ist obligatorisch!";
			vTesti[3]="Das Name-Feld ist obligatorisch!";
			vTesti[4]="Das Firmaname-Feld ist obligatorisch!";
			vTesti[5]="Das Strasse-Feld ist obligatorisch!";
			vTesti[6]="Das PLZ-Feld ist obligatorisch!";
			vTesti[7]="Das Staat-Feld ist obligatorisch!";
			vTesti[8]="Prüfen Sie bitte ob Sie Ihre Telefonnummer richtig eingetragen haben!";
			vTesti[9]="Das Stadt-Feld ist obligatorisch!";
			vTesti[10]="Das Provinz-Feld ist obligatorisch!";
			vTesti[11]="Das Staat-Feld ist obligatorisch!";
			vTesti[12]="Die Benutzer- und Passwort-Felder sind obligatorisch!";
			vTesti[13]="Tragen Sie bitte ein Wort ein, um die Suche zu starten!";
			vTesti[14]="[Le password inserite non sono uguali!]";
			break;
		default:
			vTesti[0]="Controlla l'indirizzo E-Mail inserito!";
			vTesti[1]="Devi accettare il trattamento dei Dati Personali per effettuare un'iscrizione!";
			vTesti[2]="Il campo Nome e' obbligatorio!";
			vTesti[3]="Il campo Cognome e' obbligatorio!";
			vTesti[4]="Il campo Nome Azienda e' obbligatorio!";
			vTesti[5]="Il campo Via e' obbligatorio!";
			vTesti[6]="Il campo Codice Postale e' obbligatorio!";
			vTesti[7]="Il campo Stato e' obbligatorio!";
			vTesti[8]="Controlla il numero di Telefono inserito!";
			vTesti[9]="Il campo Citta' e' obbligatorio!";
			vTesti[10]="Il campo Provincia e' obbligatorio!";
			vTesti[11]="Il campo Stato e' obbligatorio!";
			vTesti[12]="I campi username e password sono obbligatori!";
			vTesti[13]="Inserisci una Parola per avviare la Ricerca!";
			vTesti[14]="Le password inserite non sono uguali!";
	}
}


function UnsubscribeMail(lang)
{
	CreaVettore(lang);
	
	var lung=null;
	var stringa=null;
	
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   Email = document.SuperForm_2.email.value;
   if (Filtro.test(Email))
   {  }
   else
   {
      alert(vTesti[0]);
      document.SuperForm_2.email.focus();
      return false;
   }
}



function ControllaDati(TipoForm,lang)
{
CreaVettore(lang);

var lung=null;
var stringa=null;

if (TipoForm == 'new')
{
   if (document.SuperForm.acce[0].checked==false)
   {
      alert(vTesti[1]);
      document.SuperForm.acce[0].focus();
      return false;
   }
}

   stringa=document.SuperForm.nome.value
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[2]);
     document.SuperForm.nome.focus();
     return false; 
   }

   stringa=document.SuperForm.cognome.value
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[3]);
     document.SuperForm.cognome.focus();
     return false; 
   }

   stringa=document.SuperForm.via.value;
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[5]);
     document.SuperForm.via.focus();
     return false; 
   }

   stringa=document.SuperForm.cap.value;
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[6]);
     document.SuperForm.cap.focus();
     return false; 
   }

   stringa=document.SuperForm.citta.value;
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[9]);
     document.SuperForm.citta.focus();
     return false; 
   }

   stringa=document.SuperForm.provincia.value;
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[10]);
     document.SuperForm.provincia.focus();
     return false; 
   }

   stringa=document.SuperForm.stato.value;
   lung=stringa.length;
   if (lung<=0)
   { 
     alert(vTesti[11]);
     document.SuperForm.stato.focus();
     return false; 
   }

Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   Email = document.SuperForm.email.value;
   if (Filtro.test(Email))
   {  }
   else
   {
      alert(vTesti[0]);
      document.SuperForm.email.focus();
      return false;
   }

  pw1=document.SuperForm.password1.value;
  pw2=document.SuperForm.password2.value;

  if( (pw1!=pw2) || (pw1=="") || (pw2=="") ){
	alert(vTesti[14]);
	document.SuperForm.password1.focus();
	return false;
  }

  stringa=document.SuperForm.username.value;

  if( stringa=="" ){
	alert(vTesti[12]);
	return false;
  }

return true;
}




function evidenzia(id){
	GID(id).className='evidenziato';
}
		
		
function normale(id){
	GID(id).className='non_evidenziato';
}
	
		


function normaleMercati(){
	var i;
	for (i=0;i<vet_m.length;i++){
		GID(vet_m[i]).className='testo_prodotti_sm';
	}
}




	
function normaleFam(){
	var i;
	for (i=0;i<vet_n.length;i++){
		normale(vet_n[i]);
	}
}




function CalcolaPercorso(){
	CITTAD="Este (PD)";
	INDIRIZZOD="Via%20BELLE";
	ND="2";
			
	

	var CITTA=GID("citta").value;
	var INDIRIZZO=GID("indirizzo").value;
	var N=GID("n").value;
	if( CITTA=="" )
		alert("Inserire la città di partenza!")
	else
		window.open("http://www.viamichelin.it/viamichelin/ita/dyn/controller/Itineraires?strStartCityCountry=612&strStartAddress="+INDIRIZZO+"%2C+"+N+"&strStartMerged="+CITTA+"&strDestCityCountry=612&strDestAddress="+INDIRIZZOD+"&strDestMerged="+CITTAD+"&choiceType=1&ie=UTF-8&x=0&y=0");
}


function CalcolaPercorso2(){
	
        var CITTAD=GID("cittaD").value;
	var INDIRIZZOD=GID("indirizzoD").value;
	var ND=GID("nD").value;
			
	

	var CITTA=GID("citta2").value;
	var INDIRIZZO=GID("indirizzo2").value;
	var N=GID("n2").value;
	if( CITTAD=="" ) 
		alert("Inserire la città di arrivo!")	
	else
		window.open("http://www.viamichelin.it/viamichelin/ita/dyn/controller/Itineraires?strStartCityCountry=612&strStartAddress="+INDIRIZZO+"%2C+"+N+"&strStartMerged="+CITTA+"&strDestCityCountry=612&strDestAddress="+INDIRIZZOD+"&strDestMerged="+CITTAD+"&choiceType=1&ie=UTF-8&x=0&y=0");
}



function GID(id){
	return document.getElementById(id);
}

function show(id){
	GID(id).style.display="block";
}

function hide(id){
	GID(id).style.display="none";
}

function toggleDiv(id){
	if( GID(id).style.display=="none" )
		show(id);
	else
		hide(id);
}

function createMailto(name,domain,classe){
	document.write("<a class='"+classe+"' href='mailto:"+name+"@"+domain+"'>"+name+"@"+domain+"</a>");
}
function checkData(){
	var campi=new Array('nome','cognome');
	for(i=0;i<campi.length;i++){
		if( document.getElementsByName(campi[i])[0].value=="" ){
			alert("Attenzione: manca il campo obbligatorio \""+campi[i]+"\"!");
			return false;
		}
	}
	
	if( !document.getElementById("accetta").checked ){
		alert("Devi accettare il trattamento dei dati personali per continuare!");
		return false;
	}
	return true;
}


/*
estrae il nome della pagina completo di parametri
*/
function getCurrentPage(){
	page=location.href;
	re=/(.+)\/(.+)$/g;
	complete_url=page.replace(re,"$2");
	//tolgo il parametro lang
	re=/(.+)&lang=[a-z]{3}/g;
	complete_url=complete_url.replace(re,"$1");

	return complete_url;
}