function _tools()
{
  var cnt = 0;
  var timeout = 10;
  var aObjects = new Array();
  var aObjectQueue = new Array();
  var working = 0;
  //************************
  // ACTIONS
  //************************
  var actionMove    = 0;
  var actionRESIZE  = 1;
  var actionCOLOR   = 2;
  var actionExecute = 3;
  //************************
  // COMMON
  //************************
  var oId     = 0;
  var oType   = 1;
  var oObj    = 2;
  var oIdDep  = 3;
  //************************
  // MOVE
  //************************
  var oTop     = 4;
  var oLeft    = 5;
  var oIncTop  = 6;
  var oIncLeft = 7;
  //************************
  // RESIZE
  //************************
  var oWidth     = 4;
  var oHeight    = 5;
  var oIncWidth  = 6;
  var oIncHeight = 7;
  //************************
  // COLOR
  //************************
  var oWhich      = 4;
  var oColor      = 5;
  var oColorInc   = 6;
  var oColorRed   = 0;
  var oColorGreen = 1;
  var oColorBlue  = 2;
  //************************
  // EXECUTE
  //************************
  var oExecute = 4;
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.init = function(to)
  {
    timeout = to;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.removeAllObj_dnu = function(obj)
  {
    for(var i = aObjects.length-1;i>-1;i--){
      if(aObjects[i][oObj].id == obj.id){
        aObjects.splice(i,1);
      }
    }
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.removeAllColorObj_dnu = function(obj)
  {
    for(var i = aObjects.length-1;i>-1;i--){
      if(aObjects[i][oObj].id == obj.id && aObjects[i][oType] == actionCOLOR){
        aObjects.splice(i,1);
      }
    }
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.removeAll = function()
  {
    for(var i = aObjects.length-1;i>-1;i--){
      aObjects.splice(i,1);
    }
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.move = function(objId,objdep,top,left,inct,incl)
  {
    var have = false;
    var id = cnt++;

    if(top != null) top = parseInt(top);
    if(left != null) left = parseInt(left);
    if(inct != null) inct = parseInt(inct);
    if(incl != null) incl = parseInt(incl);


    if(objdep == null) {
      aObjects.push([id,actionMove,objId,objdep,top,left,inct,incl]);
      //debug("MOVE 1: "+aObjects[aObjects.length-1]);
    }
    else {
      aObjectQueue.push([id,actionMove,objId,objdep,top,left,inct,incl]);
      //debug("MOVE 2: "+aObjectQueue[aObjectQueue.length-1]);
    }

    if(!working) this.doWork(1);
    return id;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.resize = function(objId,objdep,width,height,incw,inch)
  {
    var have = false;
    var id = cnt++;

    if(width != null) width = parseInt(width);
    if(height != null) height = parseInt(height);
    if(incw != null) incw = parseInt(incw);
    if(inch != null) inch = parseInt(inch);

    if(objdep == null){
      aObjects.push([id,actionRESIZE,objId,objdep,width,height,incw,inch]);
      //debug("RESIZE 1: "+aObjects[aObjects.length-1]);
    }
    else{
      aObjectQueue.push([id,actionRESIZE,objId,objdep,width,height,incw,inch]);
      //debug("RESIZE 2: "+aObjectQueue[aObjectQueue.length-1]);
    }

    if(!working) this.doWork(1);
    return id;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.color = function(objId,objdep,whichColor,toColor,colorInc)
  {
    var id = cnt++;
    if(typeof(toColor) == "string") toColor = [HexToR(toColor),HexToG(toColor),HexToB(toColor)];

    if(objdep == null) {
      aObjects.push([id,actionCOLOR,objId,objdep,whichColor,toColor,colorInc]);
      //debug("COLOR 1: "+aObjects[aObjects.length-1]);
    }
    else {
      aObjectQueue.push([id,actionCOLOR,objId,objdep,whichColor,toColor,colorInc]);
      //debug("COLOR 2: "+aObjectQueue[aObjectQueue.length-1]);
    }


    if(!working) this.doWork(1);
    return id;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.execute = function(toExecute,objdep)
  {
    var id = cnt++;

    if(objdep == null) aObjects.push([id,actionExecute,toExecute,objdep,1]);
    else      aObjectQueue.push([id,actionExecute,toExecute,objdep,1]);

    if(!working) this.doWork(1);
    return id;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.doWork = function(which)
  {
    if(working == 0 || which == 0){
      working = 1;
      var remove;
      var aRemove = new Array();
      var have = false;
      var ojb = null;
      for(var i=0;i<aObjects.length;i++){
        var ok = false;
        while(!ok){
          try {
            remove = true;
            if(aObjects[i][oType] == actionMove)        remove = doMove(aObjects[i]);
            else if(aObjects[i][oType] == actionRESIZE) remove = doResize(aObjects[i]);
            else if(aObjects[i][oType] == actionCOLOR)  remove = doColor(aObjects[i]);
            else if(aObjects[i][oType] == actionExecute && aObjects[i][oExecute] == 1){
              aObjects[i][oExecute] = 0;
              remove = doExecute(aObjects[i]);
            }
            if(remove) {
              aRemove.push(i);
            }
            ok = true;
          }
          catch (e){
            //debug(aObjects[i]);
            //debug(e);
            //return;
          }
        }
      }

      for(var i=0;i<aRemove.length;i++){
        aObjects.splice(aRemove.pop(),1);
      }

      for(var i=0;i<aObjectQueue.length;i++){
        have = false;
        for(var j=0;j<aObjectQueue.length;j++){
          if(aObjectQueue[j][oId] == aObjectQueue[i][oIdDep]){
            have = true;
            break;
          }
        }

        for(var j=0;j<aObjects.length;j++){
          if(aObjects[j][oId] == aObjectQueue[i][oIdDep]){
            have = true;
            break;
          }
        }
        if(!have){
          aObjects.push(aObjectQueue.splice(i,1)[0]);
        }
      }

      if(aObjects.length != 0) {
        setTimeout(oname+"doWork(0)",timeout);
        return;
      }
    }
    working = 0;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function doMove(aObject)
  {
    var obj = document.getElementById(aObject[oObj]);
    var t=parseInt(obj.style.top);
    var l=parseInt(obj.style.left);
    //***********************************************
    //***********************************************
    if(aObject[oTop] != null && t != aObject[oTop]){
      if(Math.abs(t-aObject[oTop]) < aObject[oIncTop]){
        obj.style.top = aObject[oTop]+"px";
      }
      else {
        if(aObject[oTop]>t) obj.style.top = (t+aObject[oIncTop])+"px";
        else                obj.style.top = (t-aObject[oIncTop])+"px";
      }
      w=parseInt(obj.style.top.replace("px",""));
    }
    //***********************************************
    //***********************************************
    if(aObject[oLeft] != null && l != aObject[oLeft]){
      if(Math.abs(l-aObject[oLeft]) < aObject[oIncLeft]){
        obj.style.left = aObject[oLeft]+"px";
      }
      else {
        if(aObject[oLeft]>l) obj.style.left = (l+aObject[oIncLeft])+"px";
        else                 obj.style.left = (l-aObject[oIncLeft])+"px";
      }
      h=parseInt(obj.style.left.replace("px",""));
    }
    //***********************************************
    //***********************************************
    if((aObject[oTop] == null || aObject[oTop]!= null && t == aObject[oTop]) && (aObject[oLeft] == null || aObject[oLeft]!= null && l == aObject[oLeft])){
      return true;
    }
    return false;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function doResize(aObject)
  {
    var obj = document.getElementById(aObject[oObj]);
    var w=parseInt(obj.style.width.replace("px",""));
    var h=parseInt(obj.style.height.replace("px",""));
    //***********************************************
    //***********************************************
    if(aObject[oWidth] != null && w != aObject[oWidth]){
      if(Math.abs(w-aObject[oWidth]) < aObject[oIncWidth]){
        obj.style.width = aObject[oWidth]+"px";
      }
      else {
        if(aObject[oWidth]>w) obj.style.width = (w+aObject[oIncWidth])+"px";
        else                  obj.style.width = (w-aObject[oIncWidth])+"px";
      }
      w=parseInt(obj.style.width.replace("px",""));
    }
    //***********************************************
    //***********************************************
    if(aObject[oHeight] != null && h != aObject[oHeight]){
      if(Math.abs(h-aObject[oHeight]) < aObject[oIncHeight]){
        obj.style.height = aObject[oHeight]+"px";
      }
      else {
        if(aObject[oHeight]>h) obj.style.height = (h+aObject[oIncHeight])+"px";
        else                   obj.style.height = (h-aObject[oIncHeight])+"px";
      }
      h=parseInt(obj.style.height.replace("px",""));
    }
    //***********************************************
    //***********************************************
    if((aObject[oWidth] == null || aObject[oWidth]!= null && w == aObject[oWidth]) && (aObject[oHeight] == null || aObject[oHeight]!= null && h == aObject[oHeight])){
      return true;
    }
    return false;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function doColor(aObject)
  {
    var obj = document.getElementById(aObject[oObj]);
    var aColor = getColorArray(obj,aObject[oWhich]);

    if(aColor == null) return true;

    var r = parseInt(aColor[oColorRed]);
    var g = parseInt(aColor[oColorGreen]);
    var b = parseInt(aColor[oColorBlue]);
    var rr = 0;
    var gg = 0;
    var bb = 0;

    //***********************************************
    //***********************************************
    if(Math.abs(r-aObject[oColor][oColorRed]) < aObject[oColorInc][oColorRed]){
      rr = aObject[oColor][oColorRed];
    }
    else {
      if(aObject[oColor][oColorRed]>r) rr = r+aObject[oColorInc][oColorRed];
      else                             rr = r-aObject[oColorInc][oColorRed];
    }
    //***********************************************
    //***********************************************
    if(Math.abs(g-aObject[oColor][oColorGreen]) < aObject[oColorInc][oColorGreen]){
      gg = aObject[oColor][oColorGreen];
    }
    else {
      if(aObject[oColor][oColorGreen]>g) gg = g+aObject[oColorInc][oColorGreen];
      else                               gg = g-aObject[oColorInc][oColorGreen];
    }
    //***********************************************
    //***********************************************
    if(Math.abs(b-aObject[oColor][oColorBlue]) < aObject[oColorInc][oColorBlue]){
      bb = aObject[oColor][oColorBlue];
    }
    else {
      if(aObject[oColor][oColorBlue]>b) bb = b+aObject[oColorInc][oColorBlue];
      else                              bb = b-aObject[oColorInc][oColorBlue];
    }
    //***********************************************
    //***********************************************

    setColorArray(obj,aObject[oWhich],rr,gg,bb);
    aColor = getColorArray(obj,aObject[oWhich]);
    r = parseInt(aColor[oColorRed]);
    g = parseInt(aColor[oColorGreen]);
    b = parseInt(aColor[oColorBlue]);
    if(r == aObject[oColor][oColorRed] && g == aObject[oColor][oColorGreen] && b == aObject[oColor][oColorBlue]){
      return true;
    }
    return false;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function getColorArray(obj,whichColor)
  {
    var color = null;

    if(obj.style && obj.style.backgroundColor && whichColor == "background-color")      color = obj.style.backgroundColor;
    if(obj.style && obj.style.borderColor && whichColor == "border-color")              color = obj.style.borderColor;
    if(obj.style && obj.style.borderLeftColor && whichColor == "border-left-color")     color = obj.style.borderLeftColor;
    if(obj.style && obj.style.borderRightColor && whichColor == "border-right-color")   color = obj.style.borderRightColor;
    if(obj.style && obj.style.borderTopColor && whichColor == "border-top-color")       color = obj.style.borderTopColor;
    if(obj.style && obj.style.borderBottomColor && whichColor == "border-bottom-color") color = obj.style.borderBottomColor;
    if(obj.style && obj.style.color && whichColor == "color")                           color = obj.style.color;



    if((color == null ||  color.length == 0) && obj.style && obj.style.borderColor && (whichColor == "border-left-color" || whichColor == "border-right-color" || whichColor == "border-top-color" || whichColor == "border-bottom-color")){
      color = obj.style.borderColor;
    }

    if(color == null || color.length == 0) {
      debug("Unable to find color "+whichColor+" for "+obj.id);
      return null;
    }

    if(color.indexOf("#")!=-1){
      return [HexToR(color),HexToG(color),HexToB(color)];
    }
    return color.replace("rgb(","").replace(")","").split(",");
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function HexToR(h) {return parseInt((cutHex(h)).substring(0,2),16);}
  function HexToG(h) {return parseInt((cutHex(h)).substring(2,4),16);}
  function HexToB(h) {return parseInt((cutHex(h)).substring(4,6),16);}
  function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h;}
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function setColorArray(obj,whichColor,r,g,b)
  {
    if(whichColor == "background-color")    obj.style.backgroundColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "border-color")        obj.style.borderColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "border-left-color")   obj.style.borderLeftColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "border-right-color")  obj.style.borderRightColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "border-top-color")    obj.style.borderTopColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "border-bottom-color") obj.style.borderBottomColor ="rgb("+r+","+g+","+b+")";
    if(whichColor == "color")               obj.style.color ="rgb("+r+","+g+","+b+")";
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function doExecute(aObject)
 {
    eval(aObject[oObj]);
    return true;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.isIE = function()
  {
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    //var is_minor = parseFloat(navigator.appVersion);

    // ************************************************
    // *** is it mozilla
    var is_nav    = (
                      (agt.indexOf("mozilla") != -1) &&
                      (agt.indexOf("spoofer") == -1) &&
                      (agt.indexOf("compatible") == -1) &&
                      (agt.indexOf("opera") == -1) &&
                      (agt.indexOf("webtv") == -1) &&
                      (agt.indexOf("hotjava") == -1)
                    );
    var is_nav2    = (is_nav && (is_major == 2));
    var is_nav3    = (is_nav && (is_major == 3));
    var is_nav4    = (is_nav && (is_major == 4));
    var is_nav4up  = (is_nav && (is_major >= 4));
    var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
    var is_nav6    = (is_nav && (is_major == 5));
    var is_nav6up  = (is_nav && (is_major >= 5));
    var is_gecko   = (agt.indexOf("gecko") != -1);
    // ************************************************
    // *** is it ie
    var is_ie     = (agt.indexOf("msie") != -1 && agt.indexOf("opera") == -1);
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4)  && agt.indexOf("msie 4")!=-1);
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4)  && agt.indexOf("msie 5.0")!=-1);
    var is_ie5_5  = (is_ie && (is_major == 4)  && agt.indexOf("msie 5.5") !=-1);
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    return is_ie;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.findPos = function(obj)
  {
    var curleft = 0;
    var curtop = 0;
    if (obj && obj.offsetParent) {
      curleft = obj.offsetLeft;
      curtop = obj.offsetTop;
      while (obj = obj.offsetParent) {
        curleft += obj.offsetLeft;
        curtop += obj.offsetTop;
      }
    }
    return [curtop,curleft];
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.getObjectPosition = function(obj)
  {
    var curleft = 0;
    var curtop = 0;
    if (obj.offsetParent) {
      curleft = obj.offsetLeft;
      curtop = obj.offsetTop;
      while (obj = obj.offsetParent) {
        curleft += obj.offsetLeft;
        curtop += obj.offsetTop;
      }
    }
    return [curtop,curleft];
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.getCenterPositon = function(topOffset,leftOffset,allowOutside,leftPadding,topPadding)
  {
    var ws = this.getWindowDimension();
    var nws = [parseInt(ws.height/2)+topOffset,parseInt(ws.width/2)+leftOffset];

    if(!allowOutside){
      if(nws[0] < (topPadding)) nws[0] = topPadding;
      if(nws[0] > (ws.height-topPadding)) nws[0] = ws.height-topPadding;

      if(nws[1] < (leftPadding)) nws[1] = leftPadding;
      if(nws[1] > (ws.width-leftPadding)) nws[1] = ws.width-leftPadding;
    }

    return eval("new function c(){ this.top=parseInt("+nws[0]+");this.left=parseInt("+nws[1]+");}");
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.getWindowDimension = function()
  {
    var width = 400;
    var height = 400;
		if (document.body && document.body.offsetWidth) {
      width = document.body.offsetWidth;
      height = document.body.offsetHeight;
		}
		if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) {
      width = document.documentElement.offsetWidth;
      height = document.documentElement.offsetHeight;
		}
		if (window.innerWidth && window.innerHeight) {
      width = window.innerWidth;
      height = window.innerHeight;
		}
    
      return eval("new function c(){ this.height=parseInt("+height+");this.width=parseInt("+width+");}");
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.formatAmount = function(e, field,decimals)
  {
    if(!decimals && decimals !== 0) decimals = 2;
    if (!(navigator.appName == "Netscape" || navigator.appName == "Microsoft Internet Explorer")) return;
    var key;
    if (document.all) {
      key=e.keyCode;
    }
    else {
      key=e.which;
      if (key==13) return; //return pressed
    }
    if ((key==37)||(key==39)) return; //left or right arrow
    var temp=field.value.replace(/[^0-9]/g,"");
    temp=temp.replace(/^0+/,"");
    while (temp.length<decimals+1){
      temp="0"+temp;
    }
    if (field.value.search(/-/)!=-1) temp="-"+temp;
    if(decimals !== 0) field.value=temp.substr(0,temp.length-decimals)+"."+temp.substr(temp.length-decimals);
    else field.value = temp;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.calFontSize = "font:9px Arial;text-align:center;";
  this.TableBorder = "background-color:#282828;border:1px solid #333333;"+this.calFontSize;
  this.TableCalendarTdHdr = "font-size:11px;color:#9999FF;font-weight:normal;"+this.calFontSize;
  this.TableCalendarTdCurday = "color:#FF9900;"+this.calFontSize;
  this.TableCalendarTdDayLabelTd = "color:#DD9900;border-bottom:1px solid #666666;"+this.calFontSize;
  this.DayOff = "color:BBBBBB;background-color:#393939;"+this.calFontSize;
  this.Col =  "font:10px Arial;color:#BBBBBB;"+this.calFontSize;
  this.lastCalendarTarget = null;

  this.setCalendarColorSchemeToWhite = function()
  {
    this.TableBorder = "background-color:#FFFFFF;border:1px solid #bbbbbb;"+this.calFontSize;
    this.TableCalendarTdHdr = "font-size:11px;color:#DD7700;font-weight:normal;"+this.calFontSize;
    this.TableCalendarTdCurday = "color:#FF9900;border:1px solid #DD7700;"+this.calFontSize;
    this.TableCalendarTdDayLabelTd = "color:#444444;border-bottom:1px solid #999999;"+this.calFontSize;
    this.DayOff = "color:#666666;background-color:#DDDDDD;"+this.calFontSize;
    this.Col =  "font:10px Arial;color:#666666;"+this.calFontSize;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.generateCalendarMonth = function(m,y,t,l,func,target)
  {
    var o = "";
    var w = 16;
    var c = 0;
    var nl = "\n";
    var SD_pre = "";
    var SD_post = "";
    var date = null;
    var close = 1;
    var days = [0,31,28,31,30,31,30,31,31,30,31,30,31];
    var months = [
                "",
                "January",
                "February",
                "March",
                "April",
                "May",
                "June",
                "July",
                "August",
                "September",
                "October",
                "November",
                "December"
              ];
    var isCurrent = "";
    this.hideLastCalendarTarget();
    if(!document.getElementById(target)){
      document.body.innerHTML += "<div id=\""+target+"\" style=\"position:absolute;top:"+t+";left:"+l+";\">123</div>";
    }
    
    this.lastCalendarTarget = document.getElementById(target);
    
    var lTableBorder = this.TableBorder+ "table-layout:fixed;width:"+((w*7)+w)+"px;position:absolute;top:0;left:0;";
    var lTableCalendarTdHdr = this.TableCalendarTdHdr;
    var lTableCalendar = this.TableBorder+"table-layout:fixed;"+this.calFontSize;
    var lTableCalendarTdCurday = this.TableCalendarTdCurday;
    var lTableCalendarTdDayLabelTd = this.TableCalendarTdDayLabelTd;
    var lDayOff = this.DayOff+"width:"+w+"px;height:"+w+"px;";
    var lCol =  this.Col+"text-align:center;cursor:default;";

    var pm = m-1;
    var py = y;
    if(pm < 1) {
      pm = 12;
      py = py-1;
    }
    var nm = m+1;
    var ny = y;
    if(nm > 12) {
      nm = 1;
      ny = ny+1;
    }
    var dt = new Date();
    var cd = dt.getDate();
    var cm = dt.getMonth()+1;
    var cy = dt.getFullYear();

    o += "<table cellpadding=\"4\" style=\""+lTableBorder+"\">"+nl;
    o += "  <tr>"+nl;
    o += "    <td>"+nl;
    o += "<table style='"+lTableCalendar+"' cellspacing='0'>"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <col width='"+w+"' style=\""+lCol+"\">"+nl;
    o += "  <tr>";+nl;
    o += "    <td style='"+lTableCalendarTdHdr+"' unselectable='on' onclick=\""+oname+"generateCalendarMonth("+pm+","+py+","+t+","+l+",'"+func+"','"+target+"');\">&lt;</td>";
    o += "    <td colspan='5' style='"+lTableCalendarTdHdr+"' unselectable='on'>"+months[m]+"&nbsp;&nbsp;"+y+"</td>";
    o += "    <td style='"+lTableCalendarTdHdr+"' unselectable='on' onclick=\""+oname+"generateCalendarMonth("+nm+","+ny+","+t+","+l+",'"+func+"','"+target+"');\">&gt;</td>";
    o += "  </tr>"+nl;
    o += "  <tr height='"+w+"'>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>S</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>M</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>T</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>W</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>R</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>F</td>";+nl;
    o += "  <td style=\""+lTableCalendarTdDayLabelTd+"\" unselectable='on'>S</td>";+nl;
    o += "  </tr>"+nl;
    o += "  <tr height='"+w+"'>";+nl;
    date = new Date(m+"/1/"+y+" 12:00:00");
    for(i=0;i<date.getDay();i++){
      o += "    <td unselectable='on'></td>"+nl;
      c++;
    }
    for(i=1;i<days[m]+1;i++){
      SD_pre = "";
      SD_post = "";
      isCurrent = "";
      isSunday = "";
      var ddd = new Date(m+"/"+i+"/"+y+" 12:00:00");
      var dayofweek = ddd.getDay();
      var ii = "";
      var mm = "";
      if(cd == i && m == cm && cy == y) isCurrent = " style='"+lTableCalendarTdCurday+"'";
      else {

        if(SD_pre == "" && (dayofweek == 0 || dayofweek == 6)){
          isCurrent = " style='"+lDayOff+"'";
        }
      }


      if(i<10) ii = "0";
      if(m<10) mm = "0";


      o += "    <td"+isCurrent+" unselectable='on' onclick=\""+oname+"storeClickedDate('"+ii+""+i+"','"+mm+""+m+"','"+y+"','"+func+"')\">"+SD_pre+i+SD_post+"</td>"+nl;
      c++;
      if(c%7==0){
        o += "  </tr>"+nl;
        if(i != days[m]){
          o += "  <tr height='"+w+"'>"+nl;
          close = 1;
        }
        else close = 0;
      }
    }
    if(close) o += "  </tr>"+nl;
    o += "</table>"+nl;
    o += "    </td>"+nl;
    o += "  </tr>"+nl;
    o += "</table>"+nl;
    if(document.getElementById(target) != null){
      document.getElementById(target).innerHTML = o;
      document.getElementById(target).style.top = t;
      document.getElementById(target).style.left = l;
      return;
    }
    return o;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.calendarDate = [0,0,0];
  this.storeClickedDate = function(d,m,y,f)
  {
    this.calendarDate[0] = d;
    this.calendarDate[1] = m;
    this.calendarDate[2] = y;
    eval(f);
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.hideLastCalendarTarget = function()
  {
   if(this.lastCalendarTarget && document.getElementById(this.lastCalendarTarget)) document.getElementById(this.lastCalendarTarget).innerHTML = "";
   this.lastCalendarTarget = null;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.getStoredClickedDate = function()
  {
    return this.calendarDate;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.getDate = function()
  {
    var d = new Date();
    var cd = parseInt(d.getDate());
    var cm = parseInt(d.getMonth()+1);
    var cy = d.toString().split(" ")[3];    
    
    if(cy.length != 4) cy = d.toString().split(" ")[5];
    
    return [parseInt(cy),cm,cd];
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.isCtrlKeyPressed = function()
  {
    try {
      if(event.ctrlKey) return true;
    }
    catch(e) {
      return false;
    }
    return false;
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  var oname;
  var jso = null;
  var script = "";
  var debugcnt = 0;
  var _debugWidth_ = 300;
  var _debugHeight_ = document.documentElement.clientHeight-10;
  var _debugTop_ = 0;
  var _debugLeft_ = document.documentElement.clientWidth-_debugWidth_;
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this._init_ = function(j,s,n)
  {
    jso = j;
    script = s;
    oname = n+".";
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.functions = function()
  {
    var a = script.split("\n");
    var out = "";
    for(var i=0;i<a.length;i++){
      if(a[i].split("this.").length == 2 && a[i].split("function").length == 2 && a[i].split("=").length == 2 && a[i].split("__").length != 3){
        out += a[i].replace("function","").replace("this.","").replace(" = ","").replace("  ","")+"\n";
      }
    }
    debug(out);
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  function debug(txt)
  {
    obj = document.getElementById(oname+"DebugObj");
    if(!obj){
      document.body.innerHTML += "<table cellspacing=\"0\" cellpadding=\"0\" style=\"table-layout:fixed;position:absolute;top:"+_debugTop_+"px;left:"+_debugLeft_+";width:"+_debugWidth_+"px;height:"+_debugHeight_+"px;border:1px solid #999999;\"><tr><td style=\"height:15px;color:#DD7700;padding-left:5px;\">"+oname+"</td></tr><tr valign=\"top\"><td><textarea id=\""+oname+"DebugObj"+"\" style=\"width:"+(_debugWidth_-9)+"px;height:"+(_debugHeight_-15)+"px;font:10px Lucida Console;\"></textarea></td></tr></table>";
    }
    obj = document.getElementById(oname+"DebugObj");
    if(obj != null){
      //obj.value = obj.value+txt+"\n";
      obj.value = txt+"\n"+obj.value;
      debugcnt++;
      if(debugcnt % 60 == 0) obj.value = "";
    }
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
  this.debug = function(txt)
  {
    obj = document.getElementById(oname+"DebugObj");
    if(!obj){
      document.body.innerHTML += "<table cellspacing=\"0\" cellpadding=\"0\" style=\"table-layout:fixed;position:absolute;top:"+_debugTop_+"px;left:"+_debugLeft_+";width:"+_debugWidth_+"px;height:"+_debugHeight_+"px;border:1px solid #999999;\"><tr><td style=\"height:15px;color:#DD7700;padding-left:5px;\">"+oname+"</td></tr><tr valign=\"top\"><td><textarea id=\""+oname+"DebugObj"+"\" style=\"width:"+(_debugWidth_-9)+"px;height:"+(_debugHeight_-15)+"px;font:10px Lucida Console;\"></textarea></td></tr></table>";
    }
    obj = document.getElementById(oname+"DebugObj");
    if(obj != null){
      //obj.value = obj.value+txt+"\n";
      obj.value = txt+"\n"+obj.value;
      debugcnt++;
      if(debugcnt % 60 == 0) obj.value = "";
    }
  }
  /*****************************************************************************************************************************
  ******************************************************************************************************************************
  ******************************************************************************************************************************
  *****************************************************************************************************************************/
}
