/*FUNZIONI GENERICHE UTILIZZABILI DA QUALSIASI PAGINA*/
function sendNews(lan){
	if (!lan) {lan='it';}
	nWidth=490;
	nHeight=450;
	window.open("/dynnew/"+lan+"/popup/popSendNews.phtml?link="+escape(window.location.href),"WinPopUp","width="+nWidth+",height="+nHeight+",directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");
}

function submitForm(button, form){
		button.disabled=true;
		form.submit();
}

/*FUNZIONI NON GENERICHE MA CONDIVISE DA DUE O PIU' PAGINE AVENTI SIMILE STRUTTURA*/

function ctrlNomeCognomeEmailPhoneNumber ()
{
	prefisso = document.ull.pref.value;
	numero = document.ull.tel.value;
	prefisso = trim_string(prefisso);
	numero = trim_string(numero);

	if ((prefisso == '') && (numero == '' ))
	{
		alert('Inserire il prefisso e il numero.');
		return(false);
	}

	if(prefisso == '')
	{
		alert('Inserire il prefisso.');
		return(false);
	}
	if(numero == '' )
	{
		alert('Inserire il numero telefonico.');
		return(false);
	}
	if(!Is_Number(prefisso))
	{
		alert('Inserire un prefisso valido');
		return(false);
	}

	if(prefisso.substr(0,1)!='0')
	{
		alert('Inserire un prefisso valido');
		return(false);
	}


	if(!Is_Number(numero))
	{
		alert('Inserire un numero di telefono valido');
		return(false);
	}

	if ((numero.substr(0,1)=='0') || (numero.substr(0,1)=='1'))
	{
		alert('Inserire un numero di telefono valido');
		return(false);
	}


	var espressione = /^[a-zA-Z][?????a-zA-Z\ ]*$/;
	var stringa = document.ull.nome.value;
	if (!espressione.test(stringa)  )
	{
		alert("Nome non valido!");
		return false;
	}

	if ( stringa.length<3 )
	{
		alert("Il nome deve contenere almeno 3 caratteri!");
		return false;
	}

	espressione = /^[a-zA-Z][?????a-zA-Z\ ]*$/;
	stringa = document.ull.cognome.value;
	if (!espressione.test(stringa))
	{
		alert("Cognome non valido!");
		return false;
	}


	if ( stringa.length<2 )
	{
		alert("Il cognome deve contenere almeno 2 caratteri!");
		return false;
	}



	espressione = /^[a-zA-Z][a-zA-Z1-9_\-\.]*$/;
	stringa = document.ull.username.value;
	if (!espressione.test(stringa))
	{
		alert("E-mail non valido!");
		return false;
	}
	if ( stringa.length<2 )
	{
		alert("Errore nel campo E-mail!");
		return false;
	}

	espressione = /^[a-zA-Z1-9_\-][a-zA-Z1-9._\-]*\.[a-zA-Z1-9]+$/;
	stringa = document.ull.domain.value;
	if (!espressione.test(stringa))
	{
		alert("Dominio non valido!");
		return false;
	}

	if ( stringa.length<3 )
	{
		alert("Errore nel campo E-mail!");
		return false; 
	}


	return(true);

}


function trim_string(string)
{
	var ichar, icount;
	var strValue = string;
	ichar = strValue.length - 1;
	icount = -1;
	while (strValue.charAt(ichar)==' ' && ichar > icount)
		--ichar;
	if (ichar!=(strValue.length-1))
		strValue = strValue.slice(0,ichar+1);
	ichar = 0;
	icount = strValue.length - 1;
	while (strValue.charAt(ichar)==' ' && ichar < icount)
		++ichar;
	if (ichar!=0)
		strValue = strValue.slice(ichar,strValue.length);
	return strValue;
}

function Is_Number(sDato)
{
	var i;
	var CodeChr;
	for (i = 0;  i < sDato.length;  i++)
	{
		CodeChr = sDato.charAt(i);
		if ((CodeChr<'0') || (CodeChr>'9'))
		return(false);
	}
	return(true);
}

function wait() {
    sm('boxWait',324,159); 
}

function no_wait() {
    hm('boxWait');
}


