
String.prototype.trim = function() {

	return this.replace(/(^\s*|\s*$)/,"");
}

var DHTML = document.getElementById;

function getObj(name) {

  if (document.getElementById) {
  
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all) {
  
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers) {
  
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
  else
  	return false;
  
  return this;
}

function getStyle(obj) {

  if(document.getElementById
  		|| document.all)
  	return obj.style;
  else if(document.layers)
  	return obj;
  else
  	return false;
}

	
function getElement( id ) {

	if( document.getElementById ) {
		this.obj = document.getElementById( id );
		this.style = this.obj.style;
	}
	return this;
}

function setText( obj, text ) {
	if( obj.firstChild
			&& obj.firstChild.nodeValue )
		obj.firstChild.nodeValue = text;
	else
		return false;
	return true;
}

/*********** Start dynamic menus code *************/

var oMenus = [];

function closeMenu(id) {
	if(oMenus[id].obj.canClose) {
		oMenus[id].style.visibility = 'hidden';
		oMenus[id].obj.canClose = false;
	}
}

function closeAllButMe(id) {
	for( var oMenu in oMenus )
		if( oMenu != id )
			oMenus[oMenu].style.visibility = 'hidden';
}

function setVisible(id) {
	if(!oMenus[id])
		oMenus[id] = new getObj(id);
	if(!oMenus[id]) 
		return;
	oMenus[id].obj.canClose = false;
	closeAllButMe(id);
	oMenus[id].style.visibility = 'visible';
}

function setHidden(id) {
	oMenus[id].obj.canClose = true;
	setTimeout('closeMenu("'+id+'")', 500);
}

/*********** End dynamic menus code *************/


