
var utils = new (function() {

  var self = this;

  ////////////////////////////////////////////////////////////////////////////

  this.addClassName = function(el, className)
  {
    el.className += ' '+className;
  }

  ////////////////////////////////////////////////////////////////////////////

  this.removeClassName = function(el, className)
  {
    eval('re = /\\s*'+className+'\\s*/g;');
    el.className = el.className.replace(re, ' ');
  }

  ////////////////////////////////////////////////////////////////////////////

  this.isClassName = function(el, className)
  {
    return (el.className.indexOf(className) > -1);
  }

  ////////////////////////////////////////////////////////////////////////////

  this.stopPropagation = function(e)
  {
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
  }

  ////////////////////////////////////////////////////////////////////////////

  this.getStyle = function(element, style) {
    var value = element.style[style];
    if (!value) {
      if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(element, null);
        value = css ? css.getPropertyValue(style) : null;
      } else if (element.currentStyle) {
        value = element.currentStyle[style];
      }
    }

    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
      if (this.getStyle(element, 'position') == 'static') value = 'auto';

    return value == 'auto' ? null : value;
  }

  ////////////////////////////////////////////////////////////////////////////

  this.setOpacity = function(element, value) {
    if (value == 1) {
      element.style.opacity =
        (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 
        0.999999 : null;
      if (/MSIE/.test(navigator.userAgent)) {
        element.style.filter = this.getStyle(element, 'filter').replace(/alpha\([^\)]*\)/gi,'');
      }
    } else {
      if (value < 0.00001) {
        value = 0;
      }
      element.style.opacity = value;
      if (/MSIE/.test(navigator.userAgent)) {
        element.style.filter = this.getStyle(element, 'filter').replace(/alpha\([^\)]*\)/gi,'') +
          'alpha(opacity='+value*100+')';
      }
    }   
  }  

  ////////////////////////////////////////////////////////////////////////////

  // avoiding bugs: in Firefox when load tasklist, in IE when onload and resizing
  this.redrawFooter = function()
  {
    // for Firefox
    document.getElementById('bottom').style.display = 'none';
    document.getElementById('bottom').style.display = '';

    // for IE
    if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
      var footerElement = document.getElementById('bottom');
      var footerHeight = '20';

      footerElement.style.top  = 0;
      footerElement.style.bottom = 0;
      if (document.body.scrollHeight > document.documentElement.clientHeight) {
        var windowHeight = document.body.scrollHeight;
        footerElement.style.top = (windowHeight - footerHeight) + 'px';
      } else {
        var windowHeight = document.documentElement.clientHeight;
        //alert(windowHeight+','+footerHeight);
        footerElement.style.top = (windowHeight - footerHeight) + 'px';
      }
    }
  }

  ////////////////////////////////////////////////////////////////////////////

});