function PhoneNumber()
{
	if (typeof(document.ull[0].pref) != "undefined")
	{
		prefisso = document.ull[0].pref.value;
		numero = document.ull[0].tel.value;
	}
	else
	{
		prefisso = document.ull.pref.value;
		numero = document.ull.tel.value;
	}
	prefisso = trim_string(prefisso);
	numero = trim_string(numero);

	if ((prefisso == '') && (numero == '' ))
	{
		alert('Inserire il prefisso e il numero.');
		return(false);
	}

	if(prefisso == '')
	{
		alert('Inserire il prefisso.');
		return(false);
	}
	if(numero == '' )
	{
		alert('Inserire il numero telefonico.');
		return(false);
	}
	if(!Is_Number(prefisso))
	{
		alert('Inserire un prefisso valido');
			return(false);
	}

	if(prefisso.substr(0,1)!='0')
	{
		alert('Inserire un prefisso valido');
			return(false);
	}


	if(!Is_Number(numero))
	{
		alert('Inserire un numero di telefono valido');
		return(false);
	}

/*
	    if ((numero.substr(0,1)=='0') || (numero.substr(0,1)=='1'))
	    {
		    alert('Inserire un numero di telefono valido');
			return(false);
	    }
*/

	if ( numero.length<4 ) {
		alert("Inserire un numero di telefono valido");
		return false;
	}

	if (typeof(document.ull[0].mkt) != "undefined"){
		mercato = document.ull[0].mkt.value;
	}else{
		mercato = document.ull.mkt.value;
	}

	if (mercato=='RES') {
		if (    (prefisso.length + numero.length > 10)
			&& !( (prefisso.length + numero.length == 11) && (numero.substr(0,1)=='1') )
		) {
			alert("Inserire un telefono valido");
			return false;
			}
	}

// *****************************

	// document.getElementById('wait').style.display='block';
	wait(); 
	if(document.getElementById('C701240658') != null)
		{
		document.getElementById('C701240658').style.visibility='visible';
		}
	document.getElementById('tastoverif').style.display='none'; 
	document.getElementById('tipo').style.display='none'; 

	return(true);
}


function Invia()
{
	if(PhoneNumber()) document.ull.submit();
}


/*utilizzato per le form di tutto incluso*/
function PhoneNumber_TI()
{

	if (typeof(document.ull1[0].indirizzo) != "undefined")
	{
		indirizzo = $('indirizzoEsteso') ? $('indirizzoEsteso').value:$('indirizzo').value;
		civico = document.ull1[0].civico.value;
		comune = document.ull1[0].comune.value;
		provincia = $('provinciaEstesa') ? $('provinciaEstesa').value:$('provincia').value; 
		//cap = document.ull1[0].cap.value;
		//tipoindirizzo = document.ull1[0].tipoindirizzo.value;
	}
	else
	{
		indirizzo = $('indirizzoEsteso') ? $('indirizzoEsteso').value:$('indirizzo').value;
		civico = document.ull1.civico.value;
		comune = document.ull1.comune.value;
		provincia = $('provinciaEstesa') ? $('provinciaEstesa').value:$('provincia').value;
		//cap = document.ull1.cap.value;
		//tipoindirizzo = document.ull1.tipoindirizzo.value;
	}

	indirizzo = trim_string(indirizzo);
	civico = trim_string(civico);
	upper_civico = civico.toUpperCase();	
	comune = trim_string(comune);
	provincia = trim_string(provincia);
	//cap = trim_string(cap);
	//tipoindirizzo = trim_string(tipoindirizzo);
	/*
	if(tipoindirizzo == '')
	{
		alert('Inserire il tipo indirizzo.');
		return(false);
	}*/
	if(provincia == '' || provincia=='Provincia') {
		alert('Selezionare la provincia.');
		return(false);
	}
	if(comune == '' || comune == 'Comune') {
		alert('Inserire il comune.');
		return(false);
	}
	if(indirizzo == '' || indirizzo == 'Indirizzo') {
		alert('Inserire l\'indirizzo.');
		return(false);
	}
	if(civico == '' || upper_civico.indexOf('CIV') != -1 ){
		alert('Inserire il civico.');
		return(false);
	}
	/*
	if(cap == '' )
	{
		alert('Inserire il cap .');
		return(false);
	}
	if(!Is_Number(cap))
	{
		alert('Inserire un cap valido');
		return(false);
	}*/
	
	

	// document.getElementById('wait2').style.display='block';
	wait();
	if(document.getElementById('C701240659') != null)
		{
		document.getElementById('C701240659').style.visibility='visible';
		}
	// document.getElementById('tastoverifTI').style.display='none'; 
	if($('tipoTI') != null)
		{
		document.getElementById('tipoTI').style.display='none'; 
		}
	return(true);
}

