var CrossBrowser = new function (){
  this.onLoadRequests = new Array();
  this.onLoadRequestsPos = 0;

  this.addEventListener = function(irElement, isEventName, irFunction, ibCapture){
    if (irElement.addEventListener) // W3C DOM
      irElement.addEventListener(isEventName, irFunction, ibCapture);
    else if (irElement.attachEvent) // IE4 DHTML DOM
      irElement.attachEvent('on'+isEventName, irFunction);
    //else
    //  this.UnsupportedBrowser();
  }

  this.addWindowOnLoadListener = function(irFunction){
    this.onLoadRequests[this.onLoadRequests.length] = irFunction;
  }

  this.CancelEvent = function(irEvent){
    if(irEvent.preventDefault) //W3C DOM
      irEvent.preventDefault();
    else
      irEvent.returnValue = false; //IE4 DHTML DOM
  }

  this.getClientWidth = function() {
    var lnClientWidth = 0;

    if (document.compatMode && document.compatMode != 'BackCompat') {
      lnClientWidth = document.documentElement.clientWidth;
    } else {
      lnClientWidth = document.body.clientWidth;
    }
    return lnClientWidth;
  }

  this.GetEventTarget = function(irEvent){
    if(irEvent.target) //W3C DOM
      lrTarget = irEvent.target;
    else if(irEvent.srcElement) //IE4 DHTML DOM
      lrTarget = irEvent.srcElement;
    else
      lrTarget = null;
    return lrTarget;
  }
  this.GetNodeType = function(isNodeTypeName){
    lnResult = null;
    eval('if(document.'+isNodeTypeName+'){lnResult = document.'+isNodeTypeName+';}');
    if(lnResult == null){
      switch(isNodeTypeName){
        case 'ELEMENT_NODE':
          lnResult = 1;
          break;
        case 'TEXT_NODE':
          lnResult = 3;
          break;
        case 'COMMENT_NODE':
          lnResult = 8;
          break;
      }
    }
    return(lnResult);
  }

  this.ProcessWindowOnLoad = function(){
    var lrFunc;
    if (this.onLoadRequestsPos < this.onLoadRequests.length){
      lrFunc = this.onLoadRequests[this.onLoadRequestsPos++];
      lrFunc();
      setTimeout("CrossBrowser.ProcessWindowOnLoad()", 10);
    }
  }
  this.RaiseEvent = function(irElement,isEventName){
    if(irElement.fireEvent){ //IE4 DHTML DOM
      irElement.fireEvent('on'+isEventName);
    }else{ //W3C DOM
      var lrEvt = document.createEvent('HTMLEvents');
      lrEvt.initEvent(isEventName, true, false);
      irElement.dispatchEvent(lrEvt);
    }
  }
  this.IsUndefined = function (irVar){
    return (typeof(irVar) == 'undefined'); //IE 5.0 don't understand (isText == undefined)
  }
  this.namedItem = function(irCollection, isName){
    lrItem = null;
    if(irCollection.namedItem) //W3C
      lrItem = irCollection.namedItem(isName);
    else{ //IE <6.0
      for(var i=0; i<irCollection.length; i++){
        if(irCollection.item(i).id == isName){
          lrItem = irCollection.item(i);
          break;
        }
      }
    }
    return lrItem;
  }
}
function ProcessWindowOnLoad(){
  setTimeout("CrossBrowser.ProcessWindowOnLoad()", 10);
}

CrossBrowser.addEventListener(window, 'load', ProcessWindowOnLoad);

