String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function AnalizeARs(Expr, NodeAr)
{
	if(Expr == null) return true;

	Expr = ReplaceVars(Expr, NodeAr);

	return eval(Expr);
}

function ReplaceVars(str, NodeAr)
{
	for(var key in NodeAr)
		str = str.replace(new RegExp("ar::" + key, "g"), NodeAr[key]);
	return str;
}

/*****************************************************************************************************
	Box
		Description:
			Class for containing dimentions of a square, as well as defining classes to determine the
			size of a control, or whether a Point (defined below) is within the square.
		Input:
			Top		- Top location of the box.
			Right	- Right location of the box.
			Bottom	- Bottom location of the box.
			Left	- Left location of the box.
		Variables:
			Same as above.
		Usage:
			var bx = new Box(10, 20, 20, 10);
			var pt = new Point(11, 11);
			bx.IsPointInBox(pt);		//returns true
			
			pt = new Point(9, 9);
			bx.IsPointInBox(pt);		//returns false
			
			var tbl = document.getElementById(sometable);
			bx.FromControl(tbl, null);	// bx now contains the measurements of "sometable"
******************************************************************************************************/
function Box(Top, Right, Bottom, Left)
{
	this.Top = Top;
	this.Right = Right;
	this.Bottom = Bottom;
	this.Left = Left;
}
Box.prototype.FromControl = function(obj, borderadjust)
{
	if(obj == null) return;
	var curleft = 0;
	var curtop = 0;
	var curObj = obj;
	
	if(borderadjust == null) borderadjust = 0;
	
	if (curObj.offsetParent) 
	{
		curleft = curObj.offsetLeft;
		curtop = curObj.offsetTop;
		
		while (curObj = curObj.offsetParent) 
		{
			curleft += curObj.offsetLeft;
			curtop += curObj.offsetTop;
		}
	}
	this.Top = curtop + borderadjust;
	this.Left = curleft + borderadjust;
	this.Right = this.Left + obj.offsetWidth - borderadjust;
	this.Bottom = this.Top + obj.offsetHeight - borderadjust;
};
Box.prototype.IsPointInBox = function(pt)
{
	if( (pt.X >= this.Left && pt.X <= this.Right) && (pt.Y >= this.Top && pt.Y <= this.Bottom) )
		return true;
		
	return false;
};

/*****************************************************************************************************
	MouseInfo
		Description: 
			Returns information about the mouse, specificaly the x, y, and button clicked
		Input:
			e	- Event to analize for mouse information
		Variables:
			Point	- (see point definition below) X, Y
			Button	- String value, one of 3 possabilities
						left
						middle
						right
		Usage:
			var info = new MouseInfo(event);
			var mouseX = info.Point.X;
			var mouseY = info.Point.Y;
			var mouseButtonClicked = info.Button;
******************************************************************************************************/
function MouseInfo(e)
{
	if (!e) var e = window.event;
	if(e == null) return;

	this.Point = this.MousePos(e);
	this.Button = this.GetMouseButton(e);
}
MouseInfo.prototype.MousePos = function(e)
{
	var posx = 0;
	var posy = 0;
	//var YOffset = (document.all) ? document.body.scrollTop : window.pageYOffset;
	//var XOffset = (document.all) ? document.body.scrollLeft : window.pageXOffset;
	
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;
	}

	var Pos = new Point(posx, posy);
	return Pos;				
};
MouseInfo.prototype.GetMouseButton = function(e)
{
	if (e.which)
		return (e.which < 2) ? "left" : ((e.which == 2) ? "middle" : "right");
	else
		return (e.button < 2) ? "left" : ((e.button == 4) ? "middle" : "right");
};

/*****************************************************************************************************
	Point
		Description:
			Basic class for holding an X and Y co-ordinate.
		Input:
			x		- Horizontal location of the point.
			y		- Vertical location of the point.
		Variables:
			X		- same as x above.
			Y		- same as y above.
		Usage:
			var pt = new Point(12, 29);
			var ptX = pt.X;
			var ptY = pt.Y;
******************************************************************************************************/
function Point(x, y)
{
	this.X = x;
	this.Y = y;
}