function Invia_TI()
{
		if(PhoneNumber_TI()) document.ull.submit();
}



function get_url_param(name)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
	var regexS = "[\\?&]"+name+"=([^&#]*)"; 
	var regex = new RegExp( regexS ); 
	var results = regex.exec( window.location.href ); 
	if( results == null ) return ""; 
	else return results[1];
}


// Popup video verso Libero Video
function videoPopup(theID) {
	vPopup = window.open("about:Blank","videopopupid","width=420,height=353,status=no,menubar=no,resizable=no,scrollbars=no,toolb	ar=no,location=no,directories=no");
	vPopup.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	vPopup.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
	vPopup.document.write('<head>');
	vPopup.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
	vPopup.document.write('<title>infostrada.it</title>');
	vPopup.document.write('</head>');
	vPopup.document.write('<body>');
	vPopup.document.write('<object width="400" height="333"><param name="movie" value="http://video.libero.it/static/swf/eltvplayer.swf?id='+ theID +'&ap=1" /><embed src="http://video.libero.it/static/swf/eltvplayer.swf?id='+ theID +'&ap=1" width="400" height="333" type="application/x-shockwave-flash"></embed></object>');
	vPopup.document.write('</body>');
	vPopup.document.write('</html>');
}

// Popup video verso Libero Video
// Si apre solo se chiamato con un url che abbia un parametro openvideo==OpenVideoValue
function videoPopupIf(theID, OpenVideoValue) {
	ovvalue = get_url_param("openvideo");
	if (ovvalue == OpenVideoValue) {
		videoPopup(theID);
	}
}

function validate_this(obj,ev) {	 	
	
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	
	
	 
	switch(obj.name) {
		case 'indirizzoEsteso':
				var stringa = obj.value;
				  //alert(String.fromCharCode(key));
					stringa = stringa.replace(String.fromCharCode(224),"a'");
			    stringa = stringa.replace(String.fromCharCode(232),"e'");
				  stringa = stringa.replace(String.fromCharCode(233),"e'");
				  stringa = stringa.replace(String.fromCharCode(236),"i'");
				  stringa = stringa.replace(String.fromCharCode(242),"o'");
				  stringa = stringa.replace(String.fromCharCode(249),"u'");
				
				obj.value = stringa;	
			  break;

		case 'civico':  // NUM.CIVICO 123 || 123/A1
		  
		  var stringa = obj.value;
		  
		  if ((key==8 || key==46) && (stringa=='K' || stringa=='SN'|| stringa=='NC' || stringa=='SC')) {
		  	obj.value='';
		  	stringa='';
		  } else if(key=44) {
		  	obj.value = obj.value.replace(',','.');
		  	stringa = obj.value;
		  }
		  
		  /*
			if (stringa.substr(0,2)=='KM' && stringa.length>5 && stringa.length<10 && ((key>47 && key<58) || key==8 || key==46)) {
				stringa = stringa.replace('.','');
			  if (stringa.length>5) 
			  		stringa = stringa.substr(0,stringa.length-3)+'.'+stringa.substr(stringa.length-3);
		 	  
			} 
			*/
		  obj.value=stringa;
		  
		  if (stringa=='s' || stringa =='S') obj.value='SNC';
		  if (stringa=='k' || stringa =='K') obj.value='KM';
		 
		  var pattern_esatto = new RegExp("^(([1-9]{1}[0-9]*)(/{1}[a-zA-Z]*[0-9]*[a-zA-Z]*)?|(KM){1}[1-9]{1}[0-9]{0,3}\.?[0-9]{0,3}|(KM){1}|(SNC){1})$");
		  var pattern        = new RegExp("^(([1-9]{1}[0-9]*)(/{1}[a-zA-Z]*[0-9]*[a-zA-Z]*)?|(KM){1}[1-9]{1}[0-9]{0,3}\.?[0-9]{0,3}|(KM){1}|(SNC){1})");   
		  
		  stringa = obj.value;
	
			var result = stringa.search(pattern_esatto);
			var campo = obj.value;
			var new_campo='';	
		
			if (result<0) {
				
				if (stringa.match(pattern)) {	
					obj.value = stringa.match(pattern)[0];
				} else {			
				  obj.value='';
				}
				if (obj.name=='civico')  open_tooltip(obj,"<strong>NUMERO CIVICO</strong> deve essere compilato nel seguente modo <br>es. <strong>123/A</strong> (Numero Civico<strong>/</strong>eventuale palazzo o scala), oppure <strong>KM1.432</strong>, oppure <strong>SNC</strong> (senza numero civico)",'right','Attenzione!',false,'',true);;
				return false;
			} else {
				close_tooltip(obj);
			}
		  break;
		
	}
}

