
function addLoadEvent(func) {
	addLoadEvent(func, false);
}

function addLoadEvent(func, insertAtFirst) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } 
  else {
  	  if(insertAtFirst) {
  	  	  window.onload = function() {
  	  	  	func();
	      	oldonload();
      	  	};
      }
      else {
	    window.onload = function() {
	      oldonload();
	      func();
    	};
      }
  }
}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

function isIE()
{
   return navigator.appName == "Microsoft Internet Explorer";
}

function getStyleById(Id) {
	return document.getElementById(Id).style;
}

function getWidthById(Id) {
    return parseInt(getStyleId(Id).width);
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}
function ltrim(st) {
	return str.replace(/^\s+/,"");
}
function rtrim(str) {
	return str.replace(/\s+$/,"");
}

function test() {
	//alert(document.getElementsByTagName("body")[0].clientHeight);
	//var height = document.getElementById("content").clientHeight;
	//getStyleById("sidebar").height = height + "px";
}
        
//addLoadEvent(test);