//FUNZIONI PER LA STAMPA
var nIE4Win;    
var nCanPrint;
var printed;
function stampa() {
        printed = "no";
        if (window.print) {
                nCanPrint = "yes";
        } else {
                nCanPrint = "no";
        }
    var agt=navigator.userAgent.toLowerCase()
    nVersion = parseInt(navigator.appVersion);
    nIE  = (agt.indexOf("msie") != -1);
    nWin   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
        nMac = (agt.indexOf("mac") != -1);
        nIE4Win  = (nIE && (nVersion == 4) && nWin);
        doPrint();
}
function doPrint() {
        if (nCanPrint == "yes") {
                printed="yes";
                window.print();
        } else if (nIE4Win) {
                printed="yes";
                IEPrint();
        }
        else if (nWin)
        {
        alert("To print this image, click your browser's Print button.");               
        }
}
function myFocus() {
        if (printed == "yes") {
                //window.close()
        }
}

// FINE FUNZIONI STAMPA 

//FUNZIONI PER LA LETTURA E SCRITTURA COOKIES

function setCookie(name, value, days) {
   var expire = new Date();
   expire.setTime(expire.getTime() + (60*60*24*days*1000));
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {        
    begin = document.cookie.indexOf(NameOfCookie+"=");      
	
    if (begin != -1) {       
      begin += NameOfCookie.length+1;      
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;   
        return unescape(document.cookie.substring(begin, end));
    }
  }
  return null;
} 

function Init(){ 
registrato = 0
username=getCookie('utentewealth'); 
if (username!=null) {
	registrato =1 
	document.writeln(" Benvenuto: "+ username)
} else {
//nome = "Azienda della Bassa" ;
// setCookie('utentewealth', nome, 1;
	document.writeln(" Utente non loggato");
	}
}

function Icona_Stampa(){ 

username=getCookie('utentewealth'); 
if (username!=null) {
	//document.writeln(" Benvenuto: "+ username)
	return 1;
} else {
 return 0;
	}
}
// FINE FUNZIONI PER LA LETTURA E SCRITTURA COOKIES
// questa funzione fa comparire un riquadro trasparente sulla pagina
function quadro_no_registrato(){
var str='';		
str+='<div align="center">';
str+='<div id ="transbox">Per non visualizzare questa <\/div>';
str+='<div id ="transbox_2">scritta e stampare correttamente<\/div>';
str+='<div id ="transbox_3">la pagina è necessario <\/div>';
str+='<div id ="transbox_4"> REGISTRARSI<\/div>';
str+='<\/div>';
				document.write(str);

}