function updateListaComuni(){	
	if ($('provincia').value!='Provincia') {
  	var checkRequest = new Request.HTML( {method: 'post', url: scriptServerPath, update: $('comune'),		onSuccess: function(){activateIndirizzoComune('provincia'); $('comune').focus();}});
		checkRequest.send('autosuggestMode=LOCAL_FS&action=comune&filtro_provincia='+$('provincia').value);
	} else {
	  $('comune').innerHTML="<option value='Comune'>Comune</option>";
	}
}


function autoSuggestCreate () {

  	var checkRequest = new Request.HTML( {
  		method: 'post', 
  		url: scriptServerPath, 
  		onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  			if(responseHTML=='ON') {
          if ($('AUTOSUGGEST_INACTIVE')) $('ull1').removeChild($('AUTOSUGGEST_INACTIVE'));
  				$('AUTOSUGGEST_ACTIVE').style.display='block';
  				
  				
  				var options = {
						minchars:1,
						maxresults:15,
						timeout:5000,
					  script:scriptServerPath+"?autosuggestMode=REMOTE&mode=subset&action=comune",
					  runtimeVar: Array({"postName":"filtro_provincia","inputName":"provincia","realValueIs":''}),
						varname:"filtro_testo",
						json:true,
						cache:false,
						activateFieldFunction: function() {return activateIndirizzoComune('comune');},
						mode:'REMOTE',
						callback: function (jsonArray) {  } 
					};
					createAutoSuggestFor('comune', options);
		  
				  var options = {
						minchars:1,
						maxresults:15,
						timeout:5000,
					  script:scriptServerPath+"?autosuggestMode=REMOTE&mode=subset&action=indirizzo",
					  runtimeVar: Array({"postName":"filtro_provincia","inputName":"provincia","realValueIs":''},
					                    {"postName":"filtro_comune",   "inputName":"comune",         "realValueIs":''}),
						varname:"filtro_testo",
						json:true,
						cache:false,
						activateFieldFunction: function() {return activateIndirizzoComune('indirizzoEsteso');},
						mode:'REMOTE',
						callback: function (jsonArray) { $('tipoindirizzo').value = jsonArray.id; $('indirizzo').value= jsonArray.value.replace(jsonArray.id+' ', ""); } /* jsonArray.id jsonArray.info jsonArray.value */
					};
					createAutoSuggestFor('indirizzoEsteso', options);

  			} else {
  				 if ($('AUTOSUGGEST_ACTIVE')) $('ull1').removeChild($('AUTOSUGGEST_ACTIVE'));
  			   $('AUTOSUGGEST_INACTIVE').style.display='block';
  			}
  		}
  	});
		checkRequest.send('action=TestPamIsOn');	
}

