/* FUNZIONI GENERICHE UTILIZZABILI DA QUALSIASI PAGINA */
/* ultima versione Luigi Faragalli - 25 novembre 2009 */

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*/
//Setta/resetta i flag dei consensi di MWOL
function pickConsensiMwol(bConsensoCondAcquisto, bConsensoDatiAcquisto, bConsensoDatiPubblicita) {
	// Abilitazione di iscrizione a MWOL
	  document.form_reg.tmpCOND_ACQUISTO[0].disabled=false;
	  document.form_reg.tmpCONSENSODIFFUSIONE[0].disabled=false;
	  document.form_reg.tmpMATERIALEINFORMATIVO[0].disabled=false;
	  document.form_reg.tmpCOND_ACQUISTO[1].disabled=false;
	  document.form_reg.tmpCONSENSODIFFUSIONE[1].disabled=false;
	  document.form_reg.tmpMATERIALEINFORMATIVO[1].disabled=false;	    							  
		//imposto i valori di default
	  document.form_reg.tmpCOND_ACQUISTO[0].checked=Boolean(bConsensoCondAcquisto);
	  document.form_reg.tmpCONSENSODIFFUSIONE[0].checked=Boolean(bConsensoDatiAcquisto);
	  document.form_reg.tmpMATERIALEINFORMATIVO[0].checked=Boolean(bConsensoDatiPubblicita);
	  document.form_reg.tmpCOND_ACQUISTO[1].checked=Boolean(!bConsensoCondAcquisto);
	  document.form_reg.tmpCONSENSODIFFUSIONE[1].checked=Boolean(!bConsensoDatiAcquisto);
	  document.form_reg.tmpMATERIALEINFORMATIVO[1].checked=Boolean(!bConsensoDatiPubblicita);
}

// Funzioni di apertura popup Emulatore i-mode
function popupEmu(filename){
	filepath = "/imode/it/emu/";
        if (filename=="popupEmuHome.phtml"){
	nWidth=732;
	nHeight=560;
      }else if (filename=="popupEmuTech.phtml"){
        nWidth=350;
        nHeight=632;
      }else{
        nWidth=800;
                nHeight=600;
      }
      var nXMax = screen.width;
        var nYMax = screen.height;
      var nXOffset = (nXMax - nWidth)/2;
        var nYOffset = (nYMax - nHeight)/2;
        window.open(filepath+filename,"emu","top="+nYOffset+",left="+nXOffset+", width="+nWidth+",height="+nHeight+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0");
    }


function GuidaConto() {
        win = window.open("guidaconto/guidaConto.html", "win", "height=600,width=700,top=50,left=50,toolbar=no,resizable=no,menubar=no,scrollbars=yes")
        if (win.window.focus) win.window.focus();
}

function flashGuidaConto()
{
        var flashmenu = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="660" height="1200" id="guidaConto_base" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="guidaConto_base.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="guidaConto_base.swf" quality="high" bgcolor="#ffffff" width="660" height="1200" name="guidaConto_base" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
        document.write(flashmenu);
}

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;
}