    lzLPSRoot = './';
    lzAppName = 'index';
    lzCanvasRuntimeVersion = 8 * 1;
    if (lzCanvasRuntimeVersion == 6) {
      lzCanvasRuntimeVersion = 6.65;
    }
    flashPlayerVersion=detectFlash();
    flashPlayerVersion=isNaN(flashPlayerVersion)?0:flashPlayerVersion;
    hasFlash=(flashPlayerVersion >= lzCanvasRuntimeVersion)?true:false;
    isSafari = navigator.appVersion.indexOf('Safari') != -1;
    withDebug=false;
    moreArgs='';
    
    hWndPopup=null;
    
    C2_OnClose_Message='';
    
    //--{{{ Function: addToElement
    function addToElement(id, o) {
      if (document.getElementById) {
          var el = document.getElementById(id);
          // fix bug in IE Mac 5.1 and greater that causes the div to grow
          el.innerHTML = '';
          el.innerHTML = o;
      } else if (document.all) {
          document.all[id].innerHTML = o;
      } else if (document.layers) {
          var oLayer = document.layers[id].document;
          oLayer.open();
          oLayer.write(o);
          oLayer.close();
      }
    }
    //--}}} End Function: addToElement
    //--{{{ Function: showTimer
    function showTimer() {
      var _html='';
      // _html+='<div id="loadMessage">Caricamento applicazione...</div><br>';
       
      /**      
      _html+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; 
      _html+='        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'; 
      _html+='        width="55" height="55">';
      _html+='  <param name="movie" value="resources/Timer.swf">';
      _html+='  <param name="quality" value="high">';
      _html+='  <param name="bgcolor" value="#FFFFFF">';
      _html+='  <embed name="Timer"'; 
      _html+='         src="resources/Timer.swf"';
      _html+='         height="55" width="55"';
      _html+='         scale="exactfit"'; 
      _html+='         quality="high" bgcolor="#FFFFFF"'; 
      _html+='         type="application/x-shockwave-flash"'; 
      _html+='         pluginspage="http://www.macromedia.com/go/getflashplayer">';
      _html+='</object>';
      **/
      
      _html+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; 
      _html+='        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'; 
      _html+='        width="716" height="481">';
      _html+='  <param name="movie" value="resources/splash.swf">';
      _html+='  <param name="quality" value="high">';
      _html+='  <param name="bgcolor" value="#FFFFFF">';
      _html+='  <embed name="Timer"'; 
      _html+='         src="resources/splash.swf"';
      _html+='         width="716" height="481"';
      _html+='         scale="exactfit"'; 
      _html+='         quality="high" bgcolor="#FFFFFF"'; 
      _html+='         type="application/x-shockwave-flash"'; 
      _html+='         pluginspage="http://www.macromedia.com/go/getflashplayer">';
      _html+='</object>';
      if (isIE && isWin || hasFlash) {
        addToElement('main', _html);
      }  
    }
    //--}}} End Function: showTimer
    //--{{{ Function: hideTimer
    function hideTimer() {
      var _main=document.getElementById('main');
      var _root=document.getElementById('container');
      _root.removeChild( _main );
      var _appl=document.getElementById('application');
      _appl.style.left = '0px';
    }
    //--}}} End Function: hideTimer
    //--{{{ Function: loadMessage
    function loadMessage(m) {
      var _message=document.getElementById('loadMessage');
      _text=_message.firstChild;
      _text.nodeValue=m;
    }
    //--}}} End Function: loadMessage
    //--{{{ Function: showApplication
    function showApplication() {
      if (hasFlash) {
        document.getElementById('application').innerHTML='';
        lzEmbed({
                 url: lzLPSRoot+'src/'+lzAppName+'.lzx'+
                      '?lzt=swf'+
                      '&lzr=swf8'+
                      moreArgs +
                      '&__lzhistconn='+top.connuid+
                      '&__lzhisturl=' + escape(lzLPSRoot+'lps/includes/h.html?h='), 
                 bgcolor: '#ffffff', 
                 width: '100%', 
                 height: '100%', 
                 id: lzAppName, 
                 accessible: 'false'
                 }, lzCanvasRuntimeVersion);
         lzHistEmbed(lzLPSRoot);
       } else {
         goDiag();
       }
    }
    //--}}} End Function: showApplication
    //--{{{ Function: showApplicationWithUFO
    function showApplicationWithUFO() {
      if (hasFlash) {
        UFO.create({
                    movie: lzLPSRoot+'src/'+lzAppName+'.lzx'+
                           '?lzt=swf'+
                           '&lzr=swf8'+
                           moreArgs, 
                    flashvars: 'lzt=swf'+
                               '&lzr=swf8'+
                               moreArgs +
                               '&__lzhistconn='+top.connuid+
                               '&__lzhisturl=' + escape(lzLPSRoot+'lps/includes/h.html?h='), 
                    width:"100%", 
                    height:"100%", 
                    bgcolor: '#ffffff', 
                    id: lzAppName, 
                    name: lzAppName, 
                    majorversion:"8", 
                    build:"0" 
                   }, "application");
       } else {
         goDiag();
       }
    }
    //--}}} End Function: showApplicationWithUFO
    //--{{{ Function: doAction
    function doAction(a) {
      lzSetCanvasAttribute('action', a);    
    }
    //--}}} End Function: doAction
    //--{{{ Function: setAttribute
    function setAttribute(a,v) {
      lzSetCanvasAttribute(a, v);    
    }
    //--}}} End Function: setAttribute
    //--{{{ Function: setOnCloseMessage
    // flash.external.ExternalInterface.call('setOnCloseMessage', 'message')
    function setOnCloseMessage(msg) {
      C2_OnClose_Message=msg;
    }
    //--}}} End Function: setOnCloseMessage
    //--{{{ Function: goDiag
    function goDiag() {
      location.href = 'diag.jsp';    
    }
    //--}}} End Function: goDiag
    //--{{{ Function: loadURL
    function loadURL(u) {
      if ( window.frames['ifBuffer'] ) {
        // window.frames['ifBuffer'].location = u;
        /**/
        var _width=(isSafari)?668:400;
        var _height=(isSafari)?520:100;
        hWndPopup=window.open(u, 'ppPrint', 'width='+_width+', height='+_height+', resizable=false, location=false, menubar=false, status=true, toolbar=false');
        
        /**/
        return false;
      } 
      return true;
    }
    //--}}} End Function: loadURL
    //--{{{ Function: popUp
    function popUp(u,h,o,cw,ch) {
      //__{{{ Center window
      cw=(typeof(cw)=='undefined')?false:cw;
      ch=(typeof(ch)=='undefined')?false:ch;
      
      if (cw||ch) {
        //__ Get params
        var _params=o.split(',');
        var _w=document.all?document.body.clientWidth:window.innerWidth;
        var _h=document.all?document.body.clientHeight:window.innerHeight;
        
        //__ Get size
        for (var _p=0; _p<_params.length; _p++) {
        
          if ( _params[_p].indexOf('width') == 0 ) { 
            _w=_params[_p].split("=")[1];

          }
          else if ( _params[_p].indexOf('height') == 0 ) { 
            _h=_params[_p].split("=")[1];
          }
        }
        
        //__ Set position
        for (var _p=0; _p<_params.length; _p++) {
        
          if ( cw && _params[_p].indexOf('left') == 0 ) 
            _params[_p]="left=" + (screen.width-_w)/2;

          else if ( ch && _params[_p].indexOf('top') == 0 ) 
            _params[_p]="top=" + (screen.height-_h)/2;
        }
      
        //__ Set params
        o=_params.join(',');
      }
      //__}}}__
      
      hWndPopup=window.open(u, h, o);

      //__{{{ Try to trap load/unload   
      /**
      hWndPopup.onload= function(p) { 
        //__ Show alert onLoad
        alert('Window Popup Loaded::this['+this.name+'] loc['+this.location.href+']');
        
        //__ Enable trapping on unUnload
        this.onunload= function(p) { 
          //__ Show alert onUnload
          alert('Window Popup Unloaded::this['+this.name+'] loc['+this.location.href+']'); 
        };
      };
      // hWndPopup.onclose= function(p) { alert('Window Popup Closed['+p+'] this['+this.name+'] closed['+this.closed+']'); };
      **/
      //__}}}__
    }
    //--}}} End Function: popUp
    //--{{{ Function: C2_attachEvent
    function C2_attachEvent(elem, eventName, eventHandler, useCapture) {
      // alert('attachEvent('+eventName+')');
      if (!elem) return;
      
      //if (eventName.substring(0, 2) == "on")
      //  eventName = eventName.substring(2,eventName.length);
       
      if (elem.addEventListener) { // Gecko
        // alert('attachEvent::addEventListener('+eventName+')');
        elem.addEventListener(eventName, eventHandler, useCapture);
        return true;
      }
      else if (elem.attachEvent) { // IE
        var _r=elem.attachEvent('on'+eventName, eventHandler);
        // alert('attachEvent::attachEvent('+eventName+':'+_r+')');
        return _r;
      }
      else { // Other
        // alert('attachEvent::set('+eventName+')');
        elem['on'+eventName] = eventHandler;
        return true;
      }
    }
    //--}}}
    //--{{{ Function: C2_detachEvent
    function C2_detachEvent(elem, eventName, eventHandler, useCapture){
      if (!elem) return;

      if (elem.removeEventListener) { // Gecko
        elem.removeEventListener(eventName, eventHandler, useCapture);
        return true;
      } 
      
      else if (elem.attachEvent) { // Internet Explorer
        var _r = elem.detachEvent('on' + eventName, eventHandler);
        return _r;
      }

      else { // Other
        elem['on' + eventName] = '';
        return true;
      }
    }
    //--}}}
    //--{{{ Function: C2_OnClose
    function C2_OnClose(e) {
      /**
        RAMZI : I used the SetVariable() flash method because lzSetCanvasAttribute() 
        don't work on IE if we have iframes in the desktop! 
       **/
    
      // document.getElementById("lzxMain").SetVariable("logout","true");
      
      var msg = 'Chiudere la pagina senza effettuare il \'Logout\' potrebbe comportare la perdita di dati!';
      msg = window['C2_OnClose_Message'];
      if (!e) { e = window.event; }
      if (e) { e.returnValue = msg; }
      /** Orig
      if (typeof(e) == 'undefined') {
        e = window.event;
      }
      if (e) {
        e.returnValue = msg ;
      }
      **/
      return msg;
    }
    //--}}}
    //--{{{ Function: C2_OnUnload
    function C2_OnUnload(e) {
      /**
       Inserire qui il codice da eseguire prima della chiusura dell'applicazione
       **/
      if (opener!=null) {
        opener.alert('Sessione terminata.');
        opener.close();
      }
    }
    //--}}}


