/*

  ************************************************************
  *              EPTO WebGui 5 Ver 2.3  Layer 3/3            * 
  *                 (C) 2007-2009 by EPTO (A)                *
  *                    All rights reserved                   *
  ************************************************************

  Client:     AJAX WebGui 5 Ver 2.3 Layer 3/3 Multiplexer
              (C) 2007-2009 By EPTO (A)
			  All rights reserved

  Server:     PHP WebGui 5 Ver 2.3 Layer 3/3 Multiplexer 
              (C) 2007-2009 By EPTO (A)
              All rights reserved
			  
*/

//Begin the Default ProcSet:

var procset=({	"win":{
					   "ver":"1"				 ,
					   "hdc":""					 ,
					   "kernel":""				 ,
					   "cenx":"1"				 ,
					   "ceny":"1"				 ,
					   "x0":"0"					 ,
					   "y0":"0"					 ,
					   "width":"320"			 ,
					   "height":"200"			 ,
					   "bgcolor":"#ff0000"		 ,
					   "textcolor":"#000000"	 ,
					   "fontstyleset":"9pt Verdana",
					   "title":"No Name"   			,
					   "titlecolor":"#ff8000"		,
					   "inactivecolor":"#dd6f00"	,
					   "titletextcolor":"#000000"	,
					   "bordercolor":"#ff8000"		,
					   "scrollcolor":"#ff8000"		,
					   "shadow":"#ff0000"			,
					   "resize":"0"					,
					   "minimg":""					,
					   "maximg":""					,
					   "cloimg":""					,
					   "resimg":""					,
					   "titlefont":""				,
					   "thema":""					,
					   "lbar":""					,
					   "cbar":""					,
					   "rbar":""					,
					   "overflow":""				,
					   "bgimage":""					,
					   "bgattach":""				,
					   "bgpos":""					,
					   "bgrep":""					,
					   "hook0":""					,
					   "hook1":""					,
					   "font":"8pt Courier New, Monospace",
					   "maxtim":"5"		   			,
					   "icon":""					,
					   "xicon":""					,
					   "next":""					,
					   "icoerr":"/bin/MSGDAN.gif"	 ,
					   "minico":"/bin/MINICO.gif"	 
				}	   ,
				"stat":{
						"normal":"/bin/T.gif"		 ,
						"load":"/bin/barload.gif"	 ,
						"info":"/bin/barinfo.gif"
						}
						,
				"loading":"/bin/loading.gif"	 ,
				"icoerr":"/bin/MSGDAN.gif"		 ,
				"baloon":{ 
						   "bgcolor":"#00ffff"	 ,
						   "color":"#000000"	 ,
						   "border":"#0000ff 1px solid",
						   "maxtim":"3"		 	 ,
						   "font":"Courier new, Monospace"			 ,
						   "fsize":"9pt"		,
						   "alpha":80					   
						   }				,
				"msg":{
					   "copylink":"Link alla finestra copiato"	   ,
					   "nolink":"Link alla finestra non disponibile" ,
					   "winbookm":"Finestra agggiunta ai preferiti"
					   }			  ,
					
				"taskbar":{
						   "none":"No icon in task bar"	 ,
						   "fontFamily":"Verdana"  		 ,
						   "fontSize":"9pt"				 ,
						   "fontColor":"#000000"		 ,
						   "border":"#000000 1px solid"	 ,
						   "icoborder":"#000000 1px solid",
						   "iconover":"#00ffff"		     ,
						   "alpha":"60"					 ,
						   "alpha2":"90"				 ,
						   "color":"#0080ff"			 ,
						   "pwidth":"60"
						   }
							,
					
				"sys":{
					   "hisback":[
					   			  "/bin/HISBACK0.gif" 	 ,
								  "/bin/HISBACK1.gif" 	 
								  ]		,
								 
					   "updateinterval":30
					   }
					  ,
				"effe":{
						"blur":0 		,
						"blockblur":5		,
						"blockmax":60		,
						"blockcolor":"#0000ff" 
						}
					   ,
				"wstyle":{
					
					
					
					"obordstyle":"outset"	,
					"oborwid":"1px"		,
					"cborstyle":"inset"	,
					"cbordwid":"1px"	,
					"contpadding":"0px 2px 0px 4px"	,
					"shadow":20,
					
					"shadowradius":"8px 8px 8px 8px"	,
					"winradius":"8px 8px 8px 8px"	,
					"contradius":"0px 0px 8px 8px"	,
					"titradius":"8px 8px 0px 0px"	,
					"titborder":"#000000 1px solid"	,
					"minimg":"min.gif"	,
					"maximg":"max.gif"	,
					"cloimg":"close.gif"	,
					
					"resimg":"resize.gif"	,
					
					"lbar":"BAR00.png"	,
					
					"cbar":"BAR00.png"	
					
					
					}
					}
					)
					;
	
var mnustyle;

/*
        Begin BASIC Menuset
*/

var menuset=(
			  [
			  
			  {	"ybord":"#000000 1px solid"				 ,
				"xbord":"#000000 1px solid"				 ,
				"upcolor":"#0080ff"	 					 ,
				"upbord":"#000000 1px solid"			 ,
				"xspc":"1"		 	 					 ,
				"yspc":"0"								 ,
				"font":"Courier new, Monospace"			 ,
				"fsize":"9pt"							 ,
				"noico":"/bin/T.gif"					 ,
				"addy":"1"								 ,
				"ysize":"20"							 ,
				"width":"120"							 ,
				"height":"0"							 ,
				"maxtim":"250"							 ,
				"submnu":"/bin/SUBMNU.gif"				 ,
				"separator":"/bin/MNUSEP.gif"			 ,
				"hotfont":"Courier New, Monospace"		 ,
				"hotfsize":"7pt"   						 ,
				"hotcolor":"#000000"					 ,
				"icosize":16							 ,
				"color":[
						 {"ink":"#000000","pap":"#00ffff"}	 ,
						 {"ink":"#0000ff","pap":"#0080ff"} 	 ,
						 {"ink":"#808080","pap":"#c0c0c0"}	 ,
						 {"ink":"#000000","pap":"#00ffff"}	 ,
						 {"ink":"#0000c0","pap":"#00ff00"}
						 ]									 
				}		 
		,
		
		{	"ybord":"#000000 1px solid"				 	 ,
				"xbord":"#000000 1px solid"				 ,
				"upcolor":"#0080ff"	 					 ,
				"upbord":"#000000 1px solid"			 ,
				"xspc":"1"		 	 					 ,
				"yspc":"0"								 ,
				"font":"Courier new, Monospace"			 ,
				"fsize":"10pt"							 ,
				"noico":"/bin/T.gif"					 ,
				"addy":"1"								 ,
				"ysize":"24"							 ,
				"width":"200"							 ,
				"height":"0"							 ,
				"maxtim":"250"							 ,
				"submnu":"/bin/SUBMNU2.gif"				 ,
				"separator":"/bin/MNUSEP.gif"			 ,
				"hotfont":"Courier New, Monospace"		 ,
				"hotfsize":"8pt"   						 ,
				"hotcolor":"#000000"					 ,
				"icosize":24							 ,
				"color":[
						 {"ink":"#000000","pap":"#00ffff"}	 ,
						 {"ink":"#0000ff","pap":"#0080ff"} 	 ,
						 {"ink":"#808080","pap":"#c0c0c0"}	 ,
						 {"ink":"#000000","pap":"#00ffff"}	 ,
						 {"ink":"#0080ff","pap":"#ffff00"}
						 ]									 
				}
		])
		;

var w3c=(document.getElementById)? true: false;
var ie5=(w3c && document.all)? true : false;
var ie5c=(navigator.appVersion.indexOf("MSIE")!=-1);
    ie5c=ie5c || (navigator.appVersion.indexOf("MSIE 4.")!=-1);
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;
var iexbug=(navigator.appVersion.indexOf("MSIE")!=-1);
var divbug=iexbug;
var waitfl=0;
var lastreq=0;
var nextexecuteceter=0;

currIDb=null; xoff=0; yoff=0;
currRS=null; rsxoff=0; rsyoff=0;
oldac=null; newac=null; zdx=1; mx=0; my=0;

var idlist=new Array();

idlist.btns=new Array();
idlist.btns[0]=new Image(); idlist.btns[0].src="min.gif";
idlist.btns[1]=new Image(); idlist.btns[1].src="max.gif";
idlist.btns[2]=new Image(); idlist.btns[2].src="close.gif";
idlist.btns[3]=new Image(); idlist.btns[3].src="resize.gif";

// EXTENSIONS FUNCT //
var SYSCALL = new Object();

function SysCall(name,param) {
  if (!SYSCALL[name]) return false;
  return SYSCALL[name](param);
  }
	
function SysAdd(name,proc) {
  SYSCALL[name] = proc;
  }

function SysDel(name) {
  if (SYSCALL[name]) delete SYSCALL[name];
  }
	
function SysCopy(name,source) {
  if (!SYSCALL[source]) return false;
  SYSCALL[name] = SYSCALL[source];
  return true;
  }
  	
// UEVENT HANDLER //
var UEVENT = new Object();

function EVEDestroy(idx) {
  if (UEVENT[idx]) delete UEVENT[idx];
  }
	
function EVEAdd(idx,event,proc) {
  if (!UEVENT[idx]) UEVENT[idx] = new Object();
  UEVENT[idx][event] = proc;
  }
  
function EVERem(idx,event,proc) {
  if (!UEVENT[idx]) return;
  if (!UEVENT[idx][event]) return;
  delete UEVENT[idx][event];
  }

function EVECall(idx,event,par) {

  if (idx=='') idx='gui';
  if (!UEVENT[idx]) return;
  
  if (!UEVENT[idx][event]) return;
  
  try {
    eval(UEVENT[idx][event]);
    } catch(e) {
    alert('UEvent '+idx+':'+event+' '+e); 
    }
  
  if (idx=='gui') return; 
  if (!UEVENT.gui) return;
  if (!UEVENT.gui[event]) return;
  try {
    eval(UEVENT.gui[event]);
    } catch(e) {
    alert('UEvent gui:'+event+' '+e); 
    }
  
  }
  
function EVECopy(name,source) {
  if (!UEVENT[source]) return false;
  UEVENT[name] = UEVENT[source];
  return true;
  }
	
function BootSystemProc() {
  var log='';
  if (procset.uevents) {
  UEVENTS = new Object();
  
    for (var idx in procset.uevents) {
      try {
        EVEAdd('gui',idx,procset.uevents[idx]);
        } catch(e) {
          log+="UEvent: "+idx+"\t"+e+"\n";
          }
      }
    delete procset.uevents;
    }
  
  SYSCALL = new Object();
  
  if (procset.syscall) {
  UEVENTS = new Object();
  
    for (var idx in procset.syscall) {
      try {
        SysAdd(idx,eval(procset.syscall[idx]));
        } catch(e) {
          log+="SysCall: "+idx+"\t"+e+"\n";
          }
      }
    delete procaset.syscall;
    }
  
  if (log!='') alert(log);
  EVECall('','onboot');
  
  }
	
function EveAddArr(obj) {
  var cx = obj.length;
  var log='';
  
    for (var ax=0;ax<cx;ax++) try { 
      EVEAdd(obj[ax].hdc,obj[ax].eve,obj[ax].proc); 
      } catch(e) {
        log+=ax+' EVEAdd: '+obj[ax].hdc+':'+obj[ax].eve+' '+e+"\n";
        }
  
  if (log!='') alert(log);
  
  }
	
//<!-- EXPORTEDSUB -->

function UnHex(str) {
	return parseInt(str, 16);
}

function Hex(num) {
	if (isNaN(num)) return 0;
	var mulp = new Array();
	mulp[0] = 1;
	var alfa='0123456789ABCDEF';
	var a = 0;
	var m = 0;
	var qq = new String;
	var result=new Array();
	result.length=0;
	for(i=0; num >= (16*mulp[i]);){
		i++;
		mulp[i] = ((mulp[m])*16);
		m++;
	}
	
	for(; num != -1;){	
		var div = parseInt(num/mulp[m]);
		result[a] = alfa.charAt(div);
		num = num - (div)*mulp[m];
		if(mulp[m] == 1 & num == 0) num = -1;
		a++;
		m--;		
		
	}
	for(b = 0; b < result.length; b++){
	qq += result[b];
	}
	
	return qq;
}
	
