//================================= CLASS CONSTRUCTOR ========================================
function GUtils()
{
//VARIABLES
//The semaphore used for event sync-ing ...
 this.eventsync = new Semaphore();
//The messaging manager system ...
 this.mmgr = null;
//The system messaging manager system ...
 this.smmgr = null;
//The downloader ...
 this.downloader = null;
//The resource manager ...
 this.rmgr = null;
//The window manager ...
 this.wmgr = null;
//The wait manager ...
 this.waitmgr = null;

//Specifies if the server session has been inited for the user that logged on...
 this.sessionStarted = false;
//The global tag object used for keeping temporary data ...
 this.tag = null;
//aux for any purpose ...
 this.aux = null; 
//The global error tag object used for tracking the last error ...
 this.error = null;
//la variabile che contiene il risultato delle operazioni sull'ftp
 this.ftpErrorCode = null;
//other needed eventSybc
this.eventsync1 = new Semaphore();
this.eventsync2 = new Semaphore();
this.eventsync3 = new Semaphore();
}

//====================================== STATIC ==============================================

//====================================== MEMBERS =============================================
GUtils.prototype.finalize = function()
{
 if (this.eventsync != null)
  this.eventsync = null;
 if (this.mmgr != null)
  this.mmgr = null;
 if (this.smmgr != null)
  this.smmgr = null;
 if (this.downloader != null)
 {
  this.downloader.finalize();
  this.downloader = null;
 }
 if (this.waitmgr != null)
 {
  this.waitmgr.finalize();
  this.waitmgr = null;
 }
 if (this.wmgr != null)
  this.wmgr = null;

 if (this.eventsync1 != null)
  this.eventsync1 = null;
 if (this.eventsync2 != null)
  this.eventsync2 = null;
 if (this.eventsync3 != null)
  this.eventsync3 = null;
 this.ftpErrorCode = null;
}
GUtils.prototype.getFtpErrorCode = function()
{
    return this.ftpErrorCode;
}
GUtils.prototype.setFtpErrorCode = function(errorCode)
{
    this.ftpErrorCode = errorCode;
}
GUtils.prototype.getTag = function()
{
 var ret = this.tag;
//Since it has been queried we'll clear it ...
 if (this.tag == null)
 {
  alert('WARNING: Tag queried for value twice without set between!!!');
 }
 this.tag = null;
 return ret;
}

GUtils.prototype.setTag = function(value)
{
//This SHOULD NEVER HAPPENED ... IF IT DOES THEN THE TAG IS SETTED BY TWO DIFFERENT SOURCES(MULTITHREADING -- SHOULD NEVER HAPPEN)
 if (this.tag != null)
 {
  alert('Logic error: should never happen!!!');
  return;
 }
 this.tag = value;
}

GUtils.prototype.getError = function()
{
 var
  ret = this.error;

//Since it has been queried we'll clear it ...
 if (this.error == null)
  alert('WARNING: Error queried for value twice without set between!!!');
 this.error = null;
 return ret;
}

GUtils.prototype.setError = function(ivalue)
{
//This SHOULD NEVER HAPPENED ... IF IT DOES THEN THE TAG IS SETTED BY TWO DIFFERENT SOURCES(MULTITHREADING -- SHOULD NEVER HAPPEN)
 if (this.error != null)
 {
  alert('Logic error: should never happend !!!');
  return;
 }
 this.error = ivalue;
}