function ObjTop(obj)
{
	if(obj == null) return 0;
	var curtop = 0;
	var curObj = obj;
	
	if (curObj.offsetParent) 
	{
		curtop = curObj.offsetTop;
		
		while (curObj = curObj.offsetParent) 
			curtop += curObj.offsetTop;
	}
	
	return curtop;
}

function ObjLeft(obj)
{
	if(obj == null) return 0;
	var curleft = 0;
	var curObj = obj;
	
	if (curObj.offsetParent) 
	{
		curleft = curObj.offsetLeft;
		
		while (curObj = curObj.offsetParent) 
			curleft += curObj.offsetLeft;
	}
	return curleft;
}

function ObjHeight(obj)
{
	var height = -1;
	
	if(typeof(obj.innerHeight) == 'number') 
		height = obj.innerHeight;
	else if(document.documentElement && obj.clientHeight) 
		height = obj.clientHeight;
	else if(document.body && obj.clientHeight) 
		height = document.body.clientHeight;
		
	if(height <= 0) height = 0;
	return height;
}

function ObjWidth(obj)
{
	var width = -1;
	if(typeof(obj.innerWidth) == 'number') 
		width = obj.innerWidth;
	else if(document.documentElement && obj.clientWidth) 
		width = obj.clientWidth;
	else if(document.body && obj.clientWidth) 
		width = obj.clientWidth;
		
	if(width <= 0) width = 0;
	return width;
}

function WindowHeight()
{
	return oWindowHeight(this);
}
function oWindowHeight(obj)
{
	if (typeof (obj.window.innerWidth) == 'number')
		return obj.window.innerHeight;
	else if (obj.document.documentElement && (obj.document.documentElement.clientWidth || obj.document.documentElement.clientHeight))
		return obj.document.documentElement.clientHeight;
	else if (obj.document.body && (obj.document.body.clientWidth || obj.document.body.clientHeight))
		return obj.document.body.clientHeight;

	return obj.document.body.parentNode.scrollHeight;
}

function WindowWidth()
{
	return oWindowWidth(this);
}

function oWindowWidth(obj)
{
	if (typeof (obj.window.innerWidth) == 'number')
		return obj.window.innerWidth;
	else if (obj.document.documentElement && (obj.document.documentElement.clientWidth || obj.document.documentElement.clientHeight))
		return obj.document.documentElement.clientWidth;
	else if (obj.document.body && (obj.document.body.clientWidth || obj.document.body.clientHeight))
		return obj.document.body.clientWidth;

	return obj.document.body.parentNode.scrollWidth;
}

function ScrollTop()
{
	return oScrollTop(this);
}
function oScrollTop(obj)
{
	var pos;

	if (!obj.document.body.scrollTop)
	{
		if (obj.window.pageYOffset)
			pos = obj.window.pageYOffset;
		else
			pos = (obj.document.body.parentElement) ? obj.document.body.parentElement.scrollTop : 0;
	}
	else
		pos = obj.document.body.scrollTop;	
	
	return pos;
}

function ScrollLeft()
{
	return oScrollLeft(this);
}
function oScrollLeft(obj)
{
	var pos;

	if (!obj.document.body.scrollLeft)
	{
		if (obj.window.pageXOffset)
			pos = obj.window.pageXOffset;
		else
			pos = (obj.document.body.parentElement) ? obj.document.body.parentElement.scrollLeft : 0;
	}
	else
		pos = obj.document.body.scrollLeft;
		
	return pos;
}

function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object 
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to 
      // build the message. Message includes i (the object's property name) 
      // then the object's property value on a new line 
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they 
      // click "CANCEL" then quit this level of recursion 
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object 
      if (typeof obj[i] == "object") { 
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}