function URLEncode(plaintext)
{
	var SAFECHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";
	var HEX = "0123456789ABCDEF";
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";	
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function URLDecode(encoded)
{
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
}
	 
function defaultform(title) {
var proc= procset.win;
	
	proc.title=title;
	
	return proc;
	
}

function ToHex(x) {
     var v = String.charCodeAt(x, 0);
		 v = v.toString(16);
		 var m = v.length;
		 var p = '0000';
		 if (m>0 && m<4 ) v = p.substr(m) + v;
		 return "\\u" + v.substr(0,4);		 
		 }

function Escape(st) {
  var str=''+st+'';
  str = str.replace(/\\/g,"\\\\");
  str = str.replace(/\"/g,"\\\"");
  str = str.replace(/\r/g,"");
  str = str.replace(/\n/g,"\\n");
  str = str.replace(/\t/g,"\\t");
  str = str.replace(/[\x00-\x1F]/g, ToHex);
  return str.replace(/[\x80-\xFF]/g, ToHex);
  }

    function JSON(o) {
			
			if (o instanceof Array)  return JSONARRAY(o);
			if (o instanceof Object) return JSONOBJECT(o);
			
			return '"'+Escape(o)+'"';
			
			}
	
	function JSONARRAY (o) {
			 var str='[';
			 var le=o.length;
			 var ax;
			 var f;
			 	 for (ax=0;ax<le;ax++) {
				 	 f=0; 
					 if (o[ax] instanceof Array) {f=1; str+=JSONARRAY(o[ax]);}
					 if (f==0) if (o[ax] instanceof Object) {f=1; str+=JSONOBJECT(o[ax]);}
					 if (f==0) str+='"'+Escape(o[ax])+'"';
					 str+=',';					 
				 	 }
					 
			 if (str!='[') str=str.substr(0,str.length-1);
			 return str+']';
			 }
			 
	function JSONOBJECT (o) {
			 var str='{';
			 var f;
			 var i;
			 	 
				 for (i in o) {
				 	 str+='"'+Escape(i)+'":';
					 f=0;
					 if (o[i] instanceof Array) {f=1; str+=JSONARRAY(o[i]);}
					 if (f==0) if (o[i] instanceof Object) {f=1; str+=JSONOBJECT(o[i]);}
					 if (f==0) str+='"'+Escape(o[i])+'"';
					 str+=',';
				 	 }
					 
			 if (str!='{') str=str.substr(0,str.length-1);
			 return str+'}';
			 }
function AJAXService(file,object,callback,mega) {
		 var req='?';
		 var o;
		 var post;
		 var t;
		 
		 if (mega) {
		 	post='';
			for (o in object) {
				t = new Object();
				t[o]=object[o];
				post+=JSON(t)+'\n';
				}
		 	} else post = JSON(object);
			
		 if (file.charAt(0)!='/') file=server+file;
	 
		 try { HTTP.abort(); } catch(e) { ; }
		 HTTP = new getHTTPObject();
		 
		 HTTP.open('POST',file,true);
		 HTTP.setRequestHeader("Content-type", "application/json");
	 	 HTTP.setRequestHeader("Content-length", post.length);	
		 HTTP.onreadystatechange= function () {
								 if (HTTP.readyState == 4) {
  								 	if (HTTP.status!=200) {
	   								   alert('Server status error\n'+HTTP.statusText);
									   } else {
									   	  try {
  	   								   	   post=eval('(' + HTTP.responseText + ')');
										    } catch(err) { 
											o=document.getElementById('message');
										   if (o) o.innerHTML=HTTP.responseText;
										   
										  	alert('Data Error\n'+HTTP.responseText);
											//return;
											}
									   
										   o=document.getElementById('message');
										   if (o) o.innerHTML=HTTP.responseText;
											
									   callback(post);		   
									   } //200
  								 } //4
											  
		 			} //fun_fun
		 HTTP.send(post);
		 } //ajax


function closewindow(hdc) {
		 goover();
		 delhistory(hdc);
		 hdc++;
		 hidebox('Div'+hdc);
		 //document.getElementById('Div'+hdc).innerHTML="";
		 activeurl='';
		 delete Windows['Div'+hdc];
		 EVECall('w'+hdc,'unload');
     EVEDestroy('w'+hdc);
     if (Maximized['f'+hdc]) delete Maximized['f'+hdc];
}

function setcolor(objid,col) {
		 var v=document.getElementById(objid);
		 if (v) v.style.backgroundColor=col;
		 }

function mouseturn(vm) {
		 if (vm==0) {
		 	window.document.body.style.cursor='default'
			//for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'default';
			} else {
			window.document.body.style.cursor='wait'
			//for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'wait';
			}
}

function loading(hdc) { 
		  var x = document.getElementById('Div'+hdc+'_cI');
		  if (!x) var x = document.getElementById('Div'+hdc+'_c');
		  if (!x) return;
		  x.innerHTML='<table width="100%" height="100%"><tr><td><center><img src="'+procset.loading+'" alt=""><br>Loading...</center></td></tr></table>';
		  }

function removeid(id) {
		 	 
		 var v = document.getElementById(id);
		 if (v) {
		 	v.style.display='none';
			v.innerHTML='';
			if (v.SubMenu) v.SubMenu=null;
			if (v.Data) v.Data=null;
			try { document.body.removeChild(v); } catch(e) { v= null;}
			}
		 }

function ClearGui() {
		 Locked=false;
		 var o=Windows;
		 var key;
		 var le;
		 var hdc;
		 for (key in o) {
		 
		 	 if (key.indexOf('Div')==1) {
			 	hdc=parseInt(key.substr(3));
				
			 	closewindow(hdc);
						} else {
			 	le=o[key].length;
				for (var ax=1;ax<le;ax++) removeid(o[key][ax]);
				
			 	}
		 	 }
	var v=document.getElementById('Blocker_Gui');
	if (v) document.body.removeChild(v);
	Windows=new Object();
	setstat(procset.stat.normal);
	waitfl=0;
	
}
		 
function hidebox(id){
goover();
if (procset.effe.blur!=0) blurwin(id); else hideboxEx(id);
}
function hideboxEx(id) {
removeid(id+'_b');
removeid(id+'_s');
removeid(id+'_c');
removeid(id+'_cI');

var hdc = id.substr(3);
UnSelectForm(parseInt(hdc));


}

function minimize(){
goover();
if (Locked) return;
activeurl='';
if (IsTaskEnabled) if (this.winicon) {
   MinimizeForm(this.hdc);
   return;
   }
if(w3c){
this.IDS[0].style.height=(ie5c)? '28px':'24px';
this.IDS[3].style.height='28px';
this.IDS[2].style.display='none';
this.IDS[4].style.display='none';

setTimeout('ns6bugfix()',100);
}
EVECall('w'+this.hdc,'minimize');
}

function restore(){
goover();
if(w3c){
var h=this.IDS[10];
this.IDS[0].style.height=h+'px'; 
this.IDS[3].style.height=(ie5c)? h+'px':h+5+'px'; 
this.IDS[2].style.display='block';
this.IDS[4].style.display='block'; 
setTimeout('ns6bugfix()',100);
}
EVECall('w'+this.hdc,'maximize');
}

function ns6bugfix(){

var ieb=navigator.appName;
if (ieb.indexOf("Explorer")==-1) {
   self.resizeBy(0,1);
   self.resizeBy(0,-1);
   }
}

function trackmouse(evt){
mx=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
my=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
if(!ns6)movepopup();
if((currIDb!=null)||(currRS!=null))return false;
}

function movepopup(){
if((currIDb!=null)&&w3c){
var x=mx+xoff;
var y=my+yoff;
currIDb.style.left=x+'px';
currIDs.style.left=x+8+'px';
currIDb.style.top=y+'px';
currIDs.style.top=y+8+'px';
}
if((currRS!=null)&&w3c){
var rx=mx+rsxoff;
var ry=my+rsyoff;
var c=currRS;
c.style.left=Math.max(rx,((ie5c)?88:92))+'px';
c.style.top=Math.max(ry,((ie5c)?68:72))+'px';
c.IDS[0].style.width=Math.max(rx+((ie5c)?12:8),100)+'px';
c.IDS[0].style.height=Math.max(ry+((ie5c)?12:8),80)+'px';
c.IDS[1].style.width=Math.max(rx+((ie5c)?4:3),((ns6)?95:92))+'px';
c.IDS[5].style.left=parseInt(c.IDS[1].style.width)-48+'px';
c.IDS[3].style.width=Math.max(rx+12,((ie5c)?100:104))+'px';
c.IDS[3].style.height=Math.max(ry+((ie5c)?12:13),((ie5c)?80:86))+'px';
c.IDS[2].style.width=Math.max(rx-((ie5c)?-5:5),((ie5c)?92:87))+'px';
c.IDS[2].style.height=Math.max(ry-((ie5c)?24:28),44)+'px';
c.IDS[10]=parseInt(c.IDS[0].style.height);
}
}

function startRS(evt){
var ex=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
rsxoff=parseInt(this.style.left)-ex;
rsyoff=parseInt(this.style.top)-ey;
currRS=this;
if(ns6)this.IDS[2].style.overflow='hidden';
return false;
}

function stopdrag(){
currIDb=null;
ns6bugfix();
}

function grab_id(evt){
if (this.fullscreen) return false;
var ex=(ie5)?event.clientX+document.body.scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+document.body.scrollTop:evt.pageY;
xoff=parseInt(this.IDS[0].style.left)-ex;
yoff=parseInt(this.IDS[0].style.top)-ey;
currIDb=this.IDS[0];
currIDs=this.IDS[3];
return false;
}

function subBox(x,y,w,h,bgc,id,styl){
var v=document.createElement('div');
v.setAttribute('id',id);
if (styl) if (styl!="") v.setAttribute('style',styl);  
v.style.position='absolute';
v.style.left=x+'px';
v.style.top=y+'px';
v.style.width=w+'px';
v.style.height=h+'px';
v.style.backgroundColor=bgc;
v.style.visibility='visible';
v.style.padding='0px 0px 0px 0px';
return v;
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function radius(rad) {
	if (rad=="") return "";
	if (ie5c) return "";
	return "-moz-border-radius: "+rad+"; -webkit-border-radius: "+rad+"; border-radius: "+rad+";";
	}

function popUp(x,y,w,h,cid,text,bgcolor,textcolor,fontstyleset,title,titlecolor,titletextcolor,bordercolor,scrollcolor,shadowcolor,showonstart,isdrag,isresize,oldOK,POPPERSESSION,obj){
Windows[cid]=new Array(title,cid+'_b',cid+'_s',cid+'_c',cid+'_cI');
var proceedtopop=false
var inattivo=scrollcolor;
if (title=='') title='&nbsp;';
if (obj.inactivecolor!="") inattivo=obj.inactivecolor;
if (obj.minimg=="") obj.minimg=procset.wstyle.minimg;
if (obj.maximg=="") obj.maximg=procset.wstyle.maximg;
if (obj.cloimg=="") obj.cloimg=procset.wstyle.cloimg;
if (obj.resimg=="") obj.resimg=procset.wstyle.resimg;
if (obj.lbar=="") obj.lbar=procset.wstyle.lbar;
if (obj.cbar=="") obj.cbar=procset.wstyle.cbar;
//if (obj.rbar=="") obj.rbar="RBAR.png";

if (obj.thema!="") {
   obj.thema+="/";
   obj.minimg=obj.thema+obj.minimg;
   obj.maximg=obj.thema+obj.maximg;
   obj.resimg=obj.thema+obj.resimg;
   obj.cloimg=obj.thema+obj.cloimg;
   obj.lbar=obj.thema+obj.lbar;
   obj.cbar=obj.thema+obj.cbar;
   //if (obj.rbar!="") obj.rbar=obj.thema+obj.rbar;
   }

if (POPPERSESSION){
if (get_cookie(cid)==""){
proceedtopop=true
document.cookie=cid+"=yes"
}
}
else
proceedtopop=true

if (proceedtopop){
if(w3c){
var tw, th;
w=Math.max(w,100);
h=Math.max(h,80);
var rdivx=0;
if (procset.win.rdivx) {
   					   rdivx=parseInt(procset.win.rdivx);
					   rdivx=(ie5c)?(rdivx+3):rdivx;
   					   }
var rdiv=new subBox(w-((ie5c)?12:8)-rdivx,h-((ie5c)?12:8),7,7,'',cid+'_rs');
if(isresize){
rdiv.innerHTML='<img src="'+obj.resimg+'" width="7" height="7">';
rdiv.style.cursor='move';
}
tw=(ie5c)?w:w+4;
th=(ie5c)?h:h+6;
var shadow=new subBox(x+8,y+8,tw,th,shadowcolor,cid+'_s',radius(procset.wstyle.shadowradius));

if (procset.wstyle.shadow!=0) alpha(shadow,procset.wstyle.shadow); else shadow.style.visibility='hidden';

shadow.style.zIndex=++zdx;
var tw,th;
var outerdiv=new subBox(x,y,w,h,bordercolor,cid+'_b',radius(procset.wstyle.winradius));
outerdiv.style.borderStyle=procset.wstyle.obordstyle; //"outset";
outerdiv.style.borderWidth=procset.wstyle.oborwid; //"1px";
outerdiv.style.borderColor=bordercolor;
outerdiv.style.zIndex=++zdx;
tw=(ie5c)?w-8:w-5;
th=(ie5c)?h+4:h-4;
var titlebar=new subBox(2,2,tw,20,titlecolor,cid+'_t',radius(procset.wstyle.titradius));
titlebar.style.overflow="hidden";
titlebar.style.cursor="default";
titlebar.xactive=titlecolor;
if (procset.wstyle.titborder) titlebar.style.border=procset.wstyle.titborder;

if (obj.hook0!="") title=obj.hook0+title;
var icoloc='';

if (obj.winicon) {
   				 icoloc='<TD BACKGROUND="'+obj.cbar+'" width=16 >';
				 icoloc+='<img src="'+obj.winicon+'" ID="Div'+cid+'_Icon" border=0 alt="" width=16 height=16><TD>';
				 
				 }

if (obj.history) {
   icoloc+='<TD BACKGROUND="'+obj.cbar+'" width=16><a href="javascript:historyback('; 
   icoloc+="'"+obj.hdc+"');\" target=\"a\"><img src=\"";
   icoloc+=procset.sys.hisback[0];
   icoloc+='" alt="" width=16 height=16 border=0 id="Back'+obj.hdc+'"></a></td>';
   }

  
if (obj.hookleft) {
	var le0=obj.hookleft.length;
		for (var reax0=0;reax0<le0;reax0++) {
			icoloc+='<TD BACKGROUND="'+obj.cbar+'" width=16>';
			if (obj.hookleft[reax0].href!='') {
				icoloc+='<a href="'+obj.hookleft[reax0].href+'" target="a"';
				if (obj.hookleft[reax0].id) icoloc+=' id="Div'+obj.hdc+'_'+obj.hookleft[reax0].id+'_lnk"';
				icoloc+='>' ; //>
				}
			if (obj.hookleft[reax0].ico) {
				icoloc+='<img src="'+obj.hookleft[reax0].ico+'"alt="" width=16 height=16 border=0';
				if (obj.hookleft[reax0].id) icoloc+=' id="Div'+obj.hdc+'_'+obj.hookleft[reax0].id+'"';
				if (obj.hookleft[reax0].js) icoloc+=' onmousedown="'+Escape(obj.hookleft[reax0].js)+'" ';
				icoloc+='>'; //>
				}
			if (obj.hookleft[reax0].href) icoloc+='</a>';
			
			if (obj.hookleft[reax0].history) {
				icoloc+='<a href="javascript:historyback(';
				icoloc+="'"+obj.hdc+"');\" target=\"a\"><img src=\"";
				icoloc+=procset.sys.hisback[0];
   				icoloc+='" alt="" width=16 height=16 border=0 id="Back'+obj.hdc+'"></a>';
				}
			
			icoloc+='</TD>';
			
			}
	}
	
if (obj.fullscreen) {
  if (!obj.hook1) obj.hook1='';
  obj.hook1 = obj.hook1 + "<img src=\"";
  if (obj.fullscreen==1) {
      if (procset.fullscreen1) obj.hook1 = obj.hook1 +  procset.fullscreen1; else obj.hook1 = obj.hook1 +  "/bin/sysimg/FULLSW.gif"; 
      } else {
      if (procset.fullscreen0) obj.hook1 = obj.hook1 +  procset.fullscreen0; else obj.hook1 = obj.hook1 +  "/bin/sysimg/REDIMW.gif";
      }
  obj.hook1 = obj.hook1 + "\" id=\""+cid+"_FsB\" alt=\"\" border=\"0\" onclick=\"FullScreenButton("+obj.hdc+")\" style=\"cursor: pointer;\">";
 // FullScreenButton
 // _FsB
  }			 
if (obj.hook1!="") obj.hook1='<td BACKGROUND="'+obj.cbar+'" style="text-align: right; padding-right: 48px;">'+obj.hook1+'</td>';

if (obj.titlefont=="") obj.titlefont="bold 9pt Courier New, Monospace";

var minmax;
if (isresize) {
   if (obj.winicon && procset.taskbar) {
      minmax='<img src="T.gif" width="16" height="16" id="'+cid+'_max"><img src="'+procset.win.minico+'" width="16" height="16"  id="'+cid+'_min">';
   	  } else {
   	  minmax='<img src="'+obj.minimg+'" width="16" height="16" id="'+cid+'_min"><img src="'+obj.maximg+'" width="16" height="16"  id="'+cid+'_max">';
	  } 
   } else {
   minmax='<img src="T.gif" width="16" height="16" id="'+cid+'_min"><img src="T.gif" width="16" height="16"  id="'+cid+'_max">';
   }

titlebar.innerHTML='<table id="'+cid+'_TTit" width="100%" HEIGHT="100%" CELLSPACING=0 CELLPADDING=0><tr><td width=1><img src="'+obj.lbar+'"></td>'+icoloc+'<td BACKGROUND="'+obj.cbar+'" id="'+cid+'_cap" STYLE="font: '+obj.titlefont+';color:'+titletextcolor+';">'+title+'</td>'+obj.hook1+'<td><span id="'+cid+'_btt" style="position:absolute; width:48px; height:16px; left:'+(tw-48)+'px; top:2px;">'+minmax+'<img src="'+obj.cloimg+'" width="16" height="16" id="'+cid+'_cls"></span></td></tr></table>';

/*
<span style="position:absolute; left:0px; top:0px; font:'+obj.titlefont+'; color:'+titletextcolor+'; height:20px; overflow:hidden; clip-height:16px; ">
<table width="100%" HEIGHT="100%" CELLSPACING=0 CELLPADDING=0><tr><td width=1><img src="'+obj.lbar+'"></td>'+icoloc+'<td BACKGROUND="'+obj.cbar+'" id="'+cid+'_cap" STYLE="font: '+obj.titlefont+';color:'+titletextcolor+';">'+title+'</td>'+obj.hook1+'</tr></table>
</span>
<span id="'+cid+'_btt" style="position:absolute; width:48px; height:16px; left:'+(tw-48)+'px; top:2px;">'+minmax+'<img src="'+obj.cloimg+'" width="16" height="16" id="'+cid+'_cls"></span>
';
*/

tw=(ie5c)?w-7:w-13;
th=(ie5c)?h-36:h-36;
var content=new subBox(2,24,tw,th,bgcolor,cid+'_c',radius(procset.wstyle.contradius));
content.style.borderColor=bordercolor;
content.style.borderStyle=procset.wstyle.cborstyle; //"inset";
content.style.borderWidth=procset.wstyle.cbordwid; //"2px";
if (obj.winicon) content.winicon=obj.winicon;
content.tit=obj.title;

if (obj.overflow!="") content.style.overflow=obj.overflow; else content.style.overflow="auto";
if (obj.bgimage!="") {
   					obj.bgimage="url("+obj.bgimage+")";
   					content.style.backgroundImage=obj.bgimage;
					}
if (obj.bgattach!="") content.style.backgroundAttachment=obj.bgattach;
if (obj.bgpos!="") content.style.backgroundPosition=obj.bgpos;
if (obj.bgrep!="") content.style.backgroundRepeat=obj.bgrep;

content.style.padding=procset.wstyle.contpadding; //"0px 2px 0px 4px";
content.style.font=fontstyleset;
content.style.color=textcolor;
if(ie5)content.style.scrollbarBaseColor=scrollcolor;

if (obj.menu) {
   var ttext='<TABLE WIDTH="100%" HEIGHT="100%" CELLSPACING=0 CELLPADDING=0 BORDER=0>';
   ttext+='<TR height="'+menuset[0].ysize+'"><TD BGCOLOR="'+menuset[0].upcolor+'"';
   if (mnustyle.upback) ttext+=' BACKGROUND="'+menuset[0].upback+'"';
   ttext+=">";
  
   ttext+='<DIV ID="'+cid+'_menuy" STYLE="left:0px;top:0px; width:100%; height:'+menuset[0].ysize+'px; background-color:'+menuset[0].upcolor+';';
   if (menuset[0].upbord) ttext+="border: "+menuset[0].upbord+";";
   if (menuset[0].upback) ttext+="background-imgae: url("+menuset[0].upback+");";
   ttext+="\">&nbsp;</DIV>";
   ttext+="</TD></TR><tr><td><DIV id=\"";
   ttext+=cid+"_cI\"";
   
   ttext+=" STYLE=\"left:0px; top:2px; width:100%; height:100%;";
   ttext+="font: "+fontstyleset+";";
   ttext+="color: "+textcolor+";";
   if (obj.overflow!="") ttext+="overflow: "+obj.overflow+";"; else ttext+="overflow:auto;";
   content.style.overflow='hidden';
   ttext+="\">"+text+"</DIV></TD></TR></TABLE>";
   text=ttext;
   }

content.innerHTML=text;
outerdiv.appendChild(titlebar);
outerdiv.appendChild(content);
outerdiv.appendChild(rdiv);
document.body.appendChild(shadow);
document.body.appendChild(outerdiv);
 
if (obj.menu) buildmenu(cid+'_menuy',cid+'_cI',obj.menu);

if (obj.winicon) {
   
   var icom=document.getElementById('Div'+cid+'_Icon');
   icom.own=outerdiv;
   icom.tit=titlebar;
   icom.out=outerdiv;
   icom.cnd=content;
   if (obj.icomenu) {
   	  icom.menu = new Array();
   	  icom.menu = icom.menu.concat(procset.winmnu);
	  icom.menu = icom.menu.concat(obj.icomenu);
	  } else {icom.menu=procset.winmnu;}
	  
   icom.onclick=function () {
   						 var x,y;
   	  		 			 x=parseInt(this.own.style.left)+4;
						 y=parseInt(this.own.style.top)+3;
						 y+=parseInt(this.out.style.borderWidth);
						 y+=parseInt(this.tit.style.height);
						 y+=parseInt(this.cnd.style.borderWidth);
						 x+=parseInt(this.out.style.borderWidth);
						 x+=parseInt(this.cnd.style.borderWidth);
						 
						 domenu(this.menu,null,x,y);
					     } 

	//addsmenuto('Div'+cid+'_Icon',tw0,procset.winmnu,0,-mnustyle.ysize);
   } 
   
if(!showonstart)hidebox(cid);
var IDS=new Array();
IDS[0]=document.getElementById(cid+'_b');
IDS[1]=document.getElementById(cid+'_t');
IDS[2]=document.getElementById(cid+'_c');
IDS[2].activec = titlecolor;
IDS[2].inactivec = inattivo;
IDS[3]=document.getElementById(cid+'_s');
IDS[4]=document.getElementById(cid+'_rs');
IDS[5]=document.getElementById(cid+'_btt');
IDS[6]=document.getElementById(cid+'_min');
IDS[7]=document.getElementById(cid+'_max');
IDS[8]=document.getElementById(cid+'_cls');
if (obj.noclose) IDS[8].style.visibility='hidden';
IDS[9]=cid;
IDS[10]=h;
this.IDb=IDS[0]; this.IDb.IDS=IDS;
this.IDt=IDS[1]; this.IDt.IDS=IDS;
this.IDc=IDS[2]; this.IDc.IDS=IDS;
this.IDs=IDS[3]; this.IDs.IDS=IDS;
this.IDrs=IDS[4]; this.IDrs.IDS=IDS;
this.IDbtt=IDS[5]; this.IDbtt.IDS=IDS;
this.IDmin=IDS[6]; this.IDmin.IDS=IDS;
this.IDmax=IDS[7]; this.IDmax.IDS=IDS;
this.IDcls=IDS[8]; this.IDcls.IDS=IDS;
this.IDb.activecolor=titlecolor;
this.IDb.inactivecolor=inattivo;
if(oldac!=null)oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
IDS[2].th=this.IDb;
oldac=this.IDb;
this.IDcls.onclick=new Function("hidebox('"+cid+"');");
if(isresize){
this.IDmin.onclick=minimize;
this.IDmin.hdc=obj.hdc;
if (obj.winicon) this.IDmin.winicon=obj.winicon;
this.IDmax.onclick=restore;
this.IDrs.onmousedown=startRS;
this.IDrs.onmouseup=new Function("currRS=null");
}
this.IDb.onmousedown=function(){
   if(oldac!=null){
   oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
   }
   if(ns6)this.IDS[2].style.overflow='auto';
   oldac=this;

   this.IDS[1].style.backgroundColor=this.activecolor;
   this.IDS[3].style.zIndex=++zdx;
   this.style.zIndex=++zdx;
   activeurl=IDS[2].id;
   }
if(isdrag){
this.IDt.onmousedown=grab_id;
this.IDt.onmouseup=stopdrag;
}
}else{
if(oldOK){
var ctr=new Date();
ctr=ctr.getTime();
var win=window.open("" , "rnd"+ctr , "status=no,menubar=no,width="+w+",height="+h+",resizable=yes,scrollbars=yes");
var t='<html><head><title>'+title+'</title></head><body bgcolor="'+bgcolor+'"><font style="font:'+fontstyleset+'; color:'+textcolor+'">'+text+'</font></body></html>';
win.document.write(t);
win.document.close();
}}}

if (obj.fullscreen==2) EnterFullScreen(obj.hdc);
return outerdiv;
}


if(ns6)setInterval('movepopup()',40);

if(w3c){
document.onmousemove=trackmouse;
document.onmouseup=new Function("currRS=null");
}
 
function download(fil) {
		 goover();
		 uri="download.php?"+fil;
		 var win=window.open(uri , uri , "status=no,menubar=no,width=320,height=240,resizable=yes,scrollbars=yes");
		 }
 
 
function setwinhook(id,obj) {
	var nmi = 'Div'+obj.hdc+'_'+id;
	if (obj.ico!='') {
		var v = document.getElementById(nmi);
		if (v) v.src=obj.ico;
		}
	if (obj.lnk!='') {
		var v = document.getElementById(nmi+'_lnk');
		if (v) v.href=obj.href;
		}
	}

 
function openwin(obj,inner){
goover();
var x0=4,y0=4;

numwin=numwin+1;
	if (nextexecuteceter==1) {
	   obj.cenx=1;
	   obj.ceny=1;
	   nextexecuteceter=0;
	   }
	
	if (obj.kernel=="test") {
	   if (obj.cmd=="show") showobj(obj.subject);
	   if (obj.cmd=="hide") hideobj(obj.subject);
	   if (obj.cmd=="") goover();
	   return;
	   }
	
	if (obj.dde) AddDDE(obj.dde,numwin);
  
	if (obj.kernel=="baloon") baloon(obj,inner);
	if (obj.kernel=="gadget") newgadget(obj,inner); 
	if (obj.kernel=="procset") {
	   procset=inner;
	   var e;
	   try {
	   	   procset=eval('('+procset+')');
		   } catch(e) {
		   	 localerro('RUN-Time error','Procset JSON Error\n<br>'+e);
		   	 }
	   if (obj.next!="") shellexecute(obj.next);
        
	   return;
	   }
	if (obj.kernel=="") {
	  if (obj.cenx==0) x0=16*(numwin % 8);
	  if (obj.ceny==0) y0=16*(numwin % 16);
	  if (obj.cenx==1) x0=(document.body.clientWidth /2) - (obj.width/2);
	  if (obj.ceny==1) y0=(document.body.clientHeight /2) - (obj.height/2);
	  if (obj.cenx==2) x0=(document.body.clientWidth - obj.width -1);
	  if (obj.ceny==2) y0=(document.body.clientHeight - obj.height -1);
	  if (obj.cenx==3) x0=(obj.x0/640)*document.body.clientWidth;
	  if (obj.ceny==3) y0=(obj.y0/480)*document.body.clientHeight;
	  if (obj.resize!=0) obj.resize=true; else obj.resize=false; 
	  obj.hdc=numwin;
	  new popUp(x0, y0, obj.width,obj.height, "Div"+numwin, inner, obj.bgcolor, obj.textcolor, obj.fontstyleset, obj.title, obj.titlecolor,obj.titletextcolor, obj.bordercolor, obj.scrollcolor, obj.shadow, true, true, obj.resize, true, false,obj);
	  activeurl='Div'+numwin+'_c';
	  if (obj.history && obj.qry) addhistory(numwin,obj.qry);
	  var tmp=document.getElementById(activeurl);
	  if (obj.qry) tmp.qry=obj.qry;
    if (obj.qrya) tmp.qrya=obj.qrya;
	} //""
	
	
	if (obj.setstat) if (obj.setstat!="") setstat(obj.setstat);
	//if (obj.qry) document.getElementById("Div"+numwin).Dataurl=obj.qry;
}

function localerro(title,text,rsz) {
		 goover();
		 var obj = defaultform(title);
		 text='<table width="100%" height="100%"><tr><td><center><font style="size: 9pt;">'+text+'</font></center></td></tr></table>';
		 if (rsz) obj.noresize=0;
		 openwin(obj,text);
}

function settile(hdc,title) {
	 	x=document.getElementById("Div"+hdc+"_cap");
		x.innerHTML=title;
		EVECall('w'+hdc,'ontitle');
		 }

function targetnew(uri){
goover();
window.open(uri , "nuovo" , "titlebar=yes,menubar=yes,fullscreen=yes,resizable=yes,scrollbars=yes");
setstat(procset.stat.normal);
}

function parseres(rsps,typ) {
	//alert(typ);
	setstat(procset.stat.normal);
		
   var rsp = rsps.split(/\<junk\>/);
   rsps="";
   var le=rsp.length;
   
   var par=rsp[0];
   var html=rsp[le-1];
   var scri="";

	if (le==3) scri=rsp[1];
   	var e;
	try {
		par = eval("(" + par + ")");
		} catch(e) {
		if (par=='' || par==null || par=="undefined") return;
		  localerro('Run-Time Error','Server JSON Response Error<br>'+par);
		  }

  	if (!par.ver || par.ver == 'undefined') {
	   			 localerro('Run-Time Error','Invalid JSON Structure');
				 return;
	   			 }
	
	if (par.hdc=="stderr") {
	   			localerro(par.title,html);
	   			return;
	   			}

	if (par.hdc=="reboot") {
	   			top.document.location.reload();
	   			return;
	   			}
				
	if (par.hdc=="syserr") {
	   			var ihtml='<html><head><title>WEBGUI Fatal Error <?=$num ?></title></head>';
				ihtml+='<body><div STYLE="left:0px; top:0px; width:100%; height:100%; position:absolute; z-index: 3000; background-color: #000000; font-family: Courier New,Monospace; font-size: 9pt; color:#ff0000; border: #ff0000 4px solid;">';
				ihtml+='<center>'+par.title+'</center>';
				ihtml+='<hr size="1" width="100%" noshade color="#ff0000">';
				ihtml+=par.cap+'<hr size="1" width="100%" noshade color="#ff0000">';
				ihtml+='</div></body></html>';
				top.document.body.innerHTML=ihtml;				
	   			return;
	   			}
	
	if (!par.nonwin) { 
	if (typ==0) {openwin(par,html);} else {
	   				
	   				 waitfl=0;
					 par.hdc++;
					 var x=document.getElementById("Div"+par.hdc+"_cI");
					 if (!x) x=document.getElementById("Div"+par.hdc+"_c");
					 lastreq=0;
					 if (x) x.innerHTML=html;
					 
					 if (par.title!="") {
					 	x=document.getElementById("Div"+par.hdc+"_cap");
						if (x) x.innerHTML=par.title;
					 	}
					 x = document.getElementById('Div'+par.hdc+'_c');
					 if (x) if (x.history && par.url) {
					 	var le=x.history.length;
						x.history[le]=par.url;
					 	}
					 mouseturn(0);
	   				 }
			}
	
	if (par.hdc=='desktop') document.body.innerHTML=html;
			
	if (par.excmd) pharsecmd(par);
	html="";
	if (par.next!="") {
    shellexecute(par.next);
    } else {
     if (procset.shellexecute) {
        var re0=procset.shellexecute;
        procset.shellexecute=null;
        shellexecute(re0);
        }
      }
}

function pharsecmd(obj) {
		 
	var list = obj.command;
	
	var cx = list.length;
	
		for (var ax=0;ax<cx;ax++) execcmd(list[ax]);
	
	}
	
function execcmd(obj) {
	var v;
	
	if (obj.cmd=="show") showobj(obj.objid);
	if (obj.cmd=="hide") hideobj(obj.objid);
	
	if (obj.cmd=="tophref") {
		v="top.location.href='"+decodeURIComponent(obj.content)+"';";
		if (obj.msg!='') {
			message(obj.msg);
			setTimeout(v,3000);
			} else {
			setTimeout(v,500);
			}
		}
		
	if (obj.cmd=="goover") goover();
	if (obj.cmd=="html") {
	   v = document.getElementById(obj.objid);
	   if (v) v.innerHTML=obj.content;
	   }
	   
	if (obj.cmd=="style") {
	   v = document.getElementById(obj.objid);
	   if (v) v.setAttribute('style',obj.content);
	   }
	
	if (obj.cmd=="new") {
	   v=document.createElement('div');
	   v.setAttribute('id',obj.objid);
	   if (obj.style) v.setAttribute('style',obj.style);
	   if (obj.content) v.innerHTML=obj.content;
	   document.body.appendChild(v);
	   }

	if (obj.cmd=="del") {
	   v = document.getElementById(obj.objid);
	   if (v) {
	   	  	  v.innerHTML='';
			  document.body.removeChild(v);
			  }
	   }

   if (obj.cmd=="nextnext") procset.shellexecute=obj.content;
	 if (obj.cmd=="procset") procset=obj.procset;
	 if (obj.cmd=="mnustyle") mnustyle=obj.content;
	 if (obj.cmd=="execute") shellexecute(obj.content);
	 if (obj.cmd=="query") shellquery(obj.hdc,obj.content);
	 if (obj.cmd=="submit") shellsubmit(obj.hdc);
	 if (obj.cmd=="winclose") closewindow(obj.hdc);
	 if (obj.cmd=="reboot") top.location.href="/";
	 if (obj.cmd=="stat") setstat(obj.content);
	 if (obj.cmd=="regmnu") regmenu(obj.content);
	 if (obj.cmd=="unregmnu") unregmnu(obj.content);
	 if (obj.cmd=="caption") setcaption(obj.hdc,obj.objid,obj.content);
	 if (obj.cmd=="setkey") addhotkey(obj.ctrl,obj.alt,obj.shift,och.key,shellexecute(obj.content));
	 if (obj.cmd=="setkeyex") addhotkey(obj.ctrl,obj.alt,obj.shift,och.key,eval(obj.content));
 	 if (obj.cmd=="delkey") delhotkey(obj.ctrl,obj.alt,obj.shift,och.key);
	 if (obj.cmd=="remoterun") eval(obj.content);
	 if (obj.cmd=="sound") Sound(obj.content);
	 if (obj.cmd=="exception") if (obj.guru==1) GuruMeditation(obj.eip); else ExceptionTrap(obj.eip);
	 if (obj.cmd=="msgbox") MSGBOX(obj.text,obj.cla);
	 if (obj.cmd=="eveadd") EveAddArr(obj.content);
	 if (obj.cmd=="changedesktop") ChangeDesktop(obj.content,obj.message);
	 if (obj.cmd=="uevent") EVECall(obj.content.hdc,obj.content.name,obj.content.param);
	 if (obj.cmd=="adddde") AddDDE(obj.name,obj.hdc);
	 if (obj.cmd=="calldde") CallDDE(obj.name,obj.url);
	 if (obj.cmd=="deldde") DelDDE(obj.name);
	 if (obj.cmd=="messagex") message(obj.content,obj.w,obj.h,obj.bgcolor,obj.notim);
	 if (obj.cmd=="sethook") setwinhook(obj.objid,obj);
	 if (obj.cmd=="lockit") lockit();
	 if (obj.cmd=="modal") lockit(obj.hdc);
	 if (obj.cmd=="unlockit") unlockit();
	 if (obj.cmd=="dialoglink") dialoglink(obj.hdd,obj.from);
	 if (obj.cmd=="dialogprop") dialogprop(obj.hdd,obj.from,obj.submit,obj.exec,obj.post);
	 if (obj.cmd=="dialogdone") dialogdone(obj.hdd,obj.result);
	 if (obj.cmd=="loaddll") loaddll(obj.dll);
	 if (obj.cmd=="setjava") SetJava(obj.hdc,obj);
	 if (obj.cmd=="cleargui") ClearGui();
	 
	 if (obj.cmd=="addsub") {
                           v=1;
                           try {
	                             eval('addSub("'+obj.name+'",'+obj.content+');');
	                             } catch(e) {
                               localerro('RUN-TIME Error',e+"\nAddSub "+obj.name+"\n"+obj.content);
                               v=0;
                               }
                          if (obj.run==1) try {
	                             if (v==1) SubS[obj.name]();
	                             } catch(e) {
                               localerro('RUN-TIME Error',e+"\nDynamicSubAutorun "+obj.name);
                               }
                          }
	 
	 if (obj.cmd=="delsub") delSub(obj.name);
	  
	 
	 if (obj.cmd=="topwin") {
	 	v=document.getElementById('Div'+obj.hdc+'_s');
		if (v) v.style.zIndex=6000+zdx++;
		v=document.getElementById('Div'+obj.hdc+'_b');
		if (v) {
		   v.style.zIndex=6000+zdx++;
		   if (obj.alpha) alpha(v,obj.alpha);
		   }
		
	 	}
	 if (obj.cmd=="alpha") {
	    v = document.getElementById(obj.objid);
		if (v) alpha(v,obj.content);
	 	}
	 
}

//<!-- WEBGUI DOM --> //

function LocalMenuExec(hdc,cmd) {
		 var v=document.getElementById('Div'+hdc+'_c');
		 if (!v) {
		 	localerro('RUN-TIME Error',"Event "+cmd+" not found in form "+hdc);
			return;}
		 if (cmd.indexOf('(')==-1) v[cmd](); else eval('v.'+cmd);
		 }

function GetObj(hdc,id) {
		 var v = document.getElementById('Div'+hdc+'_'+id);
		 if (!v) localerro('RUN-TIME Error',"Object Id not found: GetObject("+id+")");
		 return v;
		 }		 
		 
function GetIObj(hdc,id) {
		 var v = document.getElementById('Div'+hdc+'_'+id);
		 return v;
		 }	
		 
function GetObject(hdc,iid) {
		 var id='Div'+hdc+'_'+iid;
		 var v;
		 v=document.getElementById(id);
		 if (!v) localerro('RUN-TIME Error',"Object Id not found: GetObject("+bx+")");
		 return v;
		 }
		 
function RemoveObj(hdc,id) {
		 var v;
		 v = document.getElementById('Div'+hdc+'_cI');
		 if (!v) v=document.getElementById('Div'+hdc+'_c');
		 
		 var v1 = document.getElementById('Div'+hdc+'_'+id);
		 v.removeChild(v1);
		 
		 }
		 
function CreateObj(hdc,id,typ,x,y,w,h,style,appendto) {
		 var v;
		 v = document.getElementById('Div'+hdc+'_cI');
		 if (v) if (divbug) y=parseInt(y)+parseInt(menuset[0].ysize);
		 if (!v) v=document.getElementById('Div'+hdc+'_c');
		 if (!v) localerro('RUN-TIME Error',"Window not found: "+hdc);
		 
		 var v1=document.createElement(typ);
		 id='Div'+hdc+'_'+id;
		 
		 v1.setAttribute('id',id);
		 if (style) if (style!="") v1.setAttribute('style',style);  
		 v1.style.position='absolute';
		 v1.style.left=x+'px';
		 v1.style.top=y+'px';
		 v1.style.width=w+'px';
		 v1.style.height=h+'px';
		 v1.style.visibility='visible';
		 v1.style.padding='0px 0px 0px 0px';
		 
		 if (!appendto) v.appendChild(v1); else appendto.appendChild(v1);
		 return v1;
		 }
		 
function getFormThis(hdc) {
		 var v = document.getElementById('Div'+hdc+'_cI');
		 if (!v) v = document.getElementById('Div'+hdc+'_c');
		 if (!v) localerro('RUN-TIME Error',"Form not fount: "+hdc);
		 return v;
		 }
		 
function getObjectById(ax,bx) {
		 var v;
		 if (!bx) v=document.getElementById(bx); else {
		 	v = document.getElementById('Div'+ax+'_cI');
			if (!v) v=document.getElementById('Div'+ax+'_c');
			}
		 if (!v.id) localerro('RUN-TIME Error',"Object Id not found: GetObjectById("+ax+","+bx+")");
		 return v;			
		 }

function SetJava(hdc,Obj) {
		 
		 var v = document.getElementById("Div"+hdc+"_c");
		 
		 if (!v) { localerro('RUN-TIME Error',"Can't set data/events For Window "+hdc); return ;}
		 
		/* try {*/
		 	 var jObj=eval("("+URLDecode(Obj.content)+")");
			/* } catch(err) {
			   localerro('RUN-TIME Error',"JSON Syntax Error in SetJava For Window "+hdc+":<br></center><pre>"+URLDecode(Obj.content)+"</pre>&nbsp;<center>",1); 
			   return ;
			   }*/
		
	 	 for (var key in jObj) { v[key]=jObj[key]; } 
		 
		 if (v.On_Load) {
		 	if (!v.On_Load_Done) v.On_Load_Done=1;
			v.On_Load();
		 	}
			 
}

function setcaption(hdc,objid,cap) {
		 var v = document.getElementById(objid+'__'+hdc);
		 if (v) v.innerHTML=cap;
		 }

function regmnu(list) {
	var mnu = list.split(" ");
	var t0;
	var cx = mnu.lenght;
		for (var ax=0;ax<cx;ax++) {
		t0='!'+mnu[ax]+'!';
		if (mnuall.indexOf(t0)==-1) mnuall+=t0;
		}
	}

function unregmnu(list) {

		 var mnu=list.split(" ");
		 var cx=mnu.length;
		 
		 	 for (var ax=0;ax<cx;ax++) { mnuall=eval('mnuall.replace(/!'+mnu[ax]+'!/g, "")') ;}
	}

//	   <!--	#####]#]#]#]#]#]#]#]#] -->
function handleHttpResponseQRY() {handleHttpResponse(1);}
function handleHttpResponseNEW() {handleHttpResponse(0);}

function handleHttpResponse(typ) {
  if (http.readyState == 4) {
    goover();
  	if (http.status!=200) {
	   
	   //alert(typ);
	    if (http.statusText!='') localerro('Errore di Richiesta', 'Il server ha risposto con il messaggio:<br>'+http.statusText);
	   } else {
  	   parseres(http.responseText,typ);
	   }
	  	
	mouseturn(0);
	waitfl=0;
  }
 }

function shellchange(hdc,file) {

  closewindow(hdc);

  shellexecute(file);
  }

function shellexecute(fil,parex) {
goover();


if (fil.indexOf('http://')==0) {
   targetnew(fil);
   } else {
  if (waitfl==1) {
  		alert("Caricamento in corso...\nLa velocità di risposta dipende dalla velocità di connessione!\nPer attivare le icone basta un click.");
		waitfl=0;
		return;
		}
  if (!parex) var parex=''; else parex='&'+parex;
  http.open("GET", "run.php?n="+numwin+parex+"&hdc="+numwin+"&f="+encodeURIComponent(fil), true);
  http.onreadystatechange = handleHttpResponseNEW;
  mouseturn(1);
  waitfl=2;
  http.send(null);
  }
  setstat(procset.stat.load);
  
}

function submitdata(hdc,scp,dati) {
goover();
setstat(procset.stat.load);

		 hdc1=hdc-1;
		 var post="hdc="+hdc1;
			
			 for (var tmp in dati) { post=post+"&"+tmp+"=" + encodeURIComponent(dati[tmp]); }
 	 		 
		var req="run.php?f="+encodeURIComponent(scp)+"&hdc="+hdc1+"&n="+hdc1;
		
		http.open("POST", req, true);
  		http.onreadystatechange = handleHttpResponseQRY;
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", post.length);
  		mouseturn(1);
  		waitfl=1;
  		http.send(post);
		loading(hdc); 
}

function shellsubmit(hdc) {
goover();
setstat(procset.stat.load);

		 if (lastreq!=0) {
		// 	alert("Richiesta in corso...\nLa velocita' di risposta dipende dalla velocita' di connessione!");
			lastreq=0;
			return;
		 	}
		 var x=document.getElementById("Form"+hdc);
		 if (!x) localerro('RUN-TIME Error','Form not found '+hdc);
		 var hdc1=hdc-1;
		 var prev=null;
		 var scp;
		 if (x.action) scp=x.action;
		
		 var post="hdc="+hdc1;
		
			 	 for (var i=0;i<x.length;i++)
  			 {
			 
			 x.elements[i].value=x.elements[i].value.replace(/\n/g,"\t");
			 
			 var xly = x.elements[i].value;
			 var xld = x.elements[i].id+'_g';
			if (x.elements[i].type=='checkbox') {
        if (x.elements[i].checked) xly=x.elements[i].value; else xly='';
        }
			
          xld = document.getElementById(xld);
				 if (xld) xly=xld.innerHTML;

			 if (x.elements[i].name=='wait') prev=x.elements[i].value; else post=post+"&"+x.elements[i].name+"="+encodeURIComponent(xly);
			 if (x.elements[i].name=='action') scp=x.elements[i].value;
			 }
 	 		 
		var req="run.php?f="+encodeURIComponent(scp)+"&hdc="+hdc1+"&n="+hdc1;
		
		http.open("POST", req, true);
  		http.onreadystatechange = handleHttpResponseQRY;
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", post.length);
		//http.setRequestHeader("Connection", "close");
  		mouseturn(1);
  		waitfl=1;
  		http.send(post);
		if (prev) {
				x=document.getElementById("Div"+hdc+"_c");
				x.innerHTML=prev;
				} else { loading(hdc); }
		
}

function shellquery(hdc,phpe,pars,prev) {
addhistory(hdc,phpe);
goover();
setstat(procset.stat.load);

		 if (lastreq!=0) {
		 	alert("Richiesta in corso...\nLa velocita' di risposta dipende dalla velocita' di connessione!");
			lastreq=0;
			return;
		 	}

		 var hdc1=hdc-1;
		 if (pars!='') pars="&"+pars;
		 var req="run.php?f="+encodeURIComponent(phpe)+"&hdc="+hdc1+"&n="+hdc1+pars;
	 			
		lastreq=hdc;

		http.open("GET", req, true);
  		http.onreadystatechange = handleHttpResponseQRY;
  		mouseturn(1);
  		waitfl=1;
  		http.send(null);
		if (prev) {
		   	    x=document.getElementById("Div"+hdc+"_cI");
				if (!x) x=document.getElementById("Div"+hdc+"_c");
				x.innerHTML=prev;
				} else { loading(hdc); }
		
}


function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function chimg(id,img,lpstr) {
		 document.getElementById(id).src=img;
		 if (lpstr=='') lpstr='&nbsp;';
		 lpstr+='|';
		 lpstr=lpstr.split('|');
		 var txt=document.getElementById(id+'_txt');
		 if (txt != undefined) {
		 if (lpstr[1]=='') {
		 	txt.innerHTML=lpstr[0];
			} else {
			lpstr='<a href="javascript:shellexecute(\''+lpstr[1]+'\');" target="a" style="text-decoration: none;">'+lpstr[0]+'</a>';
		 	txt.innerHTML=lpstr;
			}
		   }
		 }
function fullfoto(id) {
		 targetnew(document.getElementById(id).src);
}

function stopblink(ob) {
var x=document.getElementById(ob);
x.style.backgroundImage="none";
x.style.borderStyle="none";
}

function shellicon(uri,ob) {
shellexecute(uri);
stopblink(ob);
}

function baloon(obj,html) {
	
	var w=obj.width;
	var h=obj.height;
    var x=document.body.clientWidth-w;
	var y=0; //document.body.clientHeight-h;
	if (!html) html=obj.content;

	numwin++;
	var id='Div'+numwin;
	Windows[id]=new Array('',id);
	var v=document.createElement('div');
	v.setAttribute('id',id);
	if (iexbug) {
	   v.setAttribute('style','overflow: hidden; font:'+obj.font+';');
	   x-=16;
	   } else {
	   v.setAttribute('style','-moz-border-radius: 8px 0px 8px 8px; -webkit-border-radius: 8px 0px 8px 8px; border-radius: 8px 0px 8px 8px; overflow: hidden; border: 1px solid #000000; font:'+obj.font+';');
	   x-=16;
	   }
	v.style.border='1px solid #000000';
	v.style.position='absolute';
	v.style.left=x+'px';
	v.style.top=y+'px';
	v.style.width=w+'px';
	v.style.height=h+'px';
	v.style.backgroundColor=obj.bgcolor;
	v.style.visibility='visible';
	v.style.padding='4px 4px 4px 4px';
	v.style.zIndex=2000+zdx++;
	var txt='';
	if (obj.title!="") txt='<a href="javascript:removebaloon('+numwin+');" target="a" STYLE="text-decoration: none;"><img src="'+obj.xicon+'" border=0 alt="" width=15 height=15></a>&nbsp;<u>'+obj.title+'</u><br>';
	if (obj.icon!="") txt='<table width="100%" height="100%" cellspacing=0 cellpadding=0><tr><td width=32 valign=top><img src="'+obj.icon+'" alt=""></td><td STYLE="font:'+obj.font+';">'+txt+html+'</td></tr></table>'; else txt+=html;
	v.innerHTML=txt;
	if (procset.baloon.alpha) alpha(v,procset.baloon.alpha);
	document.body.appendChild(v);
	if (obj.maxtim!="") timo2=setTimeout("removebaloon("+numwin+")",obj.maxtim*1000);
	if (obj.icostat!="") setstat(obj.icostat); else setstat(procset.stat.info);
	}

function newgadget(obj,html) {

	var x=obj.x0;
	var y=obj.y0;
	var txt='';
	
	if (obj.cenx==1) x=document.body.clientWidth-obj.width-x;
	if (obj.ceny==1) y=document.body.clientHeight-obj.height-y;
	
	numwin++;
	var id='DivG'+numwin;
	
	var v=document.createElement('div');
	v.setAttribute('id',id);
	if (iexbug) {
	   v.setAttribute('style','overflow: hidden; font:'+obj.font+';');
	   } else {
	   v.setAttribute('style','-moz-border-radius: 8px 8px 8px 8px; -webkit-border-radius: 8px 8px 8px 8px; border-radius: 8px 8px 8px 8px; overflow: hidden; border: 1px solid #000000; font:'+obj.font+';');
	   }
	v.style.border='1px solid #000000';
	v.style.position='absolute';
	v.style.left=x+'px';
	v.style.top=y+'px';
	v.style.width=obj.width+'px';
	v.style.height=obj.height+'px';
	v.style.backgroundColor=obj.bgcolor;
	v.style.visibility='visible';
	v.style.padding='4px 4px 4px 4px';

	if (obj.title!="") txt='<a href="javascript:removegadget('+numwin+');" target="a" STYLE="text-decoration: none;"><img src="'+obj.xicon+'" border=0 alt="" width=15 height=15></a>&nbsp;<u>'+obj.title+'</u><br>';
	txt+='<DIV ID="Div'+numwin+'" STYLE="width:100%; height:100%; position: relative; overflow: auto;font:'+obj.font+';">'+html+'</div>';
	v.innerHTML=txt;
  if (obj.alfa) alpha(v,obj.alfa);
  if (obj.zo==1) v.style.zIndex=3000; 
	document.body.appendChild(v);
	}
	
function setstat(img) {
		 var v=top.document.getElementById('ajaxstat');
		 if (v) v.src=img;
		 }
	
function removegadget(hdc) {
		var v=document.getElementById('DivG'+hdc);
		v.innerHTML='';
		document.body.removeChild(v);
	}	
	
function removebaloon(hdc) {
		if (hdc==blorem) return;
		blorem=hdc;
		var v=document.getElementById('Div'+hdc);
		v.innerHTML='';
		document.body.removeChild(v);
		setstat(procset.stat.normal);
	}
	
function stopallblink(maxb) {
var ax;
var maxb=blinks.length;
	 for (ax=0;ax<maxb;ax++) {
	 stopblink(blinks[ax]);
	 }
}

function showobj(objid) {
	var v=document.getElementById(objid);
	v.style.visibility='visible';
	
	var f=mnuall.indexOf('!'+objid+'!');
	if (f==-1) mnuall +='!'+objid+'!';
	}

function hideobj(objid) {
	var v=document.getElementById(objid);
	if (!v) return;
	v.style.visibility='hidden';
	mnuall=eval('mnuall.replace(/!'+objid+'!/g, "")');
	}

function gooverobj() {
	if (!mnuall) return;
	if (mnuall=="") return;
	mnuall=mnuall.replace(/!!/g,"!");
	var arr=mnuall.split("!");
	var cx=arr.length;
	var v;
		for (var ax=0;ax<cx;ax++) {
			if (arr[ax]!='') {
			   v = document.getElementById(arr[ax]);
			   if (v) v.style.visibility='hidden';
			   }
			}
	
	mnuall= "";
	}
	
// <!-- MENU' AREA --> //


function mnust(ob,st) {
		 ob.style.backgroundColor=mnustyle.color[st].pap;
		 ob.style.color=mnustyle.color[st].ink;
		 var img;
		 if (mnustyle.color[st].ico) ob.style.backgroundImage='url('+mnustyle.color[st].ico+')'; else ob.style.backgroundImage='';
		 var v=ob.id+'_txt';
		 v=document.getElementById(v);
		 if (v) v.style.color=mnustyle.color[st].ink;
		 if (mnustyle.color[st].style) {
		 	var le=mnustyle.color[st].style.length;
			for (var ax=0;ax<le;ax++) {
				eval('ob.style.'+mnustyle.color[st].style[ax].p+'="'+mnustyle.color[st].style[ax].v+'";');
				}
		 	}
		 }	
function removemnuchild(mn) {
		 if (!mn.child) return;
		 var le=mn.child.length;
		 for (var ax=0;ax<le;ax++) {
		     if (mn.child[ax].child) removemnuchild(mn.child[ax]);
		 	 mnutarget.removeChild(mn.child[ax]);
			 mn.child[ax]=null;
		 	 }
		 mn.child=null;
		 mn.flg=0;
		 }
	
function removenone(th) {
		 var fat;
		 var child;
		 if (th.father) fat=th.father; else fat=menutree;
		 child=fat.child;
		 var len=child.length;
		 for (var ax=0;ax<len;ax++) {
		 	 if (child[ax].child) removemnuchild(child[ax]);
		 	 } 
		 }
	
function mnucell(item,fat) {
		 var v = document.createElement('div');
		 v.id = "EptoMenu"+cntmnu++;
		 v.style.fontFamily=mnustyle.font;
		 v.style.fontSize=mnustyle.fsize;
		 v.style.height=mnustyle.ysize+'px';
		 v.style.width=mnustyle.width+'px';
		 v.style.visibility='visible';
		 v.style.position='absolute';

		 if (isNaN(item.left)) item.left=0;
		 
		 v.style.left=item.left+'px';
		 if (item.top) v.style.top=item.top+'px'; else v.style.top='0px';
		 
		 v.father=fat;
		 v.style.border=mnustyle.ybord;
		 v.style.overflow='hidden';
		 v.style.zIndex=++zdx;
		 v.style.padding='0px 0px 0px 0px';
		 var inner='<table width="100%" height="100%" CELLSPACING=0 CELLPADDING=0 border=0><tr>';
		 var img;
		 if (item.ico) img=item.ico; else img=mnustyle.noico; 
		 inner+='<td width="'+mnustyle.icosize+'"><img src="'+img+'" alt="" border=0 width="'+mnustyle.icosize+'" height="'+mnustyle.icosize+'"></td>';
		 if (item.cap=="") {
		 				inner='<table width="100%" height="100%" CELLSPACING=0 CELLPADDING=0 border=0><tr>';
		 				inner+='<td><img src="'+mnustyle.mnusep+'" width="'+mnustyle.width+'" height="'+mnustyle.ysize+'"></td>';
						} else inner+='<td id="'+v.id+'_txt" STYLE="font-family:'+mnustyle.font+'; font-size:'+mnustyle.fsize+'; color:'+mnustyle.color[0].ink+'">'+item.cap+'</td>';
						
		 v.onmouseover=function () {
		 						if (this.father!=null) this.father.flg=1;
								if (this.flg) if (this.child) removemnuchild(this); 
		 						if (!item.blo) mnust(this,1);
								curmenu=this.id;	
								}
		 v.onmouseout=function () { 
		 					   if (!item.blo) mnust(this,0); 
							   curmenu='';
							   setTimeout('allmnuout()',mnustyle.maxtim);
							   }
		  				
		 if (item.hotk) inner+='<td valign=TOP width="1" STYLE="font-family:'+mnustyle.hotfont+'; font-size:'+mnustyle.hotfsize+'; color:'+mnustyle.hotcolor+'">'+item.hotk+'&nbsp;</td>';
	 
		 if (item.item) {
		 	item.item.left=parseInt(item.left)+parseInt(mnustyle.width);
			item.item.top=parseInt(item.top);
			
			v.item=item.item;
			inner+='<td width=16><img src="'+mnustyle.submnu+'" width=16 height=16></td>';
			
			if (!item.blo) {
			
			v.onclick=function() {
								 removenone(this); 
								 this.child = showmenu(this.item,v); 
								 }
					}
					
			} else {
			v.link=item.lnk;
			if (!item.blo) {
			v.onclick=function() {
								 goover();
								 //try {eval(this.link);} catch(e) {localerro('RUN-TIME Error in men&ugrave;','Function: '+this.link+'<br>'+e);}
								 eval(this.link); 
								 }
							}
			}
		 	inner+='</tr></table>';
			v.innerHTML=inner;
			
			if (item.blo) mnust(v,2); else mnust(v,0);
		 mnutarget.appendChild(v);
		 return v;
		 }
	
function showmenu(item,fat,x0,y0) {
		 var le=item.length;
		 var ax;
		 var bx;
		 var child=new Array();
		 if (ie5c) bx=-1; else bx=0;
		 if (!x0) if (item.left) x0=item.left; else x0=0;
		 if (!y0) if (item.top) y0=item.top; else y0=0;
		 
		 if (!item.mnuid) item.mnuid='Mnu'+cntmnu++;
		 	for (ax=0;ax<le;ax++) {
				if (item[ax].cap) {
				   item[ax].left=x0;
				   if (!ie5c) item[ax].left++; else item[ax].left--;
				   item[ax].top=y0+(ax*(parseInt(mnustyle.ysize)+bx));
				   child[child.length]=mnucell(item[ax],fat);				   
				   }
				}
		 return child;
		 }

function StartButton(x0,idx) {
		 if (Locked) return;
		 if (!x0) x0=8;
		 if (!idx) idx=0;
		 idx='M'+idx;
		 goover();
		 if (!StartMNU[idx]) {localerro('RUN-TIME Error','Men&ugrave; non trovato'); return;}
		 mnustyle=menuset[1];
		 mnutarget=document.body;
		 menutree=new Object();
		 menutree.child=showmenu(StartMNU[idx],null,x0,0);
		 }
		 
function domenuex(mnu,objid,x0,y0) {
		 if (!x0) x0=0;
		 if (!y0) y0=0;
		 if (objid) mnutarget=document.getElementById(objid); else mnutarget=document.body;
		 menutree=new Object();
		 menutree.child=showmenu(mnu,null,x0,y0);
		 }	
		 
function goover() {
		 gooverobj();
		 if (!menutree) return;
		 if (menutree.child) removemnuchild(menutree);
		 menutree=new Object();
		 curmenu='';
		 mnutarget=document.body;
		 }

function allmnuout() { if (curmenu=='') goover(); }
		 
function mkmnux(mncnt,cont,mnux,x0,y0) {
		 var mnlyr;
		 
		 if (mncnt==null) {
		 				  mnlyr=top.document.getElementById('StartMenu');
						  if (!mnlyr) mnlyr=top.document.body;
						  } else {
						  mnlyr=document.getElementById(mncnt);
						  }
						  
		 var aplyr=document.getElementById(cont);
		 var v=document.createElement('div');
		 var objid=mncnt+'_'+cont+'_'+mnucnt++;
		 var inner='';
		 v.setAttribute('id',objid);
		 if (!ie5c) if (mnustyle.color[3].radius) v.setAttribute('style','-moz-border-radius:'+mnustyle.color[3].radius+';-webkit-border-radius:'+mnustyle.color[3].radius+';border-radius:'+mnustyle.color[3].radius+';');
	 	 v.style.border=mnustyle.xbord;
		 v.style.position='absolute'; 
		 v.style.zIndex=++zdx;
		 v.style.left=x0+'px';
		 v.style.top=y0+'px';
		 v.style.height=mnustyle.ysize+'px';
		 v.style.backgroundColor=mnustyle.color[3].pap;
		 v.style.visibility='visible';
		 v.style.padding='0px 0px 0px 0px';
		 v.style.overflow='hidden';
		 v.style.verticalAlign='middle';
		 v.style.fontFamily=mnustyle.font;
		 v.style.fontSize=mnustyle.fsize;
		 if (mnustyle.color[3].bak) v.style.backgroundImage='url('+mnustyle.color[3].bak+')';
		 if (mnux.blo) mnust(v,2); else { mnust(v,3);
		 	v.onmouseover=function () { mnust(this,4); }
		 	v.onmouseout=function () { mnust(this,3); }
			}
		 if (mnux.ico!="") inner='<img src="'+mnux.ico+'" id="'+v.id+'_ico" alt="" width="'+mnustyle.icosize+'" height="'+mnustyle.icosize+'">';
		 
		 //> x il parser
		 
		 inner+=mnux.cap;
		 inner="&nbsp;"+inner+"&nbsp;";
		 v.innerHTML=inner;
		 if (!mnux.blo) {
		 if (mnux.item) {
		 		 v.onclick=function () {
				 					   goover();
		 							   v.item=mnux.item;
									   x0=parseInt(this.style.left);
									   y0=parseInt(mnustyle.ysize)+parseInt(mnustyle.yspc)+1;
									   domenuex(this.item,cont,x0-1,y0); 
		 							   }
						} else {
						  v.lnk=mnux.lnk;
						  v.onclick=function () {
						  					 goover();
											 shellexecute(this.lnk);
						  					 }
						  }
		 			}
					
		 mnlyr.appendChild(v);
		 return v.offsetWidth;
		 }

function buildmenuex(mncnt,cont,mnux) {
		 var le=mnux.length;
		 var x00=parseInt(mnustyle.xspc);
		 var y00=parseInt(mnustyle.yspc);
		 
		 var ax;
		 var cm,x,y,w;
		 	 for (ax=0;ax<le;ax++) {
			 	 cm = mnux[ax];
				 x=x00;
				 y=y00;
			 	 w=mkmnux(mncnt,cont,cm,x,y);
				 x00+=w;
				 x00+=parseInt(mnustyle.xspc);
				 }
		 }
		 
// EXPORTEDSUB:
		 
function buildmenu(mncnt,cont,mnux) {
		 mnustyle=menuset[0];
		 buildmenuex(mncnt,cont,mnux);
		 }
		 
function domenu(mnu,objid,x0,y0) {
		 mnustyle=menuset[0];
		 domenuex(mnu,objid,x0,y0);
		 }			 
	 
		 
function supermenu(mnu,objid,x0,y0) {
		 if (mnu.styid) mnustyle=menuset[mnu.styid];
		 if (mnu.mnustyle) mnustyle=mnu.mnustyle;
		 if (mnu.x0) x0=mnu.x0;
		 if (mnu.y0) y0=mnu.y0;
		 if (mnu.objid) objid=mnu.objid;
		 if (mnu.mncnt) builbmenuex(mnu.mncnt,objid,mnu.menu); else domenuex(mnu.menu,objid,x0,y0);
		 }
		 
var StartMenus= new Object();
		 
// <!-- HOTKEYS MANAGER -->

function getkey(e) {
	if (Locked) return;
	if (!e) var e = window.event;
	var keycod; 
	var shift=0;
	if (e.shiftKey) shift=1;
	if (e.altKey) shift=shift | 2;
	if (e.ctrlKey) shift=shift | 4;
	
	if(window.event) keycod = e.keyCode; else if(e.which) keycod = e.which; 
	var uevent='HKey_'+shift+'_'+keycod;
	eval('if (HotKeys.'+uevent+') HotKeys.'+uevent+'(e);');
}

function addhotkey(ctrl,alt,shift,code,funct) {
		 var flg;
		 if (ctrl!=0) flg=4;
		 if (alt!=0) flg=flg | 2;
		 if (shift!=0) flg = flg | 1;
		 var uevent='HKey_'+flg+'_'+code;
		 
		 eval('HotKeys.'+uevent+' = funct;');
		 
		 }
		 
function delhotkey(ctrl,alt,shift,code) {
		 var flg;
		 if (ctrl!=0) flg=4;
		 if (alt!=0) flg=flg | 2;
		 if (shift!=0) flg = flg | 1;
		 var uevent='HKey_'+flg+'_'+code;
		 eval('if (HotKeys.'+uevent+') HotKeys.'+uevent+'=null;');
		 }

var lastmessage=null;
	
function message(inner,w,h,bgcolor,notims) {
		 
		 if (!w) w=400;
		 if (!h) h=64;
		 if (!bgcolor) bgcolor=procset.baloon.bgcolor;
		 var v;
		 var x=parseInt( (document.body.clientWidth-w) / 2);
		 var y=parseInt( (document.body.clientHeight-h) / 2);
		 var tmp8='';
		 var id = 'Ctrl_x'+(++numwin);
		 var notim=notims;
		 if (notims==-1) {
        notim=false;
        notims=true;
        }
		 Windows[id]=new Array('',id);
		 if (iexbug) v= new subBox(x,y,w,h,procset.baloon.bgcolor,id); else v= new subBox(x,y,w,h,bgcolor,id,'-moz-border-radius: 8px 8px 8px 8px; -webkit-border-radius: 8px 8px 8px 8px; border-radius: 8px 8px 8px 8px;');
		 v.style.fontFamily=procset.baloon.font;
		 v.style.fontSize=procset.baloon.fsize;
		 v.style.border=procset.baloon.border;
		 v.style.visibility='visible';
		 v.style.zIndex=(++zdx)+1000;
		 v.style.textAlign='center';
		 if (inner!='') {
		  if (notim) {
		    if (!iexbug) tmp8='-moz-border-radius: 4px 4px 4px 4px; -webkit-border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px;';
		    inner+="<br><span style=\"border: #000 1px solid;"+tmp8+"\" onmousedown=\"document.body.removeChild(document.getElementById('"+id+"'));\">&nbsp;Close&nbsp;</span>";
        }
      }
		 if (procset.baloon.alpha) alpha(v,procset.baloon.alpha);
		 if (inner!='') v.innerHTML='<table width="100%" height="100%" border=0><tr><td VALIGN=center STYLE="font-family: '+procset.baloon.font+'; font-size:'+procset.baloon.fsize+'; color:'+procset.baloon.color+';" ID="'+id+'_c"><center>'+inner+'</center></td></tr></table>';
		 document.body.appendChild(v);
		 if (inner=='') return v;
		 if (!notims) var timo2=setTimeout("removeid('"+id+"');",1000*procset.baloon.maxtim);
		 var o = new Object();
		 lastmessage=v;
		 o.msg = v;
		 o.content = document.getElementById(id+"_c");
		 return o;
		 }		
		 
function GetObjWinLink(v) {
    if (v.qrya) return v.qrya;
    if (v.qry) return '?'+v.qry;
    return '';
  }
	
function DoStats(e) {
   if (activeurl!='') {
    	var v=document.getElementById(activeurl);
      var u;
      if (v.qry) u=v.qry;
      shellexecute('wstats.phpe?'+u);
      }
  }
  	 
function WinActiveTo(phpe) {
   if (activeurl!='') {
    	var v=document.getElementById(activeurl);
      var u;
      if (v.qry) u=v.qry;
      shellexecute(phpe+'?'+u);
      }
  }
  	 
function CopyLink(e) {
		 if (activeurl=='') {txt=txt=procset.msg.nolink;} else {
		 					var v=document.getElementById(activeurl);
							if (v.qry) { var link=top.location.protocol+"//"+top.location.host+"/"+GetObjWinLink(v);
							   	     var txt=procset.msg.copylink+"<br>"+link;
									 if( window.clipboardData && clipboardData.setData ) clipboardData.setData("Text", link);
									 } else {
									 txt=txt=procset.msg.nolink;
									 }
							}
		 message(txt);
		 }
		 
function AddUrl(url,title) {
	if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if( window.external ) 
	   					{ window.external.AddFavorite( url, title); } else if(window.opera && window.print) 
						{ return true; }
 }		 
		 
function addprefwin() {
		 if (activeurl=='') {txt=txt=procset.msg.nolink;} else {
		 					var v=document.getElementById(activeurl);
							if (v.qry) { var link=top.location.protocol+"//"+top.location.host+"/"+GetObjWinLink(v);
							   	     var txt=procset.msg.winbookm;
									 var titolo;
									 v=document.getElementById(activeurl+'_cap');
									 if (v) titolo=v.innerHTML; else titolo=document.title;
									 
									 AddUrl(link,titolo);
									 
									 } else {
									 txt=txt=procset.msg.nolink;
									 }
							}
		 message(txt);

		 }

//<!-- History Manager --> 

function histicon(hdc) {
		 var nom='Div'+hdc;
		 var le,ico;
		 eval('if (!hist.'+nom+') le=-1; else le=hist.'+nom+'.length;');
		 if (le<2) ico=procset.sys.hisback[0]; else ico=procset.sys.hisback[1];
		 var v = document.getElementById('Back'+hdc);
		 if (v) v.src=ico;
		 }

function addhistory(hdc,link) {
		 var nom='Div'+hdc;
		 var le;
		 eval('if (!hist.'+nom+') hist.'+nom+'=new Array();');
		 le=eval('hist.'+nom+'.length');
		 eval('hist.'+nom+'[le] = link');
		 histicon(hdc);
		 }
		 
function delhistory(hdc) { eval('hist.Div'+hdc+'=null;') ;}
		 
function historyback(hdc) {
		 var le=-1;
		 var nom='Div'+hdc;
		 
		 eval('if (!hist.'+nom+') le=-1; else le=hist.'+nom+'.length;');
		 histicon(hdc);
		 
		 if (le==-1) return;
		 le-=2;
		 if (le<0) return;
		 var link=eval('hist.'+nom+'[le]');
		 eval('hist.'+nom+'.length=le');

		 shellquery(hdc,link);
		 histicon(hdc);
	 }
		 
// Alpha

function noalpha(obj) {
		 if(ie5) obj.style.filter=""; else obj.style.MozOpacity=1;
		 }

function alpha(obj,perc) {
		 var p=(perc/100);
		 if(ie5) obj.style.filter="alpha(opacity="+perc+")"; else obj.style.MozOpacity=p;
		 }

//<!-- ITP: InTime Procs -->

function startITP() {
	if (!procset.sys.updateinterval) return;
	   	   
	ITPTmr = setTimeout("ITPHandler();",1000* parseInt(procset.sys.updateinterval));
	//ITPHandler();
	}

function stopITP() {
  if (ITPTmr) clearTimeout(ITPTmr);
  ITPTmr=null;
  }

function ITPHandler() {
  var tc = Math.ceil(DateObj.getTime() / 1000);

    try {
      shellexecute('.sys:ITP?tcr='+tc);
     ITPLastm = tc;
      } catch(e) {;}
    
  ITPTmr = setTimeout("ITPHandler();",1000* parseInt(procset.sys.updateinterval));
  
  }

var ITPTmr;
var ITPLastm=0;
var DateObj = new Date();

//<!-- Effetti speciali -->

var SpecTmp;
var SpecIdx=new Array();
var Locked=false;
function lockit(nohdc) {
	var v = new subBox(0,0,document.body.clientWidth,document.body.clientHeight,procset.effe.blockcolor,'Blocker_Gui');
	alpha(v,0);
	v.style.zIndex=++zdx;
	document.body.appendChild(v);
	var a=new Array();
	a[0]='Blocker_Gui';
	addeffalpha(0,procset.effe.blockmax,a,procset.effe.blockblur,"");
	if (nohdc) {
		var ob = document.getElementById('Div'+nohdc+'_s');
		if (ob) ob.style.zIndex=++zdx;
		var ob = document.getElementById('Div'+nohdc+'_b');
		if (ob) ob.style.zIndex=++zdx;
		}
	Locked=true;
	}

function unlockit() {
	var a=new Array();
	a[0]='Blocker_Gui';
	addeffalpha(50,0,a,procset.effe.blockblur,"removeid('Blocker_Gui');");
	Locked=false;
	}
	
function blurobj(objid) {
	var v=new Array();
	v[0]=objid;
	addeffalpha(100,0,v,procset.effe.blur,"removeid('"+objid+"');");
	}
	
function blurwin(hdc) {
	var id=hdc; //'Div'+hdc;
	
	var r0=id+'_b|'+id+'_c';
	var v = document.getElementById(id+'_cI');
	if (v) r0+='|'+id+'_cI';
	r0=r0.split('|');
	addeffalpha(100,0,r0,procset.effe.blur,"hideboxEx('"+(hdc)+"');");	
	var s0=new Array();
	removeid(id+'_s');
	}

function addeffalpha(from,to,objids,speed,atend) {
	var mx = SpecIdx.length;
	var ef = new Object();
		ef.typ=1;
		ef.from=from;
		ef.to=to;
		ef.objs=objids;
		ef.ax=from;
		ef.tx=0;
		if (speed<1) speed=1;
		
		ef.spd=speed;
	if (atend) ef.end=atend;
	
	SpecIdx[mx]=ef;
	
	if (mx==0) SpecTmp=setTimeout("KernelEffSpec()",10);  
	}
	
function KernApplyEffect(k) {
	var le = k.objs.length;
	var v;
		
		for (var ax=0;ax<le;ax++) {
			v = document.getElementById(k.objs[ax]);
			if (v) {
			
				if (k.typ==1) alpha(v,k.ax);
				 
			}} //for & v
	
	}

function KernelEffSpec() {

	var le=SpecIdx.length;
	
	var no=0;
	var fin;
		for (var ax=0;ax<le;ax++) {
		fin=false;

		if (SpecIdx[ax].typ!=0) {
				
					SpecIdx[ax].tx=0;
					if (SpecIdx[ax].from>SpecIdx[ax].to) {
						SpecIdx[ax].ax-=SpecIdx[ax].spd;
						if (SpecIdx[ax].ax<=SpecIdx[ax].to) fin=true;
						}
					if (SpecIdx[ax].from<SpecIdx[ax].to) {
						SpecIdx[ax].ax+=SpecIdx[ax].spd;
						if (SpecIdx[ax].ax>=SpecIdx[ax].to) fin=true;
						}
				
					KernApplyEffect(SpecIdx[ax]);
					
					if (fin) {
						SpecIdx[ax].typ=0;
						if (SpecIdx[ax].end!="") try {
              eval(SpecIdx[ax].end); 
              no++;
              } catch(e) {alert('error ' + SpecIdx[ax].end.toSource());}
						
						}
					
					
				}//typ	
			}//for
			
	if (no<le) SpecTmr=setTimeout("KernelEffSpec()",10); else {clearTimeout(SpecTmr); SpecIdx=new Array();}
	}
	
//<!-- SUONI -->

var soundindex=0;
var lastmp3='';

function StopSound() {
  var id;
  var v;
  
  if (soundindex>0) {
    id='Sound' + (soundindex-1);
    v = document.getElementById(id);
    if (v) document.body.removeChild(v);
    }
  }


function Sound(mp3) {
  lastmp3=mp3;
  var id;
  var v;
  try {
  if (soundindex>0) {
    id='Sound' + (soundindex-1);
    v = document.getElementById(id);
    if (v) document.body.removeChild(v);
    }
    
  id='Sound' + soundindex;
  var n = subBox(0,0,1,1,'#000000',id);
  var idp = id+'p';
  
  n.style.visibility='hidden';
  n.innerHTML='<p align="center" style="visibility: hidden;" id="' + idp +'">&nbsp;</p>';
  
  var FO = {
      movie:"/inc/mp3player.swf",
      width:"1",
      height:"1",
      majorversion:"7",
      build:"0",
      bgcolor:"0xFFFFFF",
      flashvars:"file="+mp3+"&showdigits=false&autostart=true&showfsbutton=false&repeat=false&fsreturnpage=%2F"}
      ;
  
	document.body.appendChild(n);
  UFO.create(	FO, idp);

  soundindex++;
  } catch(e) {;}
  }	
//<!-- BOOT -->		

/*		
function BootGuiImages() {
		 var inner='';
		 var imglist=([
			"procset.win.icoerr"		 ,
			"procset.stat.normal"		 ,
			"procset.stat.load"		 ,
			"procset.stat.info"		 ,
			"procset.loading"		 ,
			"procset.icoerr"		 ,
			"procset.sys.hisback[0]"		 ,
			"procset.sys.hisback[1]"		 ,
			"menuset[0].submnu"				 ,
			"menuset[0].separator"			 ,
			"menuset[1].submnu"				 ,
			"menuset[1].separator"
		 	 ])
		 	 ;
		  
		 if (procset.imglist) imglist.concat(procset.imglist);
		 var le=imglist.length;
		 var id;
		 for (var ax=0;ax<le;ax++) {
		 	 id='img_cache_'+ax;
			 //eval("if ("+imglist[ax]+") imglist[ax]=\""+imglist[ax]+"\";" ) ;
			 try {
			   if (eval(imglist[ax]+';')) imglist[ax]=eval(imglist[ax]+';');
			   } catch(e) {;}
			 
		 	 inner+='<img src="'+imglist[ax]+'" width=2 height=2 id="'+id+'">';
			 imglist[ax]=id; //>
		 	 }
		 	 var o = new Object();
			 o.imglist=imglist;
			 o.inner=inner;
		  return o;
		 }
*/		 
function BootGuiHandler() {
	
if (http.readyState == 4) {
  	if (http.status!=200) {
	   localerro('HTTP Error '+http.status, http.statusText);
	   } 
	mouseturn(0);
	waitfl=0;
	
	var json;
	var e;
	try {
		json=eval("("+http.responseText+")");
		} catch(e) {
		  localerro('Procset Error','Error in JSON Format!\n'+e);
		  BootGuiComplete();
		  } 

	if (!json.ver) localerro('Server error', http.responseText);
	if (json.procset) procset=json.procset;
	if (json.menuset) menuset=json.menuset;
	if (json.StartMNU) StartMNU=json.StartMNU;
	//var json2=BootGuiImages();
	mnustyle=menuset[0];
	
/*
	var t0='<DIV ID="TMP" STYLE="left:0px; top:0px; width:1px; height:1px; overflow:hidden;">';
	t0+=json2.inner;
	t0+='</DIV>';
	t0+='<center>Loading...<BR><div ID="tmp_perc0" STYLE="border: solid #000000 1px; background-color: #00ffff; width:200px; height:16px; overflow:hidden; text-align:right;">';
	t0+='<DIV ID="tmp_prec1" STYLE="border-right: solid #000000 1px; background-color:#0080ff; width:1px; height:16px; overflow:hidden;font-family: Courier New,Monospace; font-size: 8pt; color:#000000;">&nbsp;</DIV></DIV></center>';
	sysmsg.content.innerHTML=t0;
	sysmsg.imgs=json2.imglist;
	sysmsg.tmr=setInterval("BootGuiTmr()",100);
	sysmsg.tmr2=setTimeout("BootGuiComplete()",3000);
	*/
	BootGuiComplete();
  }
}
/*
function BootGuiTmr() {
		 var le=document.images.length;
		 var ci=0;
		 
		 	 for (var ax=0;ax<le;ax++) { if (document.images[ax].complete) ci++;}
		 
		 var pr = parseInt((ci/le)*100);
		 var v = document.getElementById('tmp_prec1');
		 if (v) {
		 	v.style.width=pr;
			v.innerHTML=pr+'%';
		 	}
		 
		 if (ci>=le) BootGuiComplete();
		 }
*/
function BootGuiComplete() {
		 if (IsBootGuiComplete) return;
		 IsBootGuiComplete=true;
		 startITP();
		 if (sysmsg) { 
		 	clearInterval(sysmsg.tmr);
		 	document.body.removeChild(sysmsg.msg);
		 	sysmsg=null;
			}
		 
	//	 unlockit();
		 shellexecute('.system:desktop');
		 mouseturn(0);
		 		 
     if (procset.taskbar) StartTaskBar();
		 if (procset.autorun) {
		 	procset.autorun();
			delete(procset.eval);
		 	}
		 	
		 BootSystemProc();	
		 try { UpdeteDIcons() ; } catch(e) {;}
		 }

var IsBootGuiComplete=false;
 
function BootGui() {
		if (window==window.top) {top.location.href="/";return; }
		 
	//	lockit();
		
		 if (!http) {
		 	sysmsg =new message("AJAX Application not supported.<br>I can't create the XMLHTTP Object, your web browser is obsolete.<br>Please download <a href=\"http://mozilla.com\">Mozilla Firefox</a> and try again! :)",500,64,"#ffffff",1);
			return false;
			}

		 if (!w3c) {
		 	sysmsg =new message("This is not a standard w3c Browser.<br>I can't use the getElementById Object, your web browser is obsolete.<br>Please download <a href=\"http://mozilla.com\">Mozilla Firefox</a> and try again! :)",500,64,"#ffffff",1);
			return false;
			}
			
		 sysmsg =new message('Loading...',500,120,"#ffffff",1);
		 
	     http.open("GET", "/bin/run.php?f=%2Esystem%3Aboot", true);
		 http.onreadystatechange = BootGuiHandler;
		 mouseturn(1);
  		 http.send(null);
		 
		 PlaceDesk();		 
		 
		 }

// <!-- DYNAMIC SUBS --> //

var SubS = new Object();
var SubSc = new Object();
var DynaVar = new Object();

function addSub(nome,funct) {
	if (SubSc[nome]) SubSc[nome]++; else {
		SubSc[nome]=1;
		SubS[nome]=funct;
		}
	}

function delSub(nome) {
	if (!SubSc[nome]) return;
	SubSc[nome]--;
	if (SubSc[nome]<=0) {
		delete SubS[nome];
		delete SubSc[nome];
		}
	}
		 
function listSubs() {
	var qq='[';
	for (var x in SubSc) qq+=' {"'+x+'":'+SubSc[x]+'},';
	qq=qq.substr(0,qq.length-1)+"]";
	return qq;
	}

function addEvent(objid,name,funct) {
	var v = document.getElementById(objid);
	if (!v) return;
	if (!v.Uevents) v.Uevents= new Object();
	v.Uevents[name]=funct;
	}
	
function delEvent(objid,name) {
	var v = document.getElementById(objid);
	if (!v) return;
	if (!v.Uevents) return;
	delete v.Uevents[name];
	}
		 
function UEvent (name,valo,objid) {
	var th;
	if (!objid) th = this; else {
				th=document.getElementById(objid);
				if (!th) return;
				}
	if (th.Uevents) {
		if (th.Uevents[name]) { 
			if (valo) eval("th.Uevents[name]("+valo+");"); else th.Uevents[name]();
				}
			} 
	}
		
function setevent(objid,name,funct) {
	var v =document.getElementById(objid);
	if (!v) localerro('RUN-TIME Error',"Can't set event "+name+" for object "+objid);
	v[name]=eval(funct);
	}
		
 // <!-- Interform dialog -->
	
function shelldialog(form,hdc,toobjid,submit) {
		 var o= new Object();
		 o.hdc=hdc;
		 o.form=form;
		 o.toobj=toobjid;
		 if (submit) o.submit=submit;
		 o.dialoghdc=numwin;
		 var hdd = DialogsLength++;
		 Dialogs['Di'+hdd] = o;
		 lockit();
		 shellexecute(form,'hdd='+hdd);
		 }

function dialogreturn(hdd,result,objid) {
		 var o;
		 var ob;
		 unlockit();
		 if (objid) {
		 	ob=document.getElementById(objid);
			if (!ob) localerro('RUN-TIME Error',"Can't find object "+objid);
			if (ob.value) result=ob.value; else result=ob.innerHTML;
			}
		 o=Dialogs['Di'+hdd];
		 if (!o) localerro('RUN-TIME Error',"Dialog handle "+hdd+" not found!");
		 var txt=o.toobj.split('|');
		 var v = document.getElementById(txt[0]);
		 if (!v) localerro('RUN-TIME Error',"Can't set dialog data to object "+txt[0]);
		 if (v.value) v.value=result; else v.innerHTML=result;
		 
		 var le=txt.length;
		 
		 for (var ax=1;ax<le;ax++) {
		 	var px=txt[ax].indexOf('.');
			var arr=new Array();
			arr[0]=txt[ax].substr(0,px);
			arr[1]=txt[ax].substr(px+1);
			var eva="vx."+arr[1]+"=\""+result+"\";";
			var vx=document.getElementById(arr[0]);
			if (!vx) localerro('RUN-TIME Error',"Can't find object "+arr[0]); else {
			   		 try { eval(eva); } 
					 	 catch(err) {
						 	localerro('RUN-TIME Error',"Dialog return error in: "+txt[ax]+"<br>"+eva);
							}
					 }
		 	}
		 		 
		 closewindow(o.dialoghdc);
		 
		 delete Dialogs['Di'+hdd];
		 if (o.submit) o.submit(result);
		 }
  
 //test
	
function dialogopen(form,hdc,toobj,from,submit) {
	var o = new Object();
	o.hdc= hdc;
	o.form=form;
	o.toobj=toobj;
	if (from) o.from=from;
	if (submit) o.submit=submit;
	o.dialoghdc=numwin;
	var hdd = DialogsLength++;
	Dialogs['D'+hdd] = o;
	lockit();
	shellexecute(form,'hdd='+hdd);
}

function dialoglink(hdd,from) {
		 var id = 'D'+hdd;
		 if (!Dialogs[id]) { localerro('RUN-TIME Error',"Can't link dialog handle "+hdd+": Handle not found!"); return; }
		 Dialogs[id].from=from;
		 }	

function dialogprop(hdd,from,submit,exec,post) {
		 var id = 'D'+hdd;
		 if (!Dialogs[id]) {
		 	localerro('RUN-TIME Error',"Can't set extended dialog property to handle "+hdd);
		 	return;
		 	}
		if (from!='') Dialogs[id].from=from;
		if (submit) Dialogs[id].submit=submit;
		if (exec) Dialogs[id].exec=exec;
		if (post) Dialogs[id].post=post;
}
		
function dialogdone(hdd,result) {
		 var id = 'D'+hdd;
		 var rax;
		 var le;
		 var ax;
		 var bx;
		 var tmp;
		 var frm;
		 
		 unlockit();
		 	 
		 if (!Dialogs[id]) { localerro('RUN-TIME Error',"Dialog comunicator handle "+hdd+" not found!"); return; }
		 var o = Dialogs[id];
		 if (o.from) {
		 			 tmp=o.from.split('.');
					 if (tmp[0]=='') tmp[0]="Form"+o.dialoghdc;
					 frm = document.getElementById(tmp[0]);
					 if (!frm) { localerro('RUN-TIME Error',"Form "+tmp[0]+" not found!"); return; }
					 if (frm.elements) {
					 	le=frm.elements.length;
					 	if (tmp[1]) {
					 			    
									for (ax=0;ax<le;ax++) if (frm.elements[ax].name==tmp[1]) { rax=frm.elements[ax].value; break; }
									
					 			 	} else {
									
									rax='{';
									
									for (ax=0;ax<le;ax++) {
										bx=frm.elements[ax].value;
										bx.replace(/\"/g,"\\\"");
										rax+='"'+frm.elements[ax].name+'":"'+bx+'",';
										}
									rax=rax.substring(0,rax.length-1);
									rax+='}';
									
									} //tmp1
						} else {
						if (!frm.innerHTML) { localerro('RUN-TIME Error',"Can't get data from object "+frm.id); return; } else rax=frm.innerHTML;  
						} //elements
		 		} else {
				if (!result) { localerro('RUN-TIME Error',"Can't get the result for handle "+hdd); return; } else rax=result;
				}//from
					 
		 tmp = o.toobj.split('.');
		 if (tmp[0]=='') tmp[0]="Form"+o.hdc;
		 frm = document.getElementById(tmp[0]);
		 if (!frm) { localerro('RUN-TIME Error',"Can't set the result for handle "+hdd+" to object "+tmp[0]); return; }	
		 if (o.exec) rax=o.exec(rax);		 	 
		 if (tmp[1]) {
		 			 for (ax=0;ax<le;ax++) if (frm.elements[ax].name==tmp[1]) { frm.elements[ax].value=rax; break; }	 			 
		 			 } else {
					 if (!frm.innerHTML) { localerro('RUN-TIME Error',"Can't set result data from object "+frm.id); return; } else frm.innerHTML=rax;
					 } //tmp1
					 
		 closewindow(o.dialoghdc);		 
		 frm = document.getElementById('Div'+Dialogs[id].hdc+'_t');
		 if (frm) if (frm.xactive) frm.style.backcolor=frm.xactive;
		 if (o.post) o.post(rax);
		 if (o.submit) shellsubmit(o.hdc); 
		 delete Dialogs[id];	 
		 }
		
 		
 //<!-- Load DLL -->

 
function loaddll(dll) {
		 document.write('<'+'script type="text/javascript" src="'+dll+'"><'+'/'+'scr'+'ipt>');
		 }
 
 //<!-- TaskBar --> //
 
 function HideTaskName() {
 		  if (TaskBarName.timer) {
		  	 clearTimeout(TaskBarName.timer);
			 TaskBarName.timer=0;
			 }
		  TaskBarName.timer=setTimeout("HideTaskNameHit();",250);
 		  }
 
 function HideTaskNameHit() {
 		  TaskBarName.timer=0;
		  TaskBarName.style.visibility='hidden';
		  TaskBarName.innerHTML='';
		  TaskBarName.cap='';
 		  }

 function ShowTaskName(nam) {
 		 if (TaskBarName.timer) clearTimeout(TaskBarName.timer);
		 TaskBarName.timer=0;
		 if (TaskBarName.cap==nam) return;
		 TaskBarName.style.visibility='visible';
		 TaskBarName.innerHTML=nam;
		 TaskBarName.cap=nam;
 }
 
 function TaskCreateImg(x,y,src,idx) {
		 var v=document.createElement('div');
		 v.style.position='absolute';
		 v.style.left=x+'px';
		 v.style.top=y+'px';
		 v.style.width='20px';
		 v.style.height='20px';
		 v.style.visibility='visible';
		 v.style.padding='2px 2px 2px 2px';
		 v.style.textAlign='center';
		 v.innerHTML='<IMG SRC=\"'+src+'\" width=\"16\" height=\"16\" border=\"0\" alt=\"\">';
		 v.idx=idx;
		 
		 v.onmousedown=function () {
		 						IsTaskMouseOver=false;
		 					    clearTimeout(TaskMouseOutCnt);
		 						TaskBarOnMouseOut();  
								if (Locked) return;
								MaximizeForm(this.idx);
								HideTaskName();
		 						}
								
		 v.onmouseover = function () {
		 				clearTimeout(TaskMouseOutCnt);
						IsTaskMouseOver=true;
						this.style.backgroundColor=procset.taskbar.iconover; 
						this.style.border=procset.taskbar.icoborder;
						var v = document.getElementById('Div'+this.idx+'_c');
						if (v) {
						   ShowTaskName(v.tit);
						   } else HideTaskName();
						}
						
		 v.onmouseout = function () {
		 			  TaskMouseOutCnt=setTimeout("TaskBarOnMouseOut();",250);
					  IsTaskMouseOver=false;
					  this.style.backgroundColor='';
					  this.style.border='';
					  HideTaskName();
		 			  }
					  
		 return v;
		 }

function StartTaskBar() {
    if (IsTaskEnabled) return;
	IsTaskEnabled=true;
	var p = parseInt(procset.taskbar.pwidth);
	p = p/100;
	var w = Math.ceil(document.body.clientWidth*p); 
	var h = 21;
	var x = Math.ceil((document.body.clientWidth/2)-(w/2));
	var y = document.body.clientHeight - h -2;
	
	var tb = subBox(x,y,w,h,procset.taskbar.color,'GuiTaskBar',radius('8px 8px 0px 0px'));
	tb.y0= document.body.clientHeight - 8 -2;
	tb.y1= y;
	tb.whi=w-36;
	
	tb.style.height='8px';
	tb.style.top=tb.y0+'px';
	alpha(tb,procset.taskbar.alpha);
	tb.style.border=procset.taskbar.border;
	tb.style.zIndex=8000+(zdx++);
	tb.style.overflow='hidden';
	
	document.body.appendChild(tb);
	
	tb.advis=false;
	tb.onmouseover = function () {
				   clearTimeout(TaskMouseOutCnt);
				   IsTaskMouseOver=true;			   
				   this.style.height='21px';
				   this.style.top=this.y1+'px';
				   
				   var le = TaskBarList.length;
				   if ((le*21)>=this.whi) le = Math.ceil(this.whi/21);
				   var ax;
				   var i;
				   noalpha(this);
				   var stx = Math.ceil(this.whi/le);
				   if (stx<21) stx=21;
				   if (stx>30) stx=30;
				   
				   for (ax=0;ax<le;ax++) {
				       i=TaskCreateImg(8+(stx*ax),0,TaskBarList[ax].img,TaskBarList[ax].win);
					   this.appendChild(i);
					   TaskBarImgs[TaskBarImgs.length]=i;
				   	   }				   
				    
				   if (le==0) {
				   	  this.style.fontFamily=procset.taskbar.fontFamily; 
					  this.style.textAlign='center';
					  this.style.fontSize=procset.taskbar.fontSize;
					  this.style.color=procset.taskbar.fontColor;
					  this.innerHTML=procset.taskbar.none;
					  this.avis=true;
				   	  } else {this.avis=false;}
					
				   }
	tb.onmouseout= function() {
				   TaskMouseOutCnt=setTimeout("TaskBarOnMouseOut();",250);
				   IsTaskMouseOver=false;
				   if (this.avis) this.innerHTML='';
				   }
				   
	x = Math.ceil((document.body.clientWidth/2)-100);
	y = document.body.clientHeight-44;
	
	TaskBarName = subBox(x,y,200,16,procset.taskbar.color,'GuiTaskBarName',radius('8px 8px 8px 8px'));
	if (procset.taskbar.alpha2) alpha(TaskBarName,procset.taskbar.alpha2);
	 
	TaskBarName.style.border=procset.taskbar.border;
	TaskBarName.style.zIndex=8000+(zdx++);
	TaskBarName.style.overflow='hidden';
	TaskBarName.style.visibility='hidden';	
	TaskBarName.style.fontFamily=procset.taskbar.fontFamily; 
	TaskBarName.style.textAlign='center';
	TaskBarName.timer=0;
	TaskBarName.style.fontSize=procset.taskbar.fontSize;
	TaskBarName.style.color=procset.taskbar.fontColor;
	TaskBarName.innerHTML='';
	TaskBarName.cap='';
	TaskBarName.onmousedown = function () { this.style.visibility='hidden'; }
	document.body.appendChild(TaskBarName);
	IsTaskEnabled=true;
	}

function TaskBarOnMouseOut() {
		 		  if (IsTaskMouseOver) return;
		 		  th=document.getElementById('GuiTaskBar');	
	 			  th.style.height='8px';
				  th.style.top=th.y0+'px';
				  var ax;
				  var le=TaskBarImgs.length;
				  if (le>0) {
				  	 for (ax=0;ax<le;ax++) if (TaskBarImgs[ax]) th.removeChild(TaskBarImgs[ax]);
				  	 TaskBarImgs = new Array();
					 }
				  alpha(th,procset.taskbar.alpha);
				  if (TaskBarName) {
				  	 			   if (TaskBarName.timer) {
		  	 					   	  clearTimeout(TaskBarName.timer);
			 					   	  TaskBarName.timer=0;
			 					   	  }
								   TaskBarName.style.visibility='hidden'; 
								   TaskBarName.cap='';
				  	 			   }
				  }
	
function AddTaskInBar(win,image) {
		 var o = new Object();
		 o.img=image;
		 o.win=win;
		 TaskBarList[TaskBarList.length]=o;
		 }
	
function DelTaskInBar(idx) {
		 var tmp= new Array();
		 var le = TaskBarList.length;
		 
		 for (var ax=0;ax<le;ax++) if (TaskBarList[ax].win!=idx) tmp[tmp.length]=TaskBarList[ax];
			
		 TaskBarList=tmp;
		 }

function UnSelectForm(hdc) {
		 var bx=0;
		 var cx=0;
		 var dx=0;
		 var v;
		 for (var ax=0;ax<=numwin;ax++) {
		 	 if (ax!=hdc) {
			 	v = document.getElementById('Div'+ax+'_b');
				if (v) {
				   if (v.style.visibility!='hidden') {
				   	  bx = parseInt(v.style.zIndex);
				   	  if (bx>cx) {dx=ax; cx=bx;}
					  } //vis
				   } //v
			 	} //hdc_ax
		 	 }//for

		 if (dx) BringWindowToTop(dx);
		 EVECall('w'+hdc,'ondeactivate');
     }
		 
function MinimizeForm(hdc) {

		 UnSelectForm(hdc);
			 
		 var id='Div'+hdc;
		 var v = document.getElementById(id+'_t');
		 if (v) v.style.visibility='hidden';
		 var v = document.getElementById(id+'_b');
		 var icon='/bin/WINMNU.gif';
		 if (v) v.style.visibility='hidden';
		 var v = document.getElementById(id+'_s');
		 if (v) v.style.visibility='hidden';
		 var v = document.getElementById(id+'_c');
		 if (v) {
		 	v.oldh=v.style.height;
			v.style.height='0px';
		 	v.style.visibility='hidden';
			if (v.winicon) icon=v.winicon;
			}
		 var v = document.getElementById(id+'_cI');
		 if (v) {
		 	v.style.visibility='hidden';
			v.oldh=v.style.height;
			v.style.height='0px';
			}
		 var v = document.getElementById(id+'_rs');
		 if (v) v.style.visibility='hidden';
		 AddTaskInBar(hdc,icon);
		 var v=document.getElementById('GuiTaskBar');
		 if (v) {
		 	if (v.onmouseover) {
			   v.onmouseover();
			   IsTaskMouseOver=false;
			   TaskMouseOutCnt=setTimeout("TaskBarOnMouseOut();",500);
			   }
		 	}
		 EVECall('w'+hdc,'onminimize');
     }
		 
function MaximizeForm(hdc) {
		 DelTaskInBar(hdc);
		 var id='Div'+hdc;
		 var v = document.getElementById(id+'_b');
		 if (v) v.style.visibility='visible';
		 var v = document.getElementById(id+'_s');
		 if (v) v.style.visibility='visible';
		 var v = document.getElementById(id+'_c');
		 if (v) {
		 	v.style.visibility='visible';
			v.style.height=v.oldh;
			}
		 var v = document.getElementById(id+'_cI');
		 if (v) {
		 	v.style.visibility='visible';
			v.style.height=v.oldh;
			}
		 var v = document.getElementById(id+'_t');
		 if (v) v.style.visibility='visible';
 		 var v = document.getElementById(id+'_rs');
		 if (v) v.style.visibility='visible';
		 BringWindowToTop(hdc);
		 
		 
		 EVECall('w'+hdc,'onmaximize');
     }
 
 function BringWindowToTop(hdc) {
			var v = document.getElementById('Div'+hdc+'_b'); 
			if (v) v.onmousedown();
 		  EVECall('w'+hdc,'ontop');
       }//fun
 
 function GuiResize() {
 		  goover();
		  var v = document.getElementById('Blocker_Gui');
		  if (v) {
		  	 v.style.width=document.body.clientWidth+'px';
			 v.style.height=document.body.clientHeight+'px';
		  	 }
		  var v=document.getElementById('GuiTaskBar');
		  if (v) {
		  	 if (IsTaskMouseOver) {
			 	IsTaskMouseOver=false;
		 	 	clearTimeout(TaskMouseOutCnt);
		 	 	TaskBarOnMouseOut();
				}
			 
			 var p = parseInt(procset.taskbar.pwidth);
			 p = p/100;
			 var w = Math.ceil(document.body.clientWidth*p); 
			 var h = 21;
			 var x = Math.ceil((document.body.clientWidth/2)-(w/2));
			 var y = document.body.clientHeight - h -2;
			 v.style.left=x+'px';
			 v.style.top=y+'px';
			 v.style.width=w+'px';
			 v.style.height=h+'px';
			 v.y0= document.body.clientHeight - 8 -2;
			 v.y1= y;
			 v.whi=w-36;
			 v.style.height='8px';
			 v.style.top=v.y0+8+'px';
			 
			 IsTaskMouseOver=false;
		 	 clearTimeout(TaskMouseOutCnt);
		 	 TaskBarOnMouseOut();
		  	 }
			 
		 PlaceDesk();
		 try { UpdeteDIcons(); } catch(e) {;}
		
    var tmpo = Maximized;
    for (var xo in tmpo) {
      xo = tmpo[xo];
      var bo=document.getElementById('Div'+xo+'_c');
      if (bo) {
        if (bo.style.visibility!='hidden') ExitFullScreen(xo);
        }
      }			 
		 
		EVECall('gui','resize');	 
 		}
		  
function PlaceDesk() {
		 var dskBak000=document.getElementById('DesktopBackground');
		 if (!dskBak000) return;
		   var yy=(parseInt(document.body.clientHeight)-8);
		   var my=dskBak000.src;
		   my = my.split('?');
		   if (my[1]) if (yy>parseInt(my[1])) yy=parseInt(my[1]);
		   dskBak000.style.height=yy+'px';
		   dskBak000=document.getElementById('DesktopBackgroundDiv');
		  if (!dskBak000) return;  
		   var t=Math.ceil((document.body.clientHeight/2)-(yy/2));
   		   dskBak000.style.top=t+'px';
		   dskBak000.style.height=(document.body.clientHeight-t) + 'px';
		 }
 
 // AJAX Service
 
function AJAXRequest(file,proc /*(JSON)*/ ,post) {
		 file='/bin/run.php?f='+encodeURIComponent(file);
		 AJAXRequestDirect(file,proc,post);
		 
		 }
		 
var AJREQRes=0;
function AJAXRequestDirect(file,proc /*(JSON)*/ ,post) {
		 var o = new Object();
		 o.h = ++AJAXCounter;
		 o.proc = proc;
		 o.http = getHTTPObject();
		 AJREQRes=0;
		 
		 var method;
		 var req=null;
		 var fpo=false;
		 
		 if (!post) {
		 			fpo=false;
					method="GET";
					req=null;
					} else {
					fpo=true;
					method="POST";
					}
					
		 o.http.open(method, file, true);
		 AJAXInProgress['A'+o.h]=o;
		 
		 var fx="function () {	   		  		  			  \n";
		 	 fx+="var id = 'A"+o.h+"'; 	  		  			  \n";  	   			
				fx+="id = AJAXInProgress[id];				  \n";					
		 		fx+="if (id.http.readyState != 4) return;	  \n";
						fx+="		   if (id.http.status!=200) { \n";
								fx+="   	  localerro('RUN-Time error: Browser','Errore del server:\\n'+id.http.statusText);	    \n";
								fx+="		  AJREQRes=1;		  \n";
								fx+="	  	  AJAXRemove(id);	  \n";	
								fx+="	  	  return;			  \n";
								fx+="   	  }					  \n";
								fx+="   var text=id.http.responseText;					  \n";
								fx+="   try { text=eval('('+text+')'); } catch (e) {	  \n";
								fx+="   	localerro('RUN-Time error: Browser','Errore di dati JSON\\n'+id.http.responseText);   	   	\n";
								fx+="		AJREQRes=1;		  \n";
								fx+="	    AJAXRemove(id);	 		 				\n";
								fx+="	    return;			 \n";
								fx+="   	}				 \n";
								fx+="   id.proc(text);		 \n";
								fx+="   AJAXRemove(id);      \n";
		 						fx+="   }					 \n";

		 var fun=eval(fx);
		
		 o.http.onreadystatechange = fun;
		 
		 if (fpo) {
		 	req='';
			var nam;
			
			for(nam in post) { req+=nam+'='+encodeURIComponent(post[nam])+'&'; }
			
			req=req.substr(0,req.length-1);
			
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		 	http.setRequestHeader("Content-length", req.length);		
					
		 	}
			
		 o.http.send(req);		
		 AJAXInProgress['A'+o.h]=o;
		 
		 } 

function AJAXRemove(o) {
		 var id = 'A'+o.h;
		 try { AJAXInProgress[id].http.abort(); } catch(e) { ; }
		 delete AJAXInProgress[id];
		 } 
		
/// <!-- Critical session --> //

function ExceptionTrap(eip) {
		 try {
		 	 AJAXRequestDirect('/bin/kernel.php?err='+eip,ExceptionTrapX);
			 } catch(e) {
			 GuruMeditation(eip,e);
			 return;
			 }
		 if (AJREQRes!=0) GuruMeditation(eip);
		 
		 }
		 		 
function GuruMeditation(eip,e) {
		 var inner='<table width="100%" CELLSPACING=10 CELLPADDING=0 BORDER=0 STYLE="border: #ff0000 10px solid;">';
		 inner+='<tr><td BGCOLOR="#000000" STYLE="background-color: #000000;"><center><font STYLE="color: #ff0000; font-family: thaoma, Courier new, Monospace; font-size: 9pt; font-weight: bold;">';
		 inner+='Software Failure.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Press left mouse button to continue.<br><br>';
		 inner+='Guru Meditation #010000c.'+eip+'<br>';
		 inner+='</font></center></td></tr></table>';
		 top.document.body.style.backgroundColor='#000000';
		 top.document.body.innerHTML=inner;
		 }
		 
function ExceptionTrapX(js) {
		 var inner='<TABLE align=CENTER WIDTH="100%" height="100%" CELLPADDING=0 CELLPADDING=0 BORDER=0 STYLE="border: none; background-color:#0000ff;">'
		 inner+='<tr><td><TABLE align=CENTER WIDTH="80%" height="100%" CELLPADDING=0 CELLPADDING=0 BORDER=0 STYLE="border: none;">'
		 inner+='<tr><td><FONT STYLE="color: #c0c0c0; font-family: Courier New,Monospace; font-size: 10pt;"><B>';
		 inner+='<center><SPAN STYLE="color: #0000ff; background-color: #c0c0c0;">&nbsp;'+js.module+'&nbsp;</SPAN></center><br>';
		 inner+='<pre><font color="#ffffff">'+js.cause+':</font>\n\n';
		 inner+=decodeURIComponent(js.content)+'</pre>';
		 inner+='</B></FONT></td></tr></table></td></tr></table>';
		 top.document.body.style.backgroundColor='#0000ff';
		 top.document.body.innerHTML=inner;
		 }
		 
var AJAXInProgress = new Object();		 
var AJAXCounter=0;


//new medio //
var lastmsgbox;
var lastmsglock=false;

function msgboxbutton(id,action) {
		 if (lastmsglock) unlockit();
     goover();
		 var v=document.getElementById(id);
		 if (v) document.body.removeChild(v);
		 if (action!='') {
		 try {
		 	 eval(action);
			 } catch(e) {
			   localerro('MSGBOX action error',action);
			   }
		 lastmsgbox=false;
	   lastmsglock=false;	 
		 }}

function closeMsgbox() {
  goover();
  if (!lastmsgbox) try { document.body.removeChild(lastmsgbox.msg); } catch(e) {;}
  lastmsgbox=false;
  if (lastmsglock) unlockit();
  lastmsglock=false;
  }

function MSGBOX(text,cla) {
		 goover();
		 var cs='';
		 if (cla.icon) cs=' colspan="2"';
		 if (!lastmsgbox) try { if (lastmsglock) unlockit();
                            document.body.removeChild(lastmsgbox.msg); 
                            } catch(e) {;}
		 if (cla.lock) lockit();
		 lastmsglock=cla.lock;
		 
		 if (!cla) var cla=new Object();
		 
		 if (!cla.w) w=400; else w=cla.w;
		 if (!cla.h) h=64; else h=cla.h;
		 
		 if (!cla.bgcolor) bgcolor=procset.baloon.bgcolor; else bgcolor=cla.bgcolor;
		 
		 var id = 'Ctrl_x'+(++numwin);
		 
		 var inner='<table width="100%" height="100%"><tr>';
		 if (cla.title) inner=inner+'<td VALIGN=center'+cs+' STYLE="font-family: '+procset.baloon.font+'; font-size:'+procset.baloon.fsize+'; color:'+procset.baloon.color+';" ID="'+id+'_c"><center><B>'+cla.title+'</B></center></td></tr><tr>';
		 if (cla.icon) inner=inner+'<td width="50" VALIGN=TOP><center><img src="' + cla.icon+ '" alt=""></center></td>'; else text='<center>'+text+'</center>';
		 inner=inner + '<td VALIGN=TOP STYLE="font-family: '+procset.baloon.font+'; font-size:'+procset.baloon.fsize+'; color:'+procset.baloon.color+';" ID="'+id+'_c">'+text+'</td></tr>';
		 
		 if (cla.buttons) {
		 	var le = cla.buttons.length;
			le--;
			inner=inner+'<tr><td'+cs+'><center>';
			inner=inner+'<div style="width:8px; float:left;">&nbsp;</div>';
			for (var ax=0;ax<=le;ax++) {
				inner=inner+'<div class="msgboxbutton" style=" float:left;';
				inner=inner+';" ';
				inner=inner+'onmousedown="msgboxbutton('+"'";
				inner=inner+id+"','" + Escape(cla.buttons[ax].action) +"');"+'">';
				inner=inner+cla.buttons[ax].text+'</div>';
				
				if (ax==le) inner=inner+'<div style="width:8px; clear:left;">&nbsp;</div>'; else inner=inner+'<div style="width:8px; float:left;">&nbsp;</div>';
				}
			inner=inner+='</center></td></tr>';
		 	}
		 
		 inner=inner+='</table>';
		 var v;
		 var x=parseInt( (document.body.clientWidth-w) / 2);
		 var y=parseInt( (document.body.clientHeight-h) / 2);
		 
		 Windows[id]=new Array('',id);
		 if (iexbug) v= new subBox(x,y,w,h,procset.baloon.bgcolor,id); else v= new subBox(x,y,w,h,bgcolor,id,'-moz-border-radius: 8px 8px 8px 8px; -webkit-border-radius: 8px 8px 8px 8px; border-radius: 8px 8px 8px 8px;');
		 v.style.fontFamily=procset.baloon.font;
		 v.style.fontSize=procset.baloon.fsize;
		 v.style.border=procset.baloon.border;
		 v.style.visibility='visible';
		 v.style.zIndex=(++zdx)+1000;
		 v.style.textAlign='center';
		 if (procset.baloon.alpha) alpha(v,procset.baloon.alpha);
		  v.innerHTML=inner;
		 document.body.appendChild(v);
		 if (!cla.notim) var timo2=setTimeout("removeid('"+id+"'); if (lastmsglock) unlockit();",1000*procset.baloon.maxtim);
		 var o = new Object();
		 o.msg = v;
		 o.content = document.getElementById(id+"_c");
		 lastmsgbox=o;
		 return o;
		 }	

var UploA= new Object();

function shellsubmit2(midx,hdc) {
  var f;
  var v;
  var O = new Object();
  O.up = new Array();
  O.midx = midx;
  O.hdc = hdc;
  O.ax = 0;
  
  v = document.getElementById('formdiv'+hdc);
  if (v) {
    v.style.height='1px';
    v.style.visibility='hidden';
    v = document.getElementById('formdivl'+hdc);
    if (v) {
      v.style.visibility='visible';
      v.style.height='100px';
      v.innerHTML='<center><img src="/bin/UPLOAD.gif"><br><br>Uploading...</center>';
      }
    }
  
  for (var ax=1;ax<=midx;ax++) O.up[ax]='';
  
  for (var ax=1;ax<=midx;ax++) {
      f = document.getElementById('upload_'+hdc+'_'+ax);
      if (!f) alert('Object '+ax+' not found in form '+hdc);
    /*  if (!f.contentDocument) {*/
        f.src='javascript:SubMe()';
      /*  } else {
        v = f.contentDocument.getElementById('form');
        if (!v) alert('Object/form '+ax+' not found in form '+hdc); else v.submit();
        }*/
      }
  
  UploA['f'+hdc] = O;
  }

function Uploaded(hdc,idx,sid,sig) {
  var ix='f'+hdc;
  UploA[ix].up[idx]=sig;
  UploA[ix].ax++;
  if (UploA[ix].ax>=UploA[ix].midx) {
    shellsubmit(UploA[ix].hdc);
    delete UploA[ix];
    }
  }
 
// DDE

var DDES = new Object();

function AddDDE(nam,hdc) {
  if (!DDES[nam]) DDES[nam] = ({"a":[],"s":" "}) ;
  if (DDES[nam].s.indexOf(' '+hdc+' ')!=-1) return;
  
  DDES[nam].a.push(hdc);
  DDES[nam].s +=hdc+' ';
  }

function CallDDE(nam,url) {
  if (!DDES[nam]) return;
  var le = DDES[nam].a.length;
  var ax=0;
  var v;
  var hdc;
  var garb = new Array();
  var stx=' ';
  for (ax=0;ax<le;ax++) {
    hdc = DDES[nam].a[ax];
    v=document.getElementById('Div'+hdc+'_b');
    if (v) {
        garb.push(hdc);
        
       if (url=='') {
            closewindow(hdc);
            v=garb.pop();
          } else {
            try { 
              shellquery(hdc,url); 
              stx+=hdc+' ';
              } catch(e) {;}
        }
    }
  if (garb.length==0) {
      delete DDES[nam]; 
      } else {
        DDES[nam].a=garb;
        DDES[nam].s=stx;
        }
  }
}

function DelDDE(nam) {
  if (DDES[nam]) delete DDES[nam]; 
  }
  
//iconedesktop 2

function UpdeteDIcons() {

  if (!desktopicons) return;

  var ico;
  var v;
  var wh = screen.availWidth-100;
  var he = screen.availHeight-100;
  for (ico in desktopicons) {
     if (desktopicons[ico].x) {
      v=document.getElementById(ico);
      if (v) {
        v.style.left = Math.ceil((desktopicons[ico].x/100)*wh)+'px';
        v.style.top = Math.ceil((desktopicons[ico].y/100)*he)+'px';
        }
      }
    }
  }

//reload

var DesktopLoadingMessage;

function ChangeDesktop(item,dlmessage) {
  
  var o = new Object();
  if (dlmessage) try { DesktopLoadingMessage=message(dlmessage,null,null,null,ture); } catch(e) {;}
  
  if (!item) o.entry=''; else o.entry=item;
  o.w = document.body.clientWidth;
  o.h = document.body.clientHeight;
  
  AJAXService('/bin/reload.php',o,ChangeDesktopCB);
  }

function ChangeDesktopCB(js) {
  var v;
  
  if (js.html) {
    v = document.getElementById('desktopcontainer');
    if (v) v.innerHTML = js.html;
    }
  
  if (js.icons) desktopicons=js.icons;
  
  if (DesktopLoadingMessage) {
    try {
      document.body.removeChild(DesktopLoadingMessage);
      DesktopLoadingMessage=null;
      } catch(e) {;}
    }
  
  GuiResize();
  
  }
  
//fullscreen //

function SaveStyle(el) {
  var arr = ["left","top","width","height","zIndex"];
  var o= new Array;
  var bx;
  var cx=arr.length;
  var ax;
  for (ax=0;ax<cx;ax++) {
    bx=arr[ax];
    o[ax] = ([bx , el.style[bx]]);
    }
    
  return o;
  }

function LoadStyle(el,o) {
  var bx;
  var cx=o.length;
  var ax;
  for (ax=0;ax<cx;ax++) {
    bx = o[ax][0];
    el.style[bx]=o[ax][1];
    }
  }

function EnterFullScreen(hdc) {
    var dt=document.getElementById("Div"+hdc+"_t");
    if (dt.fullscreen) return;   
    var dc=document.getElementById("Div"+hdc+"_c");
    var db=document.getElementById("Div"+hdc+"_b");
    var btt=document.getElementById("Div"+hdc+"_btt");
    var cls=document.getElementById("Div"+hdc+"_cls");
    var ds=document.getElementById("Div"+hdc+"_s");
    var old = {
      "dc"  :   SaveStyle(dc) ,
      "db"  :   SaveStyle(db) ,
      "dt"  :   SaveStyle(dt) ,
      "btt"  :   SaveStyle(btt),
      "cls"  :   SaveStyle(cls),
      "ds"  :   SaveStyle(ds)
      }
      ;

    dt.fullscreen = old;
    dc.style.left='0px';
    dc.style.top=(parseInt(dt.style.height)+2)+'px';
    dc.style.width=(document.body.clientWidth-8)+'px';
    dc.style.height=(parseInt(document.body.clientHeight)-parseInt(dt.style.height)-4)+'px';
    dt.style.width=parseInt(document.body.clientWidth)+'px';
    //tt.style.width=(document.body.clientWidth-2)+'px';
    
    db.style.left='0px';
    db.style.top='0px';
    db.style.width=document.body.clientWidth+'px';
    db.style.height=document.body.clientHeight+'px';
    btt.style.left =(parseInt(document.body.clientWidth)-54)+'px'; 
    db.style.zIndex=++zdx;
	  dt.style.zIndex=++zdx;
    dc.style.zIndex=++zdx;    
    
    var bt=document.getElementById("Div"+hdc+"_FsB"); 
    if (!bt) return;
    if (procset.fullscreen0) bt.src = procset.fullscreen0; else bt.src = "/bin/sysimg/REDIMW.gif";
    Maximized['f'+hdc]=hdc;
    }
  
  
function ExitFullScreen(hdc) {
    var dt=document.getElementById("Div"+hdc+"_t");
    if (!dt.fullscreen) return;    
    var dc=document.getElementById("Div"+hdc+"_c");
    var db=document.getElementById("Div"+hdc+"_b");
    var tt=document.getElementById("Div"+hdc+"_s");
    var btt=document.getElementById("Div"+hdc+"_btt");
    var cls=document.getElementById("Div"+hdc+"_cls");
    var ds=document.getElementById("Div"+hdc+"_s");
    var old=dt.fullscreen;
    LoadStyle(dc,old.dc);
    LoadStyle(db,old.db);
    LoadStyle(dt,old.dt);
    LoadStyle(btt,old.btt);
    LoadStyle(cls,old.cls);
    LoadStyle(ds,old.ds);
    dt.fullscreen=null;
    db.style.zIndex=++zdx;
	  dt.style.zIndex=++zdx;
    dc.style.zIndex=++zdx;  
    var bt=document.getElementById("Div"+hdc+"_FsB");
    if (!bt) return;
    if (procset.fullscreen1) bt.src = procset.fullscreen1; else bt.src = "/bin/sysimg/FULLSW.gif"; 
    if (Maximized['f'+hdc]) delete Maximized['f'+hdc];
  }

function FullScreenButton(hdc) {
  var dt=document.getElementById("Div"+hdc+"_t");
  if (!dt.fullscreen) EnterFullScreen(hdc); else ExitFullScreen(hdc);
  }  

 //<!-- ### --> //
 
var Dialogs=new Object();
var DialogsLength=0;
var HotKeys= new Object();
 
addhotkey(1,0,1,67,CopyLink);		   //CTRL+SHIFT+C

var hist=new Object();

var numwin=1;
var http = getHTTPObject(); // AJAX Object
var http2 = getHTTPObject();
var blinks = new Array();	   //Oggetti lampeggianti
var timo2;
var blorem=0;
var mnuall= "";	 			   //Menù e daltri oggetti
var currmenu='';
var mnuobj='';
var activeurl='';
var mnutarget=document.body;
var cntmnu=0;
var curmenu='';
var menutree=new Object();
var mnucnt=1;
var sysmsg=new Object();
var Windows = new Object();
var TaskBarList = new Array();
var TaskBarImgs = new Array();
var TaskBarCNT=0;
var TaskMouseOutCnt;
var IsTaskMouseOver=false;
var IsTaskEnabled=false;
var TaskBarName;
var Maximized = new Object();

mnustyle=menuset[0];
var StartMNU=({
			   "M0":[
			   		 {"cap":"tramaci.org","lnk":"shellexecute('http://tramaci.org');"}
					 ]
			  }
			 )
			 ;