function activateIndirizzoComune(fieldId){
			
	var il_as_provincia = $('provinciaEstesa') ? $('provinciaEstesa'):$('provincia');
	var il_as_comune =    $('comune');
	var il_as_indirizzo = $('indirizzoEsteso');
	var il_as_civico =    $('civico');
	//$('divDebug').innerHTML=fieldId+' '+il_as_provincia.value; 
	switch(fieldId) {
		case 'comune': if (il_as_provincia.value == 'Provincia' || il_as_provincia.value == '') {
	                 		if (il_as_comune && il_as_comune.value!="Comune") {
											  open_tooltip(il_as_comune,"Selezionare prima la provincia..",'left','Attenzione!',false,'onblur',true);
											  il_as_comune.value="Comune";
											  return false;
											}
	                 };
	                 break;
	  case 'indirizzoEsteso':
	  							 var messaggio="";	
	  							 if (il_as_provincia.value == 'Provincia' || il_as_provincia.value == '') messaggio="Selezionare la provincia e";
	  							 
	  							 if (il_as_comune.value == 'Comune' || il_as_comune.value =='') {
	                 		if (il_as_indirizzo && il_as_indirizzo.value!="Indirizzo") {
											  open_tooltip(il_as_indirizzo,messaggio+" Inserire il comune..",'left','Attenzione!',false,'onblur',true);
                        il_as_indirizzo.value="Indirizzo";
                        return false;
											}
	                 };
	                 break;
	    case 'civico':
	  							 var messaggio="";
	  							 var messaggio_2="";	
	  							 if (il_as_provincia.value == 'Provincia') messaggio="Selezionare la provincia,";
	  							 if (il_as_comune.value == 'Comune' || il_as_comune.value =='')  messaggio_2+=" il comune e" 
	  							 if (il_as_indirizzo.value == 'Indirizzo' || il_as_indirizzo.value =='') {
	                 		if (il_as_civico.value=="n. civ" || il_as_civico.value=='') {
											  open_tooltip(il_as_civico,messaggio+" Inserire "+messaggio_2+" l'indirizzo.",'down','Attenzione!',false,'onblur',true);
                        il_as_civico.value="n. civ";
                        return false;
											}
	                 };
	                 break;
	
	}
	
	return true;	
}





function apridiffurl(nomeLink1,nomeLink2) {
		window.open(nomeLink1, "_self");
	}

/* FUNZIONI PSEUDO MODALBOX PER LOYALTY */

function pseudoModalBox(messaggioTrasmesso, modoConfirm, funzionePerYes){
	var divMascheramento = new Element('div', {
		'id' : 'loyalty_modal_wrapper',
		'styles' : {
			'width' : document.body.clientWidth,
			'height' : $('header').clientHeight+$('middle_part').clientHeight+$('footer').clientHeight
			}
		});
	var divContenitore = new Element('div', {
		'id' : 'loyalty_modal_box',
		'styles' : {
			'left' : (document.body.clientWidth-370)/2,
			'top' : (document.body.clientHeight-100)/2
			}
		});
	var divContenitoreSub1 = new Element('div', {
		'class': 'loyalty_modal_box_top'
		});
		divContenitoreSub1.innerHTML = '&nbsp;';
	var divContenitoreSub2 = new Element('div', {
		'class': 'loyalty_modal_box_content'
		})
		divContenitoreSub2.innerHTML = messaggioTrasmesso;
	var divContenitoreSub3 = new Element('div', {
		'class': 'loyalty_modal_box_bottom'
		});
		divContenitoreSub3.innerHTML = '&nbsp;';
	
	if(modoConfirm == true)
		{
			// alert('creazione tasti');
			var divSeparatore = new Element('div', {
			'class': 'clear f0'
			});
			divSeparatore.innerHTML = '&nbsp;';
			divSeparatore.inject(divContenitoreSub2, 'bottom');
			var divContenitoreTasti = new Element('div', {
				'class': 'loyalty_modal_box_content_confirm'
				});
			divContenitoreTasti.innerHTML = '<a onclick=' + funzionePerYes + 'href="#" class="loyalty_btn">S&igrave;</a><a onclick="$(\'loyalty_modal_wrapper\').destroy(); return false" href="#" class="loyalty_btn">No</a>';
			divContenitoreTasti.setStyle('padding-left' , '90px');
			divContenitoreTasti.inject(divContenitoreSub2, 'bottom');
		}
		else if(modoConfirm == false)
		{
			var divSeparatore = new Element('div', {
			'class': 'clear f0'
			});
			divSeparatore.innerHTML = '&nbsp;';
			divSeparatore.inject(divContenitoreSub2, 'bottom');
			var divContenitoreTasti = new Element('div', {
				'class': 'loyalty_modal_box_content_confirm'
				});
			divContenitoreTasti.innerHTML = '<a onclick="$(\'loyalty_modal_wrapper\').destroy(); return false" href="#" class="loyalty_btn">Chiudi</a>';
			divContenitoreTasti.setStyle('padding-left' , '132px');
			divContenitoreTasti.inject(divContenitoreSub2, 'bottom');
		}
	
	divContenitoreSub1.inject(divContenitore, 'top');
	divContenitoreSub2.inject(divContenitore, 'bottom');
	divContenitoreSub3.inject(divContenitore, 'bottom');
	divContenitore.inject(divMascheramento, 'top');
	divMascheramento.inject($('inner_content'), 'after');
}

