


aData = function(name) { 
  this.name = name; 
  this.items = new Array(); 
} 

aData.prototype.addItem = function(id, item) { 
  this.items[this.items.length] = new Array(id, item);
}

aData.prototype.in_array = function(datum, strict) { 
  if (strict) function equals(a,b) { return a === b }
  else function equals(a,b) { return a == b }

    for (var i in this.items) {
        if (equals(this.items[i][1], datum)) return true;
  }
  return false;
}

aData.prototype.removeItem = function(iArrayId) {
  this.items.splice(iArrayId,1);
}

aData.prototype.removeWord = function(word, strict) {
  if (strict) function equals(a,b) { return a === b }
  else function equals(a,b) { return a == b }
  
  for (var i in this.items) {
	  	if (equals(this.items[i][1],word)) {
			 this.items.splice(i,1);
		}
  }
  return false;
}


Array.prototype.in_array = function(datum, strict) {
	if (strict) function equals(a,b) { return a === b }
    	else function equals(a,b) { return a == b }

    for (var i in this) {
        if (equals(this[i], datum)) return true;
    }
   	return false;
}


function parseXMLData(object) {
	if(object[0].childNodes.length){
		if(object[0].childNodes[0] != null || object[0].childNodes[0] != 'undefined')
			return object[0].childNodes[0].data;
		else
			return '';
	}
	return '';
}

function showObject(item){
	item.style.display = "block";
	return true;
}

function hideObject(item){
	item.style.display = "none";
	return true;
} 

function showLayer(name){
	obj = getObj(name);
	obj.style.display = "block";
}

function hideLayer(name){
	obj = getObj(name);
	obj.style.display = "none";
} 

function closeItem(name){
	var divItem = getObj(name);
	oloHideObject(divItem);
}

function changeColor(elem, clr, brclr){
	elem.style.backgroundColor = brclr;
	elem.style.color = clr;
}


function getObj(name) {
	if (document.getElementById) {
    	obj=document.getElementById(name);
    }
	else if (document.layers) {
    	obj=document.layers[name];
	}
	else if (document.all) {
		obj=document.all[name];
	}
	else {
	   obj=false;
	}
	return obj;
}

function getFormatedText(sString, iStrNum){
	var sStringFrmText = sString.substr(0,iStrNum);
	if(sString.length > sStringFrmText.length)
			sStringFrmText = sStringFrmText + '...';
	
	return sStringFrmText;
}

function getUpperText(sString){
	var sStringFrmText = sString.toUpperCase();
	return sStringFrmText;
}

function getLowerText(sString, iFirstUp){
	var sStringFrmText = sString.toLowerCase();
	
	if(!iFirstUp)
		iFirstUp = 0;
	
	if(iFirstUp == 1)
		sStringFrmText = sStringFrmText.charAt(0).toUpperCase() + sStringFrmText.substring(1,sStringFrmText.length);
	
	return sStringFrmText;
}


function LTrim(str) {
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	    j++;
    	s = s.substring(j, i);
  	}
	return s;
}

function RTrim(str) {

	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      	i--;
		s = s.substring(0, i+1);
  	}

return s;
}


function Trim(str) {
  return RTrim(LTrim(str));
}


String.prototype.addClass = function(theClass) {
	if (this != "") {
		if (!this.classExists(theClass)) {
			return this + " " + theClass;
		}
	}
	else {
		return theClass;
	}
	return this;
}



String.prototype.classExists = function(theClass) {
	var regString = "(^| )" + theClass + "\W*";
	var regExpression = new RegExp(regString);
	if (regExpression.test(this)) {
		return true;
	}
	return false;
}

String.prototype.removeClass = function(theClass){
	var regString = "(^| )" + theClass + "\W*";
	var regExpression = new RegExp(regString);
	return this.replace(regExpression, "");
}



