/**
* Common base classes used globaly.
* Classes included in this file:
*     Padding
*     Border
*     RectangleBorder
*     Font
*     Background
*     Size
*     Point
*     Rectangle
*     BasicEventObjectBase
*     ImageObjectBase
*     ImageIcon
*     ImageButton
*     SimpleControl
*     VisibleControl
*     Control
* Pre-existing objects modified in this file:
*     Utils
* Enumerators included in this file:
*     Direction
*     VerticalAlignment
*     HorizontalAlignment
*     ContentAlignment
*     BorderStyle
*     FontStyle
*     FontVariant
*     FontWeight
*     BackgroundRepeat
*     BackgroundAttachment
*     BackgroundPosition
* This file requires the use of the following files:
*     base.js
**/
Utils.GetBrowserSize = function()
{
	var v_size = new Size(0, 0);
	if(Utils.IsIE) // IE
	{
		v_size.Width = document.documentElement.clientWidth <= 0 ? document.body.clientWidth : document.documentElement.clientWidth;
		v_size.Height = document.documentElement.clientHeight <= 0 ? document.body.clientHeight : document.documentElement.clientHeight;
	}
	else { v_size.Width = window.innerWidth; v_size.Height = window.innerHeight; } // Mozilla browsers.
	return v_size;
}
Utils.GetMouseLocation = function(e)
{
	var v_loc = new Point(0, 0);
	if(e.pageX || e.pageY)
	{
		v_loc.X = e.pageX;
		v_loc.Y = e.pageY;
	}
	else if(e.clientX || e.clientY)
	{
		if(document.body.scrollLeft || document.body.scrollTop)
		{
			v_loc.X = e.clientX + document.body.scrollLeft;
			v_loc.Y = e.clientY + document.body.scrollTop;
		}
		else
		{
			v_loc.X = e.clientX + document.documentElement.scrollLeft;
			v_loc.Y = e.clientY + document.documentElement.scrollTop;
		}
	}
	return v_loc;
}
Utils.GetElementSize = function(p_elementId)
{
	var v_size = new Size(0, 0);
	var v_element = Utils.GetElement(p_elementId);
	if(Utils.IsIE)
	{
		v_size.Width = v_element.offsetWidth;
		v_size.Height = v_element.offsetHeight;
	}
	else
	{
		var v_cs = document.defaultView.getComputedStyle(v_element, '');
		var v_tmp = v_cs.getPropertyValue('width');
		v_size.Width = v_tmp.split('px')[0];
		v_tmp = v_cs.getPropertyValue('height');
		v_size.Height = v_tmp.split('px')[0];
	}
	return v_size;
}
Utils.GetElementBounds = function(p_elementIdOrElement)
{
	var v_bounds = new Rectangle(0, 0, 0, 0);
	var v_element = TypeOf(p_elementIdOrElement) == 'String' ? Utils.GetElement(p_elementIdOrElement) : p_elementIdOrElement;
	v_bounds.X = v_element.offsetLeft;
	v_bounds.Y = v_element.offsetTop;
	v_bounds.Width = v_element.offsetWidth;
	v_bounds.Height = v_element.offsetHeight;
	return v_bounds;
}
Utils.GetPageScrollOffest = function() { return Utils.IsIE ? new Point(document.documentElement.scrollLeft <= 0 ? document.body.scrollLeft : document.documentElement.scrollLeft, document.documentElement.scrollTop <= 0 ? document.body.scrollTop : document.documentElement.scrollTop) : new Point(window.pageXOffset, window.pageYOffset); }
Utils._ToolTipDiv = null;
Utils._ToolTipHideDelayTimer = null;
Utils._ToolTipMouseYOffset = 0;
Utils.ShowToolTipAt = function(p_elementId, p_className, p_x, p_y, p_displayTime) { Utils.ShowToolTipTextAt(Utils.GetElement(p_elementId).innerHTML, p_className, p_x, p_y, p_displayTime); return; }
Utils.ShowToolTipTextAt = function(p_text, p_className, p_x, p_y, p_displayTime)
{
	p_x = TypeOf(p_x) != 'Number' ? 0 : p_x;
	p_y = TypeOf(p_y) != 'Number' ? 0 : p_y;
	p_displayTime = TypeOf(p_displayTime) != 'Number' ? 0 : p_displayTime;
	if(Utils._ToolTipDiv == null)
	{
		Utils._ToolTipDiv = document.createElement('div');
		Utils._ToolTipDiv.setAttribute('id', 'utils_tooltip_div');
		document.body.insertBefore(Utils._ToolTipDiv, document.body.firstChild);
	}
	Utils._ToolTipDiv.innerHTML = p_text;
	Utils._ToolTipDiv.className = TypeOf(p_className) != 'String' ? '' : p_className;
	Utils._ToolTipDiv.style.display = 'block';
	Utils._ToolTipDiv.style.position = 'absolute';
	Utils._ToolTipDiv.style.zIndex = 9999;
	var v_browser_size = Utils.GetBrowserSize();
	var v_element_size = Utils.GetElementSize('utils_tooltip_div');
	// TODO: fix the "infinite loop" that seems to be caused by the following code in Mozilla based browsers.
	// Temp fix is to ignore the auto-adjust for if the tool tip would be displayed outside of the visible client bounds of the browser for any non-IE browser.
	if(Utils.IsIE && p_x + v_element_size.Width > v_browser_size.Width) { Utils._ToolTipDiv.style.left = (p_x - 5 - v_element_size.Width).ToCssString(); }
	else { Utils._ToolTipDiv.style.left = p_x.ToCssString(); }
	if(Utils.IsIE && p_y + Utils._ToolTipMouseYOffset + v_element_size.Height > v_browser_size.Height) { Utils._ToolTipDiv.style.top = (p_y - 5 - v_element_size.Height).ToCssString(); }
	else { Utils._ToolTipDiv.style.top = (p_y + Utils._ToolTipMouseYOffset).ToCssString(); }
	// End bug fix TODO.
	if(p_displayTime > 0) { Utils._ToolTipHideDelayTimer = setTimeout('Utils._InternalToolTipHide();', p_displayTime); }
	return;
}
Utils.ShowToolTipText = function(p_event, p_text, p_className, p_displayTime, p_xOffset, p_yOffset)
{
	Utils._ToolTipMouseYOffset = 18;
	p_xOffset = TypeOf(p_xOffset) != 'Number' ? 0 : p_xOffset;
	p_yOffset = TypeOf(p_yOffset) != 'Number' ? 0 : p_yOffset;
	var v_mouse_loc = Utils.GetMouseLocation(p_event);
	Utils.ShowToolTipTextAt(p_text, p_className, v_mouse_loc.X + p_xOffset, v_mouse_loc.Y + p_yOffset, p_displayTime);
	return;
}
Utils.ShowToolTip = function(p_event, p_elementId, p_className, p_displayTime, p_xOffset, p_yOffset) { Utils.ShowToolTipText(p_event, Utils.GetElement(p_elementId).innerHTML, p_className, p_displayTime, p_xOffset, p_yOffset); return; }
Utils.HideToolTip = function(p_delay)
{
	if(Utils._ToolTipHideDelayTimer != null)
	{
		clearTimeout(Utils._ToolTipHideDelayTimer);
		Utils._ToolTipHideDelayTimer = null;
	}
	p_delay = TypeOf(p_delay) != 'Number' ? 0 : p_delay;
	if(p_delay > 0) { setTimeout('Utils._InternalToolTipHide();', p_delay); }
	else { Utils._InternalToolTipHide(); }
	return;
}
Utils._InternalToolTipHide = function()
{
	Utils._ToolTipMouseYOffset = 0;
	if(Utils._ToolTipDiv != null)
	{
		document.body.removeChild(Utils._ToolTipDiv);
		Utils._ToolTipDiv = null;
		Utils._ToolTipCurrentVisible = null;
	}
	return;
}
/**************************************************************************/
Direction = {};
Direction.Horizontal = 1;
Direction.Vertical = 2;
VerticalAlignment = {};
VerticalAlignment.Top    = 'top';
VerticalAlignment.Middle = 'middle';
VerticalAlignment.Bottom = 'bottom';
HorizontalAlignment = {};
HorizontalAlignment.Left   = 'left';
HorizontalAlignment.Center = 'center';
HorizontalAlignment.Right  = 'right';
ContentAlignment = {};
ContentAlignment.BottomCenter = 1;
ContentAlignment.BottomLeft   = 2;
ContentAlignment.BottomRight  = 3;
ContentAlignment.MiddleCenter = 4;
ContentAlignment.MiddleLeft   = 5;
ContentAlignment.MiddleRight  = 6;
ContentAlignment.TopCenter    = 7;
ContentAlignment.TopLeft      = 8;
ContentAlignment.TopRight     = 9;
ContentAlignment.CreateCssString = function(p_contentAlignment)
{
	if(!p_contentAlignment) { throw ArgumentNullException('p_contentAlignment'); }

	switch(p_contentAlignment)
	{
		case ContentAlignment.BottomCenter: return 'text-align: center; vertical-align: bottom;'; break;
		case ContentAlignment.BottomLeft:   return 'text-align: left; vertical-align: bottom;'; break;
		case ContentAlignment.BottomRight:  return 'text-align: right; vertical-align: bottom;'; break;
		case ContentAlignment.MiddleCenter: return 'text-align: center; vertical-align: middle;'; break;
		case ContentAlignment.MiddleLeft:   return 'text-align: left; vertical-align: middle;'; break;
		case ContentAlignment.MiddleRight:  return 'text-align: right; vertical-align: middle;'; break;
		case ContentAlignment.TopCenter:    return 'text-align: center; vertical-align: top;'; break;
		case ContentAlignment.TopLeft:      return 'text-align: left; vertical-align: top;'; break;
		case ContentAlignment.TopRight:     return 'text-align: right; vertical-align: top;'; break;
		default: throw InvalidArgumentException('p_contentAlignment'); break;
	}
	return '';
}
ContentAlignment.SetCssDomProperties = function(p_element, p_contentAlignment)
{
	if(!p_element) { throw ArgumentNullException('p_element'); }
	if(!p_contentAlignment) { throw ArgumentNullException('p_contentAlignment'); }

	switch(p_contentAlignment)
	{
		case ContentAlignment.BottomCenter:
			p_element.style.textAlign = 'center';
			p_element.style.verticalAlign = 'bottom';
			break;
		case ContentAlignment.BottomLeft:
			p_element.style.textAlign = 'left';
			p_element.style.verticalAlign = 'bottom';
			break;
		case ContentAlignment.BottomRight:
			p_element.style.textAlign = 'right';
			p_element.style.verticalAlign = 'bottom';
			break;
		case ContentAlignment.MiddleCenter:
			p_element.style.textAlign = 'center';
			p_element.style.verticalAlign = 'middle';
			break;
		case ContentAlignment.MiddleLeft:
			p_element.style.textAlign = 'left';
			p_element.style.verticalAlign = 'middle';
			break;
		case ContentAlignment.MiddleRight:
			p_element.style.textAlign = 'right';
			p_element.style.verticalAlign = 'middle';
			break;
		case ContentAlignment.TopCenter:
			p_element.style.textAlign = 'center';
			p_element.style.verticalAlign = 'top';
			break;
		case ContentAlignment.TopLeft:
			p_element.style.textAlign = 'left';
			p_element.style.verticalAlign = 'top';
			break;
		case ContentAlignment.TopRight:
			p_element.style.textAlign = 'right';
			p_element.style.verticalAlign = 'top';
			break;
		default:
			p_element.style.textAlign = '';
			p_element.style.verticalAlign = '';
			throw InvalidArgumentException('p_contentAlignment');
			break;
	}
	return;
}
/**************************************************************************/
function Padding(p_allOrTop, p_right, p_bottom, p_left)
{
	this.Top    = 0;
	this.Right  = 0;
	this.Bottom = 0;
	this.Left   = 0;
	this.Set(p_allOrTop, p_right, p_bottom, p_left);
	return;
}
Padding.prototype.Set = function(p_allOrTop, p_right, p_bottom, p_left)
{
	if((TypeOf(p_allOrTop) == 'Number' || TypeOf(p_allOrTop) == 'String')
		&& !(TypeOf(p_right) == 'Number' || TypeOf(p_right) == 'String')
		&& !(TypeOf(p_bottom) == 'Number' || TypeOf(p_bottom) == 'String')
		&& !(TypeOf(p_left) == 'Number' || TypeOf(p_left) == 'String'))
	{
		this.Top = this.Right = this.Bottom = this.Left = Utils.GetIntValue(p_allOrTop);
	}
	else if((TypeOf(p_allOrTop) == 'Number' || TypeOf(p_allOrTop) == 'String')
		&& (TypeOf(p_right) == 'Number' || TypeOf(p_right) == 'String')
		&& (TypeOf(p_bottom) == 'Number' || TypeOf(p_bottom) == 'String')
		&& (TypeOf(p_left) == 'Number' || TypeOf(p_left) == 'String'))
	{
		this.Top    = Utils.GetIntValue(p_allOrTop);
		this.Right  = Utils.GetIntValue(p_right);
		this.Bottom = Utils.GetIntValue(p_bottom);
		this.Left   = Utils.GetIntValue(p_left);
	}
	return;
}
Padding.prototype.ToCssString = function() { return this.Top.ToCssString() + ' ' + this.Right.ToCssString() + ' ' + this.Bottom.ToCssString() + ' ' + this.Left.ToCssString(); }
Padding.prototype.toString = function() { return this.ToString(); }
Padding.prototype.ToString = function() { return '[top=' + this.Top.toString() + ',right=' + this.Right.toString() + ',bottom=' + this.Bottom.toString() + ',left=' + this.Left.toString() + ']'; }
Padding.prototype.GetType = function() { return 'Padding'; }
Padding.prototype.GetHashCode = function() { return this.Top + this.Right + this.Bottom + this.Left; }
Padding.prototype.CopyTo = function(p_value) { p_value.Set(this.Top, this.Right, this.Bottom, this.Left); return; }
/**************************************************************************/
BorderStyle = {}
BorderStyle.None   = 'none';
BorderStyle.Hidden = 'hidden';
BorderStyle.Dotted = 'dotted';
BorderStyle.Dashed = 'dashed';
BorderStyle.Solid  = 'solid';
BorderStyle.Double = 'double';
BorderStyle.Groove = 'groove';
BorderStyle.Ridge  = 'ridge';
BorderStyle.Inset  = 'inset';
BorderStyle.Outset = 'outset';
function Border(p_width, p_style, p_color)
{
	this.Width = 0;
	this.Style = BorderStyle.Solid;
	this.Color = '#000000';
	this.Set(p_width, p_style, p_color);
	return;
}
Border.prototype.Set = function(p_width, p_style, p_color)
{
	if(TypeOf(p_width) == 'Number' || TypeOf(p_width) == 'String') { this.Width = Utils.GetIntValue(p_width); }
	if(p_style) { this.Style = p_style; }
	if(p_color) { this.Color = p_color; }
	return;
}
Border.prototype.ToCssString = function() { return this.Width.ToCssString() + ' ' + this.Style + ' ' + this.Color; }
Border.prototype.toString = function() { return this.ToString(); }
Border.prototype.ToString = function() { return '[width=' + this.Width.toString() + ',style=' + this.Style + ',color=' + this.Color + ']'; }
Border.prototype.GetType = function() { return 'Border'; }
Border.prototype.GetHashCode = function() { return this.Width.toString() + this.Style + this.Color; }
Border.prototype.CopyTo = function(p_value) { p_value.Set(this.Width, this.Style, this.Color); return; }
/**************************************************************************/
function RectangleBorder(p_width, p_style, p_color)
{
	this.Top    = new Border(p_width, p_style, p_color);
	this.Bottom = new Border(p_width, p_style, p_color);
	this.Left   = new Border(p_width, p_style, p_color);
	this.Right  = new Border(p_width, p_style, p_color);
	return;
}
RectangleBorder.prototype.Set = function(p_width, p_style, p_color)
{
	this.Top.Set(p_width, p_style, p_color);
	this.Bottom.Set(p_width, p_style, p_color);
	this.Left.Set(p_width, p_style, p_color);
	this.Right.Set(p_width, p_style, p_color);
	return;
}
RectangleBorder.prototype.SetCssDomProperties = function(p_element)
{
	p_element.style.borderTop    = this.Top.ToCssString();
	p_element.style.borderBottom = this.Bottom.ToCssString();
	p_element.style.borderLeft   = this.Left.ToCssString();
	p_element.style.borderRight  = this.Right.ToCssString();
	return;
}
RectangleBorder.prototype.ToCssString = function() { return 'border-top: ' + this.Top.ToCssString() + '; border-bottom: ' + this.Bottom.ToCssString() + '; border-left: ' + this.Left.ToCssString() + '; border-right: ' + this.Right.ToCssString() + ';'; }
RectangleBorder.prototype.toString = function() { return this.ToString(); }
RectangleBorder.prototype.ToString = function() { return 'Top=' + this.Top.ToString() + '\nBottom=' + this.Bottom.ToString() + '\nLeft=' + this.Left.ToString() + '\nRight=' + this.Right.ToString(); }
RectangleBorder.prototype.GetType = function() { return 'RectangleBorder'; }
RectangleBorder.prototype.GetHashCode = function() { return this.Top.GetHashCode() + this.Right.GetHashCode() + this.Bottom.GetHashCode() + this.Left.GetHashCode(); }
RectangleBorder.prototype.CopyTo = function(p_value) { this.Top.CopyTo(p_value.Top); this.Bottom.CopyTo(p_value.Bottom); this.Left.CopyTo(p_value.Left); this.Right.CopyTo(p_value.Right); return; }
/**************************************************************************/
FontStyle = {}
FontStyle.Normal  = 'normal';
FontStyle.Italic  = 'italic';
FontStyle.Oblique = 'oblique';
FontVariant = {}
FontVariant.Normal    = 'normal';
FontVariant.SmallCaps = 'small-caps';
FontWeight = {}
FontWeight.Normal  = 'normal';
FontWeight.Bold    = 'bold';
FontWeight.Bolder  = 'bolder';
FontWeight.Lighter = 'lighter';
function Font(p_family, p_size, p_weight, p_style, p_variant)
{
	this.Family  = 'verdana';
	this.Size    = '12px';
	this.Style   = FontStyle.Normal;
	this.Variant = FontVariant.Normal;
	this.Weight  = FontWeight.Normal;
	this.Set(p_family, p_size, p_weight, p_style, p_variant)
	return;
}
Font.prototype.Set = function(p_family, p_size, p_weight, p_style, p_variant)
{
	if(p_family) { this.Family = p_family; }
	if(p_size) { this.Size = p_size; }
	if(p_style) { this.Style = p_style; }
	if(p_variant) { this.Variant = p_variant; }
	if(p_weight) { this.Weight = p_weight; }
	return;
}
Font.prototype.ToCssString = function() { return this.Style + ' ' + this.Variant + ' ' + this.Weight + ' ' + this.Size + ' ' + this.Family; }
Font.prototype.toString = function() { return this.ToString(); }
Font.prototype.ToString = function() { return '[style=' + this.Style + ',variant=' + this.Variant + ',weight=' + this.Weight + ',size=' + this.Size + ',family=' + this.Family + ']'; }
Font.prototype.GetType = function() { return 'Font'; }
Font.prototype.GetHashCode = function() { return this.Family + this.Size + this.Style + this.Variant + this.Weight; }
Font.prototype.CopyTo = function(p_value) { p_value.Set(this.Family, this.Size, this.Weight, this.Style, this.Variant); return; }
/**************************************************************************/
BackgroundRepeat = {}
BackgroundRepeat.Both       = 'repeat';
BackgroundRepeat.Horizontal = 'repeat-x';
BackgroundRepeat.Vertical   = 'repeat-y';
BackgroundRepeat.None       = 'no-repeat';
BackgroundAttachment = {}
BackgroundAttachment.Scroll = 'scroll';
BackgroundAttachment.Fixed  = 'fixed';
BackgroundPosition = {}
BackgroundPosition.TopLeft      = 'top left';
BackgroundPosition.TopMiddle    = 'top center';
BackgroundPosition.TopRight     = 'top right';
BackgroundPosition.MiddleLeft   = 'center left';
BackgroundPosition.Middle       = 'center center';
BackgroundPosition.MiddleRight  = 'center right';
BackgroundPosition.BottomLeft   = 'bottom left';
BackgroundPosition.BottomMiddle = 'bottom center';
BackgroundPosition.BottomRight  = 'bottom right';
function Background(p_color, p_image, p_repeat, p_position, p_attachment)
{
	this.Color      = 'transparent';
	this.BGImage    = 'none';
	this.Repeat     = BackgroundRepeat.Both;
	this.Position   = BackgroundPosition.TopLeft;
	this.Attachment = BackgroundAttachment.Scroll;
	this.Set(p_color, p_image, p_repeat, p_position, p_attachment);
	return;
}
Background.prototype.Set = function(p_color, p_image, p_repeat, p_position, p_attachment)
{
	if(p_color) { this.Color = p_color; }
	if(p_image) { this.BGImage = p_image; }
	if(p_repeat) { this.Repeat = p_repeat; }
	if(p_position) { this.Position = p_position; }
	if(p_attachment) { this.Attachment = p_attachment; }
	return;
}
Background.prototype.ToCssString = function() { return this.Color + ' ' + this.BGImage + ' ' + this.Repeat + ' ' + this.Attachment + ' ' + this.Position; }
Background.prototype.toString = function() { return this.ToString(); }
Background.prototype.ToString = function() { return '[color=' + this.Color + ',image=' + this.BGImage + ',repeat=' + this.Repeat + ',attachmet=' + this.Attachment + ',position=' + this.Position + ']'; }
Background.prototype.GetType = function() { return 'Background'; }
Background.prototype.GetHashCode = function() { return this.Color + this.BGImage + this.Repeat + this.Position + this.Attachment; }
Background.prototype.CopyTo = function(p_value) { p_value.Set(this.Color, this.BGImage, this.Repeat, this.Position, this.Attachment); return; }
/**************************************************************************/
function Size(p_width, p_height)
{
	this.Width  = 0;
	this.Height = 0;
	this.Set(p_width, p_height);
	return;
}
Size.prototype.Set = function(p_width, p_height)
{
	if((TypeOf(p_width) == 'Number' || TypeOf(p_width) == 'String') && (TypeOf(p_height) == 'Number' || TypeOf(p_height) == 'String'))
	{
		this.Width  = Utils.GetIntValue(p_width);
		this.Height = Utils.GetIntValue(p_height);
	}
	return;
}
Size.prototype.ToAttributeString = function()
{
	var v_text = '';
	if(this.Width > 0) { v_text += ' width="' + this.Width.toString() + '"'; }
	if(this.Height > 0) { v_text += ' height="' + this.Height.toString() + '"'; }
	return v_text;
}
Size.prototype.ToCssString = function()
{
	var v_text = '';
	if(this.Width > 0) { v_text += ' width: ' + this.Width.ToCssString() + ';'; }
	if(this.Height > 0) { v_text += ' height: ' + this.Height.ToCssString() + ';'; }
	return v_text;
}
Size.prototype.toString = function() { return this.ToString(); }
Size.prototype.ToString = function() { return '[width=' + this.Width.toString() + ',height=' + this.Height.toString() + ']'; }
Size.prototype.GetType = function() { return 'Size'; }
Size.prototype.GetHashCode = function() { return this.Width + this.Height; }
Size.prototype.CopyTo = function(p_value) { p_value.Set(this.Width, this.Height); return; }
/**************************************************************************/
function Point(p_x, p_y)
{
	this.X = 0;
	this.Y = 0;
	this.Set(p_x, p_y);
	return;
}
Point.prototype.Set = function(p_x, p_y)
{
	if((TypeOf(p_x) == 'Number' || TypeOf(p_x) == 'String') && (TypeOf(p_y) == 'Number' || TypeOf(p_y) == 'String'))
	{
		this.X = parseInt(p_x);
		this.Y = parseInt(p_y);
	}
	return;
}
Point.prototype.ToCssString = function() { return ' left: ' + this.X.ToCssString() + '; top: ' + this.Y.ToCssString() + ';'; }
Point.prototype.toString = function() { return this.ToString(); }
Point.prototype.ToString = function() { return '(' + this.X.toString() + ',' + this.Y.toString() + ')'; }
Point.prototype.GetType = function() { return 'Point'; }
Point.prototype.GetHashCode = function() { return this.X + this.Y; }
Point.prototype.CopyTo = function(p_value) { p_value.Set(this.X, this.Y); return; }
/**************************************************************************/
function Rectangle(p_x, p_y, p_width, p_height)
{
	this.X      = 0;
	this.Y      = 0;
	this.Width  = 0;
	this.Height = 0;
	this.Set(p_x, p_y, p_width, p_height);
	return;
}
Rectangle.prototype.Set = function(p_x, p_y, p_width, p_height)
{
	if((TypeOf(p_x) == 'Number' || TypeOf(p_x) == 'String') && (TypeOf(p_y) == 'Number' || TypeOf(p_y) == 'String') && (TypeOf(p_width) == 'Number' || TypeOf(p_width) == 'String') && (TypeOf(p_height) == 'Number' || TypeOf(p_height) == 'String'))
	{
		this.X      = parseInt(p_x);
		this.Y      = parseInt(p_y);
		this.Width  = Utils.GetIntValue(p_width);
		this.Height = Utils.GetIntValue(p_height);
	}
	return;
}
Rectangle.prototype.SetSize = function(p_sizeOrWidth, p_height)
{
	if(TypeOf(p_sizeOrWidth) == 'Number') { this.Set(this.X, this.Y, p_sizeOrWidth, p_height); }
	else if(TypeOf(p_sizeOrWidth) == 'Size') { this.Set(this.X, this.Y, p_sizeOrWidth.Width, p_sizeOrWidth.Height); }
	else { throw InvalidArgumentException('p_sizeOrWidth'); }
	return;
}
Rectangle.prototype.SetLocation = function(p_pointOrX, p_y)
{
	if(TypeOf(p_pointOrX) == 'Number') { this.Set(p_pointOrX, p_y, this.Width, this.Height); }
	else if(TypeOf(p_pointOrX) == 'Point') { this.Set(p_pointOrX.X, p_pointOrX.Y, this.Width, this.Height); }
	else { throw InvalidArgumentException('p_sizeOrWidth'); } 
	return;
}
Rectangle.prototype.Size     = function() { return new Size(this.Width, this.Height); }
Rectangle.prototype.Location = function() { return new Point(this.X, this.Y); }
Rectangle.prototype.Top      = function() { return this.Y; }
Rectangle.prototype.Bottom   = function() { return this.Y + this.Height; }
Rectangle.prototype.Left     = function() { return this.X; }
Rectangle.prototype.Right    = function() { return this.X + this.Width; }
Rectangle.prototype.ContainsPoint = function(p_x, p_y) { return (this.X <= p_x) && (p_x < this.X + this.Width) && (this.Y <= p_y) && (p_y < this.Y + this.Height); }
Rectangle.prototype.ContainsRectangle = function(p_rectangle) { return (this.X <= p_rectangle.X) && (p_rectangle.X + p_rectangle.Width <= this.X + this.Width) && (this.Y <= p_rectangle.Y) && (p_rectangle.Y + p_rectangle.Height <= this.Y + this.Height); }
Rectangle.prototype.Inflate = function(p_sizeOrWidth, p_height)
{
	if(TypeOf(p_sizeOrWidth) == 'Number')
	{
		this.X -= p_sizeOrWidth;
		this.Y -= p_height;
		this.Width += 2 * p_sizeOrWidth;
		this.Height += 2 * p_height;
	}
	else if(TypeOf(p_sizeOrWidth) == 'Size')
	{
		this.X -= p_sizeOrWidth.Width;
		this.Y -= p_sizeOrWidth.Height;
		this.Width += 2 * p_sizeOrWidth.Width;
		this.Height += 2 * p_sizeOrWidth.Height;
	}
	else { throw InvalidArgumentException('p_sizeOrWidth'); }
	return;
}
Rectangle.prototype.Offset = function(p_pointOrX, p_y)
{
	if(TypeOf(p_pointOrX) == 'Number')
	{
		this.X += p_pointOrX;
		this.Y += p_y;
	}
	else if(TypeOf(p_sizeOrWidth) == 'Point')
	{
		this.X += p_pointOrX.X;
		this.Y += p_pointOrX.Y;
	}
	else { throw InvalidArgumentException('p_pointOrX'); }
	return;
}
Rectangle.prototype.Intersect = function(p_rectangle)
{
	var v_x = Math.max(this.X, p_rectangle.X);
	var v_w = Math.min(this.X + this.Width, p_rectangle.X + p_rectangle.Width);
	var v_y = Math.max(this.Y, p_rectangle.Y);
	var v_h = Math.min(this.Y + this.Height, p_rectangle.Y + p_rectangle.Height);
	if(v_w >= v_x && v_h >= v_y) { this.Set(v_x, v_y, v_w - v_x, v_h - v_y); }
	this.Set(0, 0, 0, 0);
	return;
}
Rectangle.prototype.IntersectsWith = function(p_rectangle) { return (p_rectangle.X < this.X + this.Width) && (this.X < p_rectangle.X + p_rectangle.Width) && (p_rectangle.Y < this.Y + this.Height) && (this.Y < p_rectangle.Y + p_rectangle.Height); }
Rectangle.prototype.ToCssString = function()
{
	var v_text = '';
	v_text += ' left: ' + this.X.ToCssString() + ';';
	v_text += ' top: ' + this.Y.ToCssString() + ';';
	if(this.Width > 0) { v_text += ' width: ' + this.Width.ToCssString() + ';'; }
	if(this.Height > 0) { v_text += ' height: ' + this.Height.ToCssString() + ';'; }
	return v_text;
}
Rectangle.prototype.toString = function() { return this.ToString(); }
Rectangle.prototype.ToString = function() { return '{X=' + this.X.toString() + ',Y=' + this.Y.toString() + ',Width=' + this.Width.toString() + ',Height=' + this.Height.toString() + '}'; }
Rectangle.prototype.GetType = function() { return 'Rectangle'; }
Rectangle.prototype.GetHashCode = function() { return this.X + this.Y + this.Width + this.Height; }
Rectangle.prototype.CopyTo = function(p_value) { p_value.Set(this.X, this.Y, this.Width, this.Height); return; }
/**************************************************************************/
function BasicEventObjectBase()
{
	this.Click       = null;
	this.DoubleClick = null;
	this.MouseDown   = null;
	this.MouseUp     = null;
	this.MouseOver   = null;
	this.MouseMove   = null;
	this.MouseOut    = null;
	this.KeyPress    = null;
	this.KeyDown     = null;
	this.KeyUp       = null;
	return;
}
BasicEventObjectBase.prototype.ToString = function() { return this.GetType(); }
BasicEventObjectBase.prototype.toString = function() { return this.ToString(); }
BasicEventObjectBase.prototype.GetType = function() { return 'BasicEventObjectBase'; }
BasicEventObjectBase.prototype.GetHashCode = function() { return ''; }
BasicEventObjectBase.prototype.OnClick = function(e, p_element) { if(this.Click) { this.Click(e, this); } return; }
BasicEventObjectBase.prototype.OnDoubleClick = function(e, p_element) { if(this.DoubleClick) { this.DoubleClick(e, this); } return; }
BasicEventObjectBase.prototype.OnMouseDown = function(e, p_element) { if(this.MouseDown) { this.MouseDown(Utils.GetMouseLocation(e), e, this); } return; }
BasicEventObjectBase.prototype.OnMouseUp = function(e, p_element) { if(this.MouseUp) { this.MouseUp(Utils.GetMouseLocation(e), e, this); } return; }
BasicEventObjectBase.prototype.OnMouseOver = function(e, p_element) { if(this.MouseOver) { this.MouseOver(e, this); } return; }
BasicEventObjectBase.prototype.OnMouseMove = function(e, p_element) { if(this.MouseMove) { this.MouseMove(Utils.GetMouseLocation(e), e, this); } return; }
BasicEventObjectBase.prototype.OnMouseOut = function(e, p_element) { if(this.MouseOut) { this.MouseOut(e, this); } return; }
BasicEventObjectBase.prototype.OnKeyPress = function(e, p_element) { if(this.KeyPress) { this.KeyPress(e, this); } return; }
BasicEventObjectBase.prototype.OnKeyDown = function(e, p_element) { if(this.KeyDown) { this.KeyDown(e, this); } return; }
BasicEventObjectBase.prototype.OnKeyUp = function(e, p_element) { if(this.KeyUp) { this.KeyUp(e, this); } return; }
/**************************************************************************/
function ImageObjectBase(p_visible, p_titleText, p_altText, p_cursor, p_id)
{
	ImageObjectBase.baseConstructor.call(this);
	this.Id        = String(p_id);
	this.Visible   = p_visible;
	this.Size      = new Size(0, 0);
	this.AltText   = String(p_altText);
	this.TitleText = String(p_titleText);
	this.Cursor    = String(p_cursor);
	this.Padding   = new Padding(0, 0, 0, 0);
	this.Parent    = null;
	return;
}
Extend(ImageObjectBase, BasicEventObjectBase);
ImageObjectBase.prototype.SetCursor = function(p_cursor)
{
	if(TypeOf(p_cursor) != 'String') { throw InvalidArgumentException('p_cursor'); }
	this.Cursor = p_cursor;
	if(this.Visible) { Utils.GetElement(this.Id).style.cursor = this.Cursor; }
	return;
}
ImageObjectBase.prototype.Refresh = function()
{
	if(this.Visible == true && this.Id && this.Id.length > 0)
	{
		var v_element = document.getElementById(this.Id);
		if(v_element != null)
		{
			this.RefreshImageObject(v_element);
		}
	}
	return;
}
ImageObjectBase.prototype.Render = function(p_renderElementId, p_onClick, p_onDoubleClick, p_onMouseDown, p_onMouseUp, p_onMouseOver, p_onMouseMove, p_onMouseOut, p_onKeyPress, p_onKeyDown, p_onKeyUp)
{
	var v_element = document.getElementById(p_renderElementId);
	if(v_element != null)
	{
		v_element.innerHTML = this.GetRenderHtml(p_onClick, p_onDoubleClick, p_onMouseDown, p_onMouseUp, p_onMouseOver, p_onMouseMove, p_onMouseOut, p_onKeyPress, p_onKeyDown, p_onKeyUp);
	}
	else
	{
		throw Exception('ImageObjectBase.Render() -> NULL render element!');
	}
	return;
}
ImageObjectBase.prototype.ToString = function() { return this.GetRenderHtml(); }
ImageObjectBase.prototype.GetType = function() { return 'ImageObjectBase'; }
ImageObjectBase.prototype.GetHashCode = function() { return this.Id; }
ImageObjectBase.prototype.RefreshImageObject = function(p_element) { return; }
ImageObjectBase.prototype.GetRenderHtml = function(p_onClick, p_onDoubleClick, p_onMouseDown, p_onMouseUp, p_onMouseOver, p_onMouseMove, p_onMouseOut, p_onKeyPress, p_onKeyDown, p_onKeyUp) { return ''; }
/**************************************************************************/
function ImageIcon(p_icon, p_altText, p_titleText)
{
	ImageIcon.baseConstructor.call(this, false, p_titleText, p_altText, 'default', '');
	this.Icon = !p_icon ? '' : String(p_icon);
	return;
}
Extend(ImageIcon, ImageObjectBase);
ImageIcon.prototype.GetType = function() { return 'ImageIcon'; }
ImageIcon.prototype.GetHashCode = function() { return this.Icon; }
ImageIcon.prototype.RefreshImageObject = function(p_element)
{
	p_element.src = this.Icon;
	p_element.title = this.TitleText;
	p_element.alt = this.AltText;
	p_element.style.width = this.Size.Width.ToCssString();
	p_element.style.height = this.Size.Height.ToCssString();
	p_element.style.cursor = this.Cursor;
	p_element.style.padding = this.Padding.ToCssString();
	return;
}
ImageIcon.prototype.GetRenderHtml = function(p_onClick, p_onDoubleClick, p_onMouseDown, p_onMouseUp, p_onMouseOver, p_onMouseMove, p_onMouseOut, p_onKeyPress, p_onKeyDown, p_onKeyUp)
{
	var v_sb = new StringBuilder();
	if(this.Visible == true && this.Icon != null)
	{
		v_sb.Append('<img src="').Append(this.Icon).Append('" border="0" alt="').Append(this.AltText).Append('" title="').Append(this.TitleText).Append('"')
			.Append(this.Size.ToAttributeString())
			.Append(Utils.CreateAttributeString('onclick', p_onClick))
			.Append(Utils.CreateAttributeString('ondblclick', p_onDoubleClick))
			.Append(Utils.CreateAttributeString('onmousemove', p_onMouseMove))
			.Append(Utils.CreateAttributeString('onkeypress', p_onKeyPress))
			.Append(Utils.CreateAttributeString('onkeydown', p_onKeyDown))
			.Append(Utils.CreateAttributeString('onkeyup', p_onKeyUp))
			.Append(Utils.CreateAttributeString('onmouseover', p_onMouseOver))
			.Append(Utils.CreateAttributeString('onmouseout', p_onMouseOut))
			.Append(Utils.CreateAttributeString('onmousedown', p_onMouseDown))
			.Append(Utils.CreateAttributeString('onmouseup', p_onMouseUp))
			.Append(Utils.CreateAttributeString('id', this.Id))
			.Append(Utils.CreateAttributeString('style', Utils.CreateCssPropertyString('padding', this.Padding.ToCssString()) + Utils.CreateCssPropertyString('cursor', this.Cursor)))
			.Append(' />');
	}
	return v_sb.ToString();
}
ImageIcon.prototype.CopyTo = function(p_obj)
{
	this.Size.CopyTo(p_obj.Size);
	this.Padding.CopyTo(p_obj.Padding);
	p_obj.Id        = this.Id;
	p_obj.Visible   = this.Visible;
	p_obj.AltText   = this.AltText;
	p_obj.TitleText = this.TitleText;
	p_obj.Cursor    = this.Cursor;
	p_obj.Icon      = this.Icon;
	return;
}
/**************************************************************************/
function ImageButton(p_titleText, p_altText)
{
	ImageButton.baseConstructor.call(this, true, p_titleText, p_altText, 'default', '');
	this.IconNormal = '';
	this.IconHover  = '';
	this.IconClick  = '';
	this._DivFlag   = false;
	return;
}
Extend(ImageButton, ImageObjectBase);
ImageButton.prototype.SetIcons = function(p_normal, p_hover, p_click)
{
	if(p_normal) { this.IconNormal = String(p_normal); }
	if(p_hover) { this.IconHover = String(p_hover); }
	if(p_click) { this.IconClick = String(p_click); }
	return;
}
ImageButton.prototype.GetType = function() { return 'ImageButton'; }
ImageButton.prototype.GetHashCode = function() { return this.IconNormal + this.IconHover + this.IconClick; }
ImageButton.prototype.RefreshImageObject = function(p_element)
{
	if(this._DivFlag == false)
	{
		p_element.src = this.IconNormal;
		p_element.title = this.TitleText;
		p_element.alt = this.AltText;
		p_element.style.cursor = this.Cursor;
		p_element.style.padding = this.Padding.ToCssString();
		if(this.Size.Width > 0)
		{
			p_element.style.width = this.Size.Width.ToCssString();
		}
		if(this.Size.Height > 0)
		{
			p_element.style.height = this.Size.Height.ToCssString();
		}
	}
	else
	{
		p_element.innerHTML = this.AltText;
		p_element.title = this.TitleText;
		p_element.style.cursor = this.Cursor;
		p_element.style.padding = this.Padding.ToCssString();
		if(this.Size.Width > 0)
		{
			p_element.style.width = this.Size.Width.ToCssString();
		}
		if(this.Size.Height > 0)
		{
			p_element.style.height = this.Size.Height.ToCssString();
		}
	}
	return;
}
ImageButton.prototype.GetRenderHtml = function(p_onClick, p_onDoubleClick, p_onMouseDown, p_onMouseUp, p_onMouseOver, p_onMouseMove, p_onMouseOut, p_onKeyPress, p_onKeyDown, p_onKeyUp)
{
	var v_sb = new StringBuilder();
	if(this.Visible == true)
	{
		var v_attributes = (new StringBuilder(Utils.CreateAttributeString('onclick', p_onClick)))
			.Append(Utils.CreateAttributeString('ondblclick', p_onDoubleClick))
			.Append(Utils.CreateAttributeString('onmousemove', p_onMouseMove))
			.Append(Utils.CreateAttributeString('onkeypress', p_onKeyPress))
			.Append(Utils.CreateAttributeString('onkeydown', p_onKeyDown))
			.Append(Utils.CreateAttributeString('onkeyup', p_onKeyUp))
			.Append(Utils.CreateAttributeString('id', this.Id))
			.Append(Utils.CreateAttributeString('style', Utils.CreateCssPropertyString('padding', this.Padding.ToCssString()) + Utils.CreateCssPropertyString('cursor', this.Cursor)));

		if(this.IconNormal != null && this.IconNormal.length > 0)
		{
			this._DivFlag = false;
			v_sb.Append('<img src="').Append(this.IconNormal).Append('" border="0" alt="').Append(this.AltText).Append('" title="').Append(this.TitleText).Append('"')
				.Append(this.Size.ToAttributeString())
				.Append(v_attributes.ToString())
			if(this.IconHover != null && this.IconHover.length > 0)
			{
				v_sb.Append(Utils.CreateAttributeString('onmouseover', 'this.src = \'' + this.IconHover + '\';' + p_onMouseOver))
					.Append(Utils.CreateAttributeString('onmouseout', 'this.src = \'' + this.IconNormal + '\';' + p_onMouseOut));
			}
			else
			{
				v_sb.Append(Utils.CreateAttributeString('onmouseover', p_onMouseOver))
					.Append(Utils.CreateAttributeString('onmouseout', p_onMouseOut));
			}

			if(this.IconClick != null && this.IconClick.length > 0)
			{
				v_sb.Append(Utils.CreateAttributeString('onmousedown', 'this.src = \'' + this.IconClick + '\';' + p_onMouseDown))
					.Append(Utils.CreateAttributeString('onmouseup', 'this.src = \'' + this.IconNormal + '\';' + p_onMouseUp));
			}
			else
			{
				v_sb.Append(Utils.CreateAttributeString('onmousedown', p_onMouseDown))
					.Append(Utils.CreateAttributeString('onmouseup', p_onMouseUp));
			}
			v_sb.Append(' />');
		}
		else
		{
			this._DivFlag = true;
			v_sb.Append('<div title="').Append(this.TitleText).Append('"')
				.Append(v_attributes.ToString())
				.Append(Utils.CreateAttributeString('onmousedown', p_onMouseDown))
				.Append(Utils.CreateAttributeString('onmouseup', p_onMouseUp))
				.Append(Utils.CreateAttributeString('onmouseover', p_onMouseOver))
				.Append(Utils.CreateAttributeString('onmouseout', p_onMouseOut))
				.Append('>').Append(this.AltText).Append('</div>');
		}
	}
	return v_sb.ToString();
}
/**************************************************************************/
function SimpleControl(p_elementId, p_instanceName)
{
	SimpleControl.baseConstructor.call(this);
	if(!p_elementId || p_elementId.length <= 0) { throw ArgumentNullException('p_elementId'); }
	if(!p_instanceName || p_instanceName.length <= 0) { throw ArgumentNullException('p_instanceName'); }
	if(TypeOf(p_elementId) != 'String') { throw InvalidArgumentException('p_elementId'); }
	if(TypeOf(p_instanceName) != 'String') { throw InvalidArgumentException('p_instanceName'); }
	this.ElementId    = String(p_elementId);
	this.Name         = String(p_instanceName);
	this.Size         = this.DefaultSize();
	this.Border       = this.DefaultBorder();
	this.Background   = this.DefaultBackground();
	this.Padding      = this.DefaultPadding();
	this.Font         = this.DefaultFont();
	this.ForeColor    = this.DefaultForeColor();
	this.Cursor       = this.DefaultCursor();
	this.TextAlign    = this.DefaultTextAlign();
	this.Text         = '';
	this.ToolTipText  = '';
	this.CssClassName = '';
	this.Identifier   = null;
	this.Parent       = null;
	this.IsRendered   = false;
	return;
}
Extend(SimpleControl, BasicEventObjectBase);
SimpleControl.prototype.GetType = function() { return 'SimpleControl'; }
SimpleControl.prototype.GetHashCode = function() { return this.Name; }
SimpleControl.prototype.ToString = function() { return this.Name; }
SimpleControl.prototype.DefaultSize = function() { return new Size(100, 100); }
SimpleControl.prototype.DefaultBorder = function() { return new RectangleBorder(1, BorderStyle.Solid, '#000000'); }
SimpleControl.prototype.DefaultBackground = function() { return new Background('#FFFFFF'); }
SimpleControl.prototype.DefaultPadding = function() { return new Padding(0, 0, 0, 0); }
SimpleControl.prototype.DefaultFont = function() { return new Font('verdana', '12px'); }
SimpleControl.prototype.DefaultForeColor = function() { return '#000000'; }
SimpleControl.prototype.DefaultCursor = function() { return 'default'; }
SimpleControl.prototype.DefaultTextAlign = function() { return ContentAlignment.MiddleCenter; }
SimpleControl.prototype.Refresh = function()
{
	if(this.IsRendered == true)
	{
		var v_element = Utils.GetElement(this.ElementId);
		v_element.innerHTML = this.Text;
		this.SetCssDomProperties(v_element);
	}
	return;
}
SimpleControl.prototype.Render = function()
{
	var v_element = Utils.GetElement(this.ElementId);
	v_element.innerHTML = this.Text;
	this.SetCssDomProperties(v_element);
	this.AttatchEventsToElement(v_element);
	this.IsRendered = true;
	return;
}
SimpleControl.prototype.SetCursor = function(p_cursor)
{
	if(TypeOf(p_cursor) != 'String') { throw InvalidArgumentException('p_cursor'); }
	this.Cursor = p_cursor;
	if(this.IsRendered) { Utils.GetElement(this.ElementId).style.cursor = this.Cursor; }
	return;
}
SimpleControl.prototype.SetCssDomProperties = function(p_element)
{
	this.SetElementSize(p_element);
	this.Border.SetCssDomProperties(p_element);
	p_element.style.background = this.Background.ToCssString();
	p_element.style.padding    = this.Padding.ToCssString();
	p_element.style.font       = this.Font.ToCssString();
	p_element.style.color      = this.ForeColor;
	p_element.style.cursor     = this.Cursor;
	ContentAlignment.SetCssDomProperties(p_element, this.TextAlign);
	p_element.title     = this.ToolTipText;
	p_element.className = this.CssClassName;
	return;
}
SimpleControl.prototype.SetElementSize = function(p_element)
{
	p_element.style.width  = (this.Size.Width > 0) ? this.Size.Width.ToCssString() : '';
	p_element.style.height = (this.Size.Height > 0) ? this.Size.Height.ToCssString() : '';
	return;
}
SimpleControl.prototype.GetSizeStyleString = function(p_stringBuilder)
{
	p_stringBuilder.Append(Utils.CreateCssPropertyString('width', (this.Size.Width > 0) ? this.Size.Width.ToCssString() : '100%'))
		.Append(Utils.CreateCssPropertyString('height', (this.Size.Height > 0) ? this.Size.Height.ToCssString() : '100%'))
	return;
}
SimpleControl.prototype.GetBorderStyleString = function(p_stringBuilder) { p_stringBuilder.Append(this.Border.ToCssString()); return; }
SimpleControl.prototype.GetStyleString = function(p_stringBuilder)
{
	this.GetSizeStyleString(p_stringBuilder);
	this.GetBorderStyleString(p_stringBuilder);
	p_stringBuilder.Append(Utils.CreateCssPropertyString('background', this.Background.ToCssString()))
		.Append(Utils.CreateCssPropertyString('padding', this.Padding.ToCssString()))
		.Append(Utils.CreateCssPropertyString('font', this.Font.ToCssString()))
		.Append(Utils.CreateCssPropertyString('color', this.ForeColor))
		.Append(Utils.CreateCssPropertyString('cursor', this.Cursor))
		.Append(ContentAlignment.CreateCssString(this.TextAlign));
	return;
}
SimpleControl.prototype.AttatchEventsToElement = function(p_element)
{
	p_element.setAttribute('onclick',     this.Name + '.OnClick(event,this);');
	p_element.setAttribute('ondblclick',  this.Name + '.OnDoubleClick(event,this);');
	p_element.setAttribute('onmousedown', this.Name + '.OnMouseDown(event,this);');
	p_element.setAttribute('onmouseup',   this.Name + '.OnMouseUp(event,this);');
	p_element.setAttribute('onmouseover', this.Name + '.OnMouseOver(event,this);');
	p_element.setAttribute('onmousemove', this.Name + '.OnMouseMove(event,this);');
	p_element.setAttribute('onmouseout',  this.Name + '.OnMouseOut(event,this);');
	p_element.setAttribute('onkeypress',  this.Name + '.OnKeyPress(event,this);');
	p_element.setAttribute('onkeydown',   this.Name + '.OnKeyDown(event,this);');
	p_element.setAttribute('onkeyup',     this.Name + '.OnKeyUp(event,this);');
	return;
}
SimpleControl.prototype.GetEventAttributeString = function(p_stringBuilder)
{
	p_stringBuilder.Append(Utils.CreateAttributeString('onclick', this.Name + '.OnClick(event,this);'))
		.Append(Utils.CreateAttributeString('ondblclick',  this.Name + '.OnDoubleClick(event,this);'))
		.Append(Utils.CreateAttributeString('onmousemove', this.Name + '.OnMouseMove(event,this);'))
		.Append(Utils.CreateAttributeString('onkeypress',  this.Name + '.OnKeyPress(event,this);'))
		.Append(Utils.CreateAttributeString('onkeydown',   this.Name + '.OnKeyDown(event,this);'))
		.Append(Utils.CreateAttributeString('onkeyup',     this.Name + '.OnKeyUp(event,this);'))
		.Append(Utils.CreateAttributeString('onmouseover', this.Name + '.OnMouseOver(event,this);'))
		.Append(Utils.CreateAttributeString('onmouseout',  this.Name + '.OnMouseOut(event,this);'))
		.Append(Utils.CreateAttributeString('onmousedown', this.Name + '.OnMouseDown(event,this);'))
		.Append(Utils.CreateAttributeString('onmouseup',   this.Name + '.OnMouseUp(event,this);'))
	return;
}
/**************************************************************************/
function VisibleControl(p_elementId, p_instanceName)
{
	VisibleControl.baseConstructor.call(this, p_elementId, p_instanceName);
	this.Visible = true;
	this.VisibleChanged = null;
	return;
}
Extend(VisibleControl, SimpleControl);
VisibleControl.prototype.GetType = function() { return 'VisibleControl'; }
VisibleControl.prototype.OnVisibleChanged = function() { if(this.VisibleChanged) { this.VisibleChanged(this); } return; }
VisibleControl.prototype.SetVisibleCore = function(p_value)
{
	if(this.Visible != p_value)
	{
		this.Visible = p_value;
		if(this.IsRendered == true) { this.OnVisibleChanged(); }
	}
	return;
}
/**************************************************************************/
function Control(p_elementId, p_instanceName)
{
	Control.baseConstructor.call(this, p_elementId, p_instanceName);
	this.Location = this.DefaultLocation();
	this.Bounds   = new Rectangle(this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height);
	this.Move     = null;
	this.Resize   = null;
	return;
}
Extend(Control, VisibleControl);
Control.prototype.GetType = function() { return 'Control'; }
Control.prototype.DefaultLocation = function() { return new Point(0, 0); }
Control.prototype.OnMove = function() { if(this.Move) { this.Move(this); } return; }
Control.prototype.OnResize = function() { if(this.Resize) { this.Resize(this); } return; }
Control.prototype.Show = function() { this.SetVisibleCore(true); this.Refresh(); return; }
Control.prototype.Hide = function() { this.SetVisibleCore(false); this.Refresh(); return; }
Control.prototype.SetCssDomProperties = function(p_element)
{
	this.SetElementLocationAndVisibility(p_element);
	Control.superClass.SetCssDomProperties.call(this, p_element);
	return;
}
Control.prototype.SetElementLocationAndVisibility = function(p_element)
{
	if(this.Visible == false)
	{
		p_element.style.display  = 'none';
		p_element.style.position = 'absolute';
		p_element.style.left     = '0px';
		p_element.style.top      = '0px;';
	}
	else
	{
		var v_flag = false;
		p_element.style.display = 'block';
		if(this.Location.X > 0) { v_flag = true; p_element.style.left = this.Location.X.ToCssString(); }
		if(this.Location.Y > 0) { v_flag = true; p_element.style.top = this.Location.Y.ToCssString(); }
		p_element.style.position = v_flag == true ? 'absolute' : 'static';
	}
	return;
}
Control.prototype.MoveTo = function(p_x, p_y)
{
	if(TypeOf(p_x) != 'Number') { throw InvalidArgumentException('p_x'); }
	if(TypeOf(p_y) != 'Number') { throw InvalidArgumentException('p_y'); }
	this.SetBounds(p_x, p_y, this.Size.Width, this.Size.Height);
	return;
}
Control.prototype.ResizeTo = function(p_width, p_height)
{
	if(TypeOf(p_width) != 'Number') { throw InvalidArgumentException('p_width'); }
	if(TypeOf(p_height) != 'Number') { throw InvalidArgumentException('p_height'); }
	this.SetBounds(this.Location.X, this.Location.Y, p_width, p_height);
	return;
}
Control.prototype.SetBounds = function(p_x, p_y, p_width, p_height)
{
	this.SetBoundsCore(p_x, p_y, p_width, p_height);
	return;
}
Control.prototype.SetBoundsCore = function(p_x, p_y, p_width, p_height)
{
	var v_move_flag = this.Location.X != p_x || this.Location.Y != p_y;
	var v_resize_flag = this.Size.Width != p_width || this.Size.Height != p_height;
	this.Location.Set(p_x, p_y);
	this.Size.Set(p_width, p_height);
	this.SyncBoundsRect();
	if(v_move_flag) { this.OnMove(); }
	if(v_resize_flag) { this.OnResize(); }
	return;
}
Control.prototype.SyncBoundsRect = function()
{
	this.Bounds.Set(this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height);
	return;
}