var $ = function(_id)
{
  return document.getElementById(_id);
};

cls = {
};

cls.doc = {
  tscrollTop: function()
  {
    return document.documentElement.scrollTop;
  },
  tscrollLeft: function()
  {
    return document.documentElement.scrollLeft;
  },
  tscrollWidth: function()
  {
    return document.documentElement.scrollWidth;
  },
  tscrollHeight: function()
  {
    return document.documentElement.scrollHeight;
  },
  tclientWidth: function()
  {
    return document.documentElement.clientWidth;
  },
  tclientHeight: function()
  {
    return document.documentElement.clientHeight;
  }
};

cls.mask = {
  tWidth: 0,
  tHeight: 0,
  tclientWidth: null,
  tclientHeight: null,
  tSetDivStyle: function()
  {
    var tobj1 = $('jMask');
    var tobj2 = $('jMaskDIV');
    if (tobj1 && tobj2)
    {
      tobj2.style.marginTop = (cls.doc.tscrollTop() - Math.floor(cls.mask.tHeight / 2)) + 'px';
      if (cls.mask.tclientWidth != cls.doc.tclientWidth())
      {
        cls.mask.tclientWidth = cls.doc.tclientWidth();
        tobj1.style.width = cls.doc.tclientWidth() + 'px';
        if (cls.doc.tscrollWidth() > cls.doc.tclientWidth()) tobj1.style.width = cls.doc.tscrollWidth() + 'px';
      };
      if (cls.mask.tclientHeight != cls.doc.tclientHeight())
      {
        cls.mask.tclientHeight = cls.doc.tclientHeight();
        tobj1.style.height = cls.doc.tclientHeight() + 'px';
        if (cls.doc.tscrollHeight() > cls.doc.tclientHeight()) tobj1.style.height = cls.doc.tscrollHeight() + 'px';
      };
      setTimeout('cls.mask.tSetDivStyle()', 60);
    };
  },
  tCreateDiv: function()
  {
    var tDiv = document.createElement('div');
    tDiv.setAttribute('id', 'jMask');
    tDiv.style.position = 'absolute';
    tDiv.style.top = '0';
    tDiv.style.left = '0';
    tDiv.style.background = '#000000';
    tDiv.style.filter = 'Alpha(Opacity=30)';
    tDiv.style.opacity = '0.3';
    tDiv.style.width = '0px';
    tDiv.style.height = '0px';
    //tDiv.style.width = cls.doc.tscrollWidth() + 'px';
    //tDiv.style.height = cls.doc.tscrollHeight() + 'px';
    tDiv.style.zIndex = '999999998';
    document.body.appendChild(tDiv);
    tDiv = document.createElement('div');
    tDiv.setAttribute('id', 'jMaskDIV');
    tDiv.style.position = 'absolute';
    tDiv.style.top = '50%';
    tDiv.style.left = '50%';
    tDiv.style.zIndex = '999999999';
    document.body.appendChild(tDiv);
    cls.mask.tclientWidth = cls.doc.tclientWidth();
    cls.mask.tclientHeight = cls.doc.tclientHeight();
    setTimeout('cls.mask.tSetDivStyle()', 60);
  },
  tShow: function(_strHTML)
  {
    var tstrHTML = _strHTML;
    if (tstrHTML)
    {
      var tobj = $('jMaskDIV');
      if (!tobj)
      {
        cls.mask.tCreateDiv();
        tobj = $('jMaskDIV');
      };
      if (tobj)
      {
        tobj.style.display = 'none';
        tobj.innerHTML = tstrHTML;
      };
    };
  },
  tSetStyle: function()
  {
    var tobj = $('jMaskDIV');
    if (tobj)
    {
      tobj.style.display = 'block';
      cls.mask.tWidth = tobj.offsetWidth;
      cls.mask.tHeight = tobj.offsetHeight;
      tobj.style.marginLeft = (0 - Math.floor(cls.mask.tWidth / 2)) + 'px';
      tobj.style.marginTop = (cls.doc.tscrollTop() - Math.floor(cls.mask.tHeight / 2)) + 'px';
    };
  },
  tClose: function()
  {
    var tobj1 = $('jMask');
    var tobj2 = $('jMaskDIV');
    if (tobj1 && tobj2)
    {
      document.body.removeChild(tobj1);
      document.body.removeChild(tobj2);
    };
  }
};

anuc = {
  tTimeout: null,
  tShow: function(_strURL)
  {
    var tstrURL = _strURL;
    if (tstrURL)
    {
      var tHTML = '<div class="jimgPreview"><img src="' + tstrURL + '" class="hidden" onload="this.className = \'hand\'; cls.mask.tSetStyle();" onclick="anuc.tClose();" /></div>';
      cls.mask.tShow(tHTML);
      cls.mask.tSetStyle();
    };
    anuc.tTimeout = setTimeout('anuc.tClose()', 5000);
  },
  tClose: function()
  {
    cls.mask.tClose();
    clearTimeout(anuc.tTimeout);
  }
};