function aggiornaDomande(valorePassato){
	// attivo seconda select
	$('loyalty_faq_select_domande').removeProperty('disabled');
	// azzero domande precedenti se presenti
	$$('#loyalty_faq_select_domande option').each(function(item, index){
				if(index != 0)
					{
						item.destroy();
					}
				});
	// ciclo ricerca domande per argomento passato
	$$('.loyalty_faq_domanda').each(function(item, index){
		// selezioni domanda solo se relativa all'argomento scelto
		if(item.getNext('div').getNext('div').innerHTML == arrayArgomenti[valorePassato])
			{
			// alert(item.getNext('div').getNext('div').innerHTML);
			var optionDaAggiungere = new Element('option', {
				'value' : index
				});
			optionDaAggiungere.innerHTML = item.innerHTML;
			optionDaAggiungere.inject($('loyalty_faq_select_domande'), 'bottom');
			}
		});
	// alert(arrayArgomenti[valorePassato]);
}

function mostraRisposta(valorePassato){
	// alert(valorePassato);	
	if(valorePassato != 'null')
		{
		$('loyalty_domanda_prescelta').innerHTML = $$('.loyalty_faq_domanda')[valorePassato].innerHTML;
		$('loyalty_risposta_prescelta').innerHTML = $$('.loyalty_faq_risposta')[valorePassato].innerHTML;
		}
		else
		{
		$('loyalty_domanda_prescelta').innerHTML = '&nbsp;';
		$('loyalty_risposta_prescelta').innerHTML = '&nbsp;';
		}
}

function WinPopUp(strPath,nWidth,nHeight){
	if(isNaN(nWidth)){nWidth=490;}
	if(isNaN(nHeight)){nHeight=340;}
	var nXMax = screen.width;
	var nYMax = screen.height;
	var nXOffset = (nXMax - nWidth)/2;
	var nYOffset = (nYMax - nHeight)/2;
	window.open(strPath,"win"+nWidth,"top="+nYOffset+",left="+nXOffset+",width="+nWidth+",height="+nHeight+",directories=no,toolbar=no,scrollbars=yes,resizable=no");
}

/* FUNZIONI COOKIE */

function impostaCookie (nome, valore, scadenza, path) {
    valore = escape(valore);
	stringaCookie = nome +'='+ valore;
	if (typeof(scadenza) != 'undefined' && scadenza != '') { stringaCookie += ';expires='+ scadenza; };
	// esempio stringa scadenza -- Thu, 2 Aug 2001 20:47:11 UTC
	// alert (typeof(scadenza));
	// alert (stringaCookie);
	if (typeof(path) != 'undefined') { stringaCookie += ';path='+path; } else { stringaCookie += ';path=/'; };
    document.cookie= stringaCookie;
}

function valoreCookie (nome) {
   var valore=document.cookie; //ottiene la stringa di cookie
   var inizioCookie=valore.indexOf(" " + nome + "="); //trova il cookie desiderato
 
   //se non esiste, magari e' all'inizio della stringa
   if (inizioCookie == -1) { 
      inizioCookie = valore.indexOf(nome + "=");
   }
 
   if (inizioCookie == -1) { //il cookie non esiste proprio
      valore = null;
   }
 
   if (inizioCookie >= 0) { //il cookie esiste
      //qui inizia la stringa del valore
      inizioCookie = valore.indexOf("=", inizioCookie) + 1; 
      var fineCookie = valore.indexOf(";", inizioCookie); //qui finisce
      if (fineCookie == -1)  //se non viene trovato, allora e' l'ultimo cookie
         fineCookie = valore.length;
      //elimina i caratteri commutati
      valore = unescape(valore.substring(inizioCookie, fineCookie)); 
   }
 
   return valore;
}

function cookieAttivi () {
    ris = false; //imposta il risultato a falso
    impostaCookie("testCookie", "test"); //crea il cookie fittizio
    if (valoreCookie("testCookie") == "test") { //se esiste
        ris = true; //allora i cookie sono abilitati
    }
    return ris;
}

