function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function addDocumentMouseOverEvent(func) {
  var oldmouseover = document.onmouseover;
  if (typeof document.onmouseover != 'function') {
	document.onmouseover = func;
  } else {
	  document.onmouseover = function() {
      if (oldmouseover) {
    	oldmouseover();
      }
      func();
    }
  }
}

function addOnClickEvent(func) {
  var oldonclick = window.onclick;
  if (typeof document.onclick != 'function') {
    document.onclick = func;
  } else {
    document.onclick = function() {
      if (oldonclick) {
        oldonclick();
      }
      func();
    }
  }
}

function getY(oElement, oStopAt) {
  var iReturnValue = 0;
  while(oElement != null && oElement != oStopAt) {
    iReturnValue += oElement.offsetTop;
    oElement = oElement.offsetParent;
  }
  return iReturnValue;
}



function getX(oElement, oStopAt) {
  var iReturnValue = 0;
  while(oElement != null && oElement != oStopAt) {
    iReturnValue += oElement.offsetLeft;
    oElement = oElement.offsetParent;
  }
  return iReturnValue;
}

function killProperty(pObject, pProperty) {
  if(!pObject.TmpProperties) {
    pObject.TmpProperties = new Object();
  }
  pObject.TmpProperties[pProperty] = pObject[pProperty];
  pObject[pProperty] = null;
}

function restoreProperty(pObject, pProperty) {
  if(!pObject.TmpProperties) {
    pObject.TmpProperties = new Object();
  }
  pObject[pProperty] = pObject.TmpProperties[pProperty];
  pObject.TmpProperties[pProperty] = null;
}

function DoNothing(e) {
  if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
}

function bindFunction(fFunc,Owner) {
    return function() {
      return fFunc.apply(Owner, arguments);
    }
}