﻿function chiudi() {document.getElementById("divNewsletter").style.display = "none";} 
    
function mostra() {document.getElementById("divNewsletter").style.display = "block";} 
    

var letto


// imposta il cookie sNome = sValore
// per la durata di iGiorni
function setCookie(sNome, iGiorni, valore) {
    var dtOggi = new Date()
    var dtExpires = new Date()
    //var  = screen.width;
    var larghezza = 0;
    var nuovalarghezza;

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        larghezza = window.innerWidth;
        nuovalarghezza = (larghezza - 995) / 2 ;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        larghezza = document.documentElement.clientWidth;
        nuovalarghezza = (larghezza - 995) / 2 + 10;
    
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        larghezza = document.body.clientWidth;
    }

   
    
    dtExpires.setTime(dtOggi.getTime() + 24 * iGiorni * 3600000)
  	
  	// verifico se esiste il cookie e che valore ha (show: non c'è o è già valorizzato)
    getCookie(sNome);
    
    
	// se hide non mostro nulla; se show mostro iscrizione; se home non mostro ma scrivo
    if (letto == "hide" || valore=="hide") {
	    document.cookie = sNome + "=" + escape("hide") + "; expires=" + dtExpires.toGMTString();
		chiudi();
	}
	if (letto == "show" && location.href == "http://www.chicago-blog.it/") {
	    document.getElementById("divNewsletter").style.marginLeft = nuovalarghezza + 'px';
	    mostra();
	  	//setTimeout('chiudi()',200000000000);	
	  	}
  	if (letto == "home") {
  	    document.cookie = sNome + "=" + escape("show") + "; expires=" + dtExpires.toGMTString();
  	    chiudi();
  	}
}


// restituisce il valore del cookie sNome
function getCookie(sNome) {
    letto = "";
    var asCookies = document.cookie.split("; ");
    for (var iCnt = 0; iCnt < asCookies.length; iCnt++)
    {
    var asCookie = asCookies[iCnt].split("=");
    if (sNome == asCookie[0]) { 
        letto=asCookie[1];
      return (unescape(asCookie[1]));
        }
    }
  // SE non esiste il cookie richiesto
    if (letto == "") {letto = "home";}
    return(letto);
}

// rimuove un cookie
function delCookie(sNome) {
    setCookie(sNome,1, "hide");
    chiudi();
}








function showimg() {
    if (document.getElementById("email").value == "") {
        document.getElementById("email").style.backgroundImage = 'url("http://www.brunoleoni.com/images/tuamail.gif")';
    }
    else {
        document.getElementById("email").style.backgroundImage = '';
    }
}


function hideimg(ID, tipo) {
  document.getElementById("email").style.backgroundImage = '';
}
