function PosizionaX() {    
                      var larghezzapagina = document.body.clientWidth;
                      var noxspace = 0;
                      var xspace = Math.floor((larghezzapagina-1032)/2);
                      xspace = xspace + 4;
 
                      if (larghezzapagina > 1024)
                         return xspace;
                      else
                         return noxspace;
                      }


function PosizionaY() {    
                      var altezzapagina = document.body.clientHeight;
                      var noyspace = 0;
                      var yspace = Math.floor((altezzapagina-628)/2);

                      if (yspace > 80) yspace = 80;

                      if (altezzapagina > 628)
                         return yspace;
                      else
                         return noyspace;
                      }


function Mainframe() {    
                     var linea1 = '<div style="background-image: url(img/sfondo_admin.png); background-repeat: repeat; ';
                     var linea2 = 'background-color: rgb(255,255,255); background-position: 0px 0px; position: absolute; ';
                     var linea3 = 'top: '
                     var linea4 = '; left: ';
                     var linea5 = '; width: 1032; height: 628">';

                     var posizionex = PosizionaX();
                     var posizioney = PosizionaY();

                     var lineacompleta = linea1 + linea2 + linea3 + posizioney + linea4 + posizionex + linea5;

                     return lineacompleta;
                     }


function Popup_pictures(z) {
                           var file = z;                                                            
                           var pos = "top=0, left=0";
                           var at1 = "resizable=no, fullscreen=no, channelmode=no, menubar=no,";
                           var at2 = "toolbar=no, location=no, scrollbars=no, status=no";                                       
                           window.open(file, null, pos + at1 + at2);
                           }


function PopupGalleryPicture(k) {
                                var file = k;
                                var yspace = 14;

                                var larghezzaschermo = screen.width;
                                var xspace = Math.floor((larghezzaschermo-990)/2);                             

                                var altezzaschermo = screen.height;

                                if (altezzaschermo > 768) yspace = Math.floor((altezzaschermo-700)/2);
                                if (yspace > 120) yspace = 120;
                                                            
                                var pos = "top=" + yspace + ", left=" + xspace;
                                var at1 = "resizable=no, fullscreen=no, channelmode=no, menubar=no,";
                                var at2 = "toolbar=no, location=no, scrollbars=no, status=no, width=980, height=680";                                       
                                window.open(file, null, pos + at1 + at2);
                                }


function MM_findObj(n, d) {
                          var p,i,x;
                          if(!d) d=document;
                          if((p=n.indexOf("?"))>0&&parent.frames.length)
                            {
                            d=parent.frames[n.substring(p+1)].document;
                            n=n.substring(0,p);
                            }
                          if(!(x=d[n])&&d.all) x=d.all[n];
                          for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
                          for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
                          if(!x && document.getElementById) x=document.getElementById(n);
                          return x;
                          }



function tmt_findObj(n) {
                        var x,t; if((n.indexOf("?"))>0&&parent.frames.length)
                          {
                          t=n.split("?");
	                  x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	                  }
                        else{x=document.getElementById(n)};
                        return x;
                        }



function MM_showHideLayers() {
                             var i,p,v,obj,args=MM_showHideLayers.arguments;
                             if(document.getElementById)
                               {
                               for (i=0; i<(args.length-2); i+=3)
                                 {
                                 obj=tmt_findObj(args[i]);v=args[i+2];
                                 v=(v=='show')?'visible':(v='hide')?'hidden':v;
                                 if(obj)obj.style.visibility=v;
                                 }
                               }
                             else
                               {
                               for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
                                 {
                                 v=args[i+2];
                                 if (obj.style)
                                   {
                                   obj=obj.style;
                                   v=(v=='show')?'visible':(v='hide')?'hidden':v;
                                   }
                                 obj.visibility=v;
                                 }
                               }
                             }