﻿Type.registerNamespace("Infragistics.Web.UI");



$IG.ObjectBaseProps = new function()
{
	this.Count = 0;
};



$IG.ObjectBase = function(adr, element, props, owner, csm)
{
	/// <summary>
	/// The base object for all Infragistics.Web.UI objects.
	/// </summary>
	this._props = props;
	this._element = element;
	this._owner = owner;
	this._address = adr;
	if (element)
		element._object = this;
	this._csm = csm;
	$IG.ObjectBase.initializeBase(this);
}

$IG.ObjectBase.prototype =
{
	get_element: function()
	{
		/// <summary>
		/// Returns the element assoicated with the item.. 
		/// </summary>
		return this._element;
	},
	set_element: function(val)
	{
		/// <summary>Sets nhtml element associated with object.</summary>
		/// <param name="val" type="Object">Reference to html element.</param>
		this._element = val;
	},

	_get_owner: function() { return this._owner; },
	_set_owner: function(value) { this._owner = value; },

	_get_address: function() { return this._address; },
	_set_address: function(val) { this._address = val; },

	_createObjects: function(objectManager)
	{
	},

	_createCollections: function(collectionsManager)
	{
	},

	_set_value: function(index, value)
	{
		if (this._csm)
			this._csm.set_value(index, value, this._address);
	},

	_get_value: function(index, isBool)
	{
		return this._csm ? this._csm.get_value(index, isBool, this._address) : null;
	},

	_get_clientOnlyValue: function(propName)
	{
		return this._csm ? this._csm.get_clientOnlyValue(propName, this._address) : null;
	},

	_get_occasionalProperty: function(propName)
	{
		return this._csm ? this._csm.get_occasionalProperty(propName, this._address) : null;
	},

	_set_occasionalProperty: function(propName, val)
	{
		return this._csm ? this._csm.set_occasionalProperty(propName, val, this._address) : null;
	},


	_saveAdditionalClientState: function()
	{

	},

	dispose: function()
	{
		/// <summary>
		/// Prepares the object for deletion.
		/// </summary>
		if (this._element)
			this._element._object = null;
		this._element = null;
		this._owner = null;
		if (this._props)
		{
			if (this._props.objectsManager)
				this._props.objectsManager.dispose();

			if (this._props.collectionsManager)
				this._props.collectionsManager.dispose();

			this._props = null;
		}
		this._csm = null;
		$IG.ObjectBase.callBaseMethod(this, "dispose");
	}
}
$IG.ObjectBase.registerClass('Infragistics.Web.UI.ObjectBase', Sys.Component);



$IG.ControlObjectProps = new function()
{
	/// <summary>For internal use only.</summary>
	this.Flags = [$IG.ObjectBaseProps.Count + 0, 0];
	this.Count = $IG.ObjectBaseProps.Count + 1;
};



$IG.UIObject = function(adr, element, props, owner, csm)
{
	/// <summary>
	/// An object that has UIFlags associated with it. 
	/// </summary>
	this._flags = null;
	$IG.UIObject.initializeBase(this, [adr, element, props, owner, csm]);
}

$IG.UIObject.prototype =
{
	_getFlags: function()
	{
		if (this._flags == null)
		{
			this.__flagHelper = new $IG.FlagsHelper();
			var key = [$IG.ObjectBaseProps.Count + 0, this.__getDefaultFlags()]
			this._flags = new $IG.FlagsObject(this._get_value(key), this);
		}
		return this._flags;
	},

	__getDefaultFlags: function()
	{
		if (this.__defaultFlags == null)
		{
			this._ensureFlags();
			this.__defaultFlags = this.__flagHelper.calculateFlags();
		}
		return this.__defaultFlags;
	},

	_updateFlags: function(flags)
	{
		var key = [$IG.ObjectBaseProps.Count + 0, this.__getDefaultFlags()]
		this._set_value(key, flags)
	},

	_ensureFlags: function()
	{

	},

	_ensureFlag: function(flag, val)
	{
		this.__flagHelper.updateFlag(flag, val);
	},

	dispose: function()
	{
		if (this._flags != null)
			this._flags.dispose();
		$IG.UIObject.callBaseMethod(this, "dispose");
	}

}
$IG.UIObject.registerClass('Infragistics.Web.UI.UIObject', $IG.ObjectBase);



$IG.ListItemProps = new function()
{
	/// <summary>For internal use only.</summary>
	this.KeyTag = [$IG.ControlObjectProps.Count + 0, ""];
	this.NavigateUrl = [$IG.ControlObjectProps.Count + 1, ""];
	this.Target = [$IG.ControlObjectProps.Count + 2, ""];
	this.Tooltip = [$IG.ControlObjectProps.Count + 3, ""];
	this.Count = $IG.ControlObjectProps.Count + 4;

};



$IG.ListItem = function(adr, element, props, owner, csm, collection, parent)
{
	/// <summary>
	/// Represents an item for flat data controls. 
	/// </summary>
	$IG.ListItem.initializeBase(this, [adr, element, props, owner, csm]);
	this._parent = parent;
	this._itemCollection = collection
}

$IG.ListItem.prototype =
{
	_ensureFlags: function()
	{
		$IG.ListItem.callBaseMethod(this, "_ensureFlag");
		this._ensureFlag($IG.ClientUIFlags.Hoverable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Selectable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Draggable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Droppable, $IG.DefaultableBoolean.True);
	},
	set_key: function(value)
	{
		/// <summary>Sets key for item.</summary>
		/// <param name="value" type="String">Key for item.</param>
		this._set_value($IG.ListItemProps.KeyTag, value);
	},
	get_key: function()
	{
		/// <summary>
		/// Returns/sets a string value that can be used to store extra information on the item.
		/// </summary>
		return this._get_value($IG.ListItemProps.KeyTag);
	},

	set_navigateUrl: function(value)
	{
		/// <summary>Sets url for item.</summary>
		/// <param name="value" type="String">Url for item.</param>
		this._set_value($IG.ListItemProps.NavigateUrl, value);
	},
	get_navigateUrl: function()
	{
		/// <summary>
		/// Returns/sets a url that will be navigated to when an item is clicked.
		/// </summary>
		return this._get_value($IG.ListItemProps.NavigateUrl);
	},

	set_target: function(value)
	{
		/// <summary>Sets NavigateUrl for item.</summary>
		/// <param name="value" type="Object">Url for item.</param>
		this._set_value($IG.ListItemProps.Target, value);
	},
	get_target: function()
	{
		/// <summary>
		/// Returns/sets where the NavigateUrl will be navigated to when an item is clicked.
		/// </summary>         
		return this._get_value($IG.ListItemProps.Target);
	},

	set_tooltip: function(value)
	{
		/// <summary>Sets tooltip for item.</summary>
		/// <param name="value" type="String">Tooltip for item.</param>
		this._set_value($IG.ListItemProps.Tooltip, value);
	},
	get_tooltip: function()
	{
		/// <summary>
		/// Returns/sets the text that will be displayed when the mouse is over the item. 
		/// </summary>         
		return this._get_value($IG.ListItemProps.Tooltip);
	},

	dispose: function()
	{
		$IG.ListItem.callBaseMethod(this, "dispose");

		this._parent = null;
		this._itemCollection = null
	}
}
$IG.ListItem.registerClass('Infragistics.Web.UI.ListItem', $IG.UIObject);



$IG.DataItemProps = new function()
{
	/// <summary>For internal use only.</summary>
	this.DataPath = [$IG.ControlObjectProps.Count + 0, null];
	this.Populated = [$IG.ControlObjectProps.Count + 1, false];
	this.IsEmptyParent = [$IG.ControlObjectProps.Count + 2, false];
	this.Count = $IG.ControlObjectProps.Count + 3;

};



$IG.NavItemProps = new function()
{
	/// <summary>For internal use only.</summary>
	this.Text = [$IG.DataItemProps.Count + 0, ""];
	this.Value = [$IG.DataItemProps.Count + 1, ""];
	this.Key = [$IG.DataItemProps.Count + 2, ""];
	this.Count = $IG.DataItemProps.Count + 3;

};



$IG.NavItem = function(adr, element, props, owner, csm, collection, parent)
{
	/// <summary>
	/// Represents an item for hierarchical data controls. 
	/// </summary>
	$IG.NavItem.initializeBase(this, [adr, element, props, owner, csm]);
	this._parent = parent;
	this._itemCollection = collection

}

$IG.NavItem.prototype =
{

	//NavItem Properties
	_ensureFlags: function()
	{
		$IG.NavItem.callBaseMethod(this, "_ensureFlag");
		this._ensureFlag($IG.ClientUIFlags.Hoverable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Selectable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Draggable, $IG.DefaultableBoolean.True);
		this._ensureFlag($IG.ClientUIFlags.Droppable, $IG.DefaultableBoolean.True);
	},

	//DataItem properties
	set_dataPath: function(value)
	{
		/// <summary>Sets datapath for item.</summary>
		/// <param name="value" type="String">Datapath for item.</param>
		this._set_value($IG.DataItemProps.DataPath, value);
	},
	get_dataPath: function()
	{
		/// <summary>
		/// Sets or gets a string value representing the datapath into the data source used to popuplate the children of this item (if any).
		/// </summary>
		return this._get_value($IG.DataItemProps.DataPath);
	},
	set_populated: function(value)
	{
		/// <summary>Sets item state.</summary>
		/// <param name="value" type="Boolean">True: item was populated.</param>
		this._set_value($IG.DataItemProps.Populated, value);
	},
	get_populated: function()
	{
		/// <summary>
		/// Sets or gets a boolean value that indicates whether or not this item has been populated with children.
		/// </summary>
		return this._get_value($IG.DataItemProps.Populated, true);
	},

	set_isEmptyParent: function(value)
	{
		/// <summary>Sets state of item parent.</summary>
		/// <param name="value" type="Boolean">True: empty parent.</param>
		this._set_value($IG.DataItemProps.IsEmptyParent, value);
	},
	get_isEmptyParent: function()
	{
		/// <summary>
		/// Sets or gets a boolean value that indicates whether or not this item is a parent that has yet to be populated from an Ajax request to expand the node.
		/// </summary>
		return this._get_value($IG.DataItemProps.IsEmptyParent, true);
	},

	set_text: function(value)
	{
		/// <summary>Sets text for item.</summary>
		/// <param name="value" type="String">Text for item.</param>
		this._set_value($IG.NavItemProps.Text, value);
	},
	get_text: function()
	{
		/// <summary>
		/// Gets/Sets the text of the NavItem.
		/// </summary>
		return this._get_value($IG.NavItemProps.Text);
	},
	set_valueString: function(value)
	{
		/// <summary>Sets value for item.</summary>
		/// <param name="value" type="String">Value for item.</param>
		this._set_value($IG.NavItemProps.Value, value);
	},
	get_valueString: function()
	{
		/// <summary>
		/// Gets/Sets the value of the NavItem.
		/// </summary>
		return this._get_value($IG.NavItemProps.Value);
	},
	set_key: function(value)
	{
		/// <summary>Sets key for item.</summary>
		/// <param name="value">Key for item.</param>
		this._set_value($IG.NavItemProps.Key, value);
	},
	get_key: function()
	{
		/// <summary>
		/// Gets/Sets the key of the NavItem.
		/// </summary>
		return this._get_value($IG.NavItemProps.Key);
	},

	getItems: function()
	{
		/// <summary>
		/// Returns the collection of child items of a NavItem.
		/// </summary>
		return this._itemCollection;
	}
}
$IG.NavItem.registerClass('Infragistics.Web.UI.NavItem', $IG.UIObject);



$IG.FlagsHelper = function()
{
	/// <summary>
	/// This class is for internal use only.
	/// Provides helper methods for decoding and coding UIFlags.
	/// </summary>
	this._flagsHT = [];
};

$IG.FlagsHelper.prototype =
{
	updateFlag: function(flag, val)
	{
		/// <summary>
		/// Stores the ClientUIFlag in the private flags Hashtable.
		/// </summary>
		this._flagsHT[flag] = val;
	},
	getBoolFlag: function(flag)
	{
		/// <summary>
		/// Gets the bool value of a flag
		/// </summary>
		var obj = this._flagsHT[flag];
		if (obj == null)
			return false;
		else
			return obj;
	},

	getDBFlag: function(flag)
	{
		/// <summary>
		/// Gets the DefaultableBoolean value of a flag
		/// </summary>
		var obj = this._flagsHT[flag];
		if (obj == null)
			return $IG.DefaultableBoolean.NotSet;
		else
			return obj;
	},

	calcBoolFlag: function(flag)
	{
		/// <summary>
		/// Calculates the integer value for the specified ClientUIFlag based off of the passed in value.
		/// </summary>
		var val = this.getBoolFlag(flag);
		return (val) ? flag : 0;
	},

	calcDBFlag: function(flag)
	{
		/// <summary>
		/// Calculates the integer value for the specified ClientUIFlag based off of the passed in value.
		/// </summary>
		var val = this.getDBFlag(flag);
		return parseInt(flag * .5 * val);
	},

	calculateFlags: function()
	{
		/// <summary>
		/// Calculates the Flags property value of a UIObject based on the values of the list of passed in parameters.
		/// </summary
		var flags = 0;
		flags += this.calcDBFlag($IG.ClientUIFlags.Visible);
		flags += this.calcDBFlag($IG.ClientUIFlags.Enabled);
		flags += this.calcDBFlag($IG.ClientUIFlags.Selectable);
		flags += this.calcBoolFlag($IG.ClientUIFlags.Selected);
		flags += this.calcDBFlag($IG.ClientUIFlags.Hoverable);
		flags += this.calcBoolFlag($IG.ClientUIFlags.Hovered);
		flags += this.calcDBFlag($IG.ClientUIFlags.Editable);
		flags += this.calcDBFlag($IG.ClientUIFlags.Focusable);
		flags += this.calcBoolFlag($IG.ClientUIFlags.Focused);
		flags += this.calcDBFlag($IG.ClientUIFlags.Draggable);
		flags += this.calcDBFlag($IG.ClientUIFlags.Droppable);
		flags += this.calcDBFlag($IG.ClientUIFlags.KBNavigable);
		return flags;
	}
}

$IG.FlagsHelper.registerClass('Infragistics.Web.UI.FlagsHelper');



$IG.FlagsObject = function(flags, object)
{
	/// <summary>
	/// For internal use only.
	/// A helper object that manages UIFlags for a UIObject.
	/// </summary
	this._flags = flags;
	this._object = object
};

$IG.FlagsObject.prototype =
{
	dispose: function()
	{
		this._flags = null;
		this._object = null;
	},

	getVisible: function(parent)
	{
		/// <summary>
		/// Returns the resolved visibility of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Visible, parent);
	},
	setVisible: function(val)
	{
		/// <summary>Sets visibility.</summary>
		/// <param name="value" type="Boolean">True: visible.</param>
		this._setFlagValue($IG.ClientUIFlags.Visible, val);
	},

	getEnabled: function(parent)
	{
		/// <summary>
		/// Returns the resolved enabled state of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Enabled, parent);
	},
	setEnabled: function(val)
	{
		/// <summary>Sets enabled state.</summary>
		/// <param name="value" type="Boolean">True: enabled.</param>
		this._setFlagValue($IG.ClientUIFlags.Enabled, val);
	},

	getSelectable: function(parent)
	{
		/// <summary>
		/// Returns the resolved selectable property of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Selectable, parent);
	},
	setSelectable: function(val)
	{
		/// <summary>Sets ability to select.</summary>
		/// <param name="value" type="Boolean">True: selectable.</param>
		this._setFlagValue($IG.ClientUIFlags.Selectable, val);
	},

	getSelected: function()
	{
		/// <summary>
		/// Returns true if the UIObject is Selected.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Selected, null, true);
	},
	setSelected: function(val)
	{
		/// <summary>Sets selected state.</summary>
		/// <param name="value" type="Boolean">True: selected.</param>
		this._setFlagValue2($IG.ClientUIFlags.Selected, val);
	},

	getHoverable: function(parent)
	{
		/// <summary>
		/// Returns the resolved hoverability of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Hoverable, parent);
	},
	setHoverable: function(val)
	{
		/// <summary>Sets ability to hover.</summary>
		/// <param name="value" type="Boolean">True: hoverable.</param>
		this._setFlagValue($IG.ClientUIFlags.Hoverable, val);
	},

	getHovered: function()
	{
		/// <summary>
		/// Returns true if the UIObject is hovered.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Hovered, null, true);
	},
	setHovered: function(val)
	{
		/// <summary>Sets hover state.</summary>
		/// <param name="value" type="Boolean">True: mouse is over.</param>
		this._setFlagValue2($IG.ClientUIFlags.Hovered, val);
	},

	getEditable: function(parent)
	{
		/// <summary>
		/// Returns the resolved editablility of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Editable, parent);
	},
	setEditable: function(val)
	{
		/// <summary>Sets ability to edit.</summary>
		/// <param name="value" type="Boolean">True: editable.</param>
		this._setFlagValue($IG.ClientUIFlags.Editable, val);
	},

	getFocusable: function(parent)
	{
		/// <summary>
		/// Returns the resolved focuability of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Focusable, parent);
	},
	setFocusable: function(val)
	{
		/// <summary>Sets ability to get focus.</summary>
		/// <param name="value" type="Boolean">True: focusable.</param>
		this._setFlagValue($IG.ClientUIFlags.Focusable, val);
	},

	getFocused: function()
	{
		/// <summary>
		/// Returns true if the UIObject is focused.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Focused, null, true);
	},
	setFocused: function(val)
	{
		/// <summary>Sets focus state.</summary>
		/// <param name="value" type="Boolean">True: has focus.</param>
		this._setFlagValue2($IG.ClientUIFlags.Focused, val);
	},

	getDraggable: function(parent)
	{
		/// <summary>
		/// Returns the resolved dragability of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Draggable, parent);
	},
	setDraggable: function(val)
	{
		/// <summary>Sets ability to drag.</summary>
		/// <param name="value" type="Boolean">True: draggable.</param>
		this._setFlagValue($IG.ClientUIFlags.Draggable, val);
	},

	getDroppable: function(parent)
	{
		/// <summary>
		/// Returns the resolved dropability of a UIObject.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.Droppable, parent);
	},
	setDroppable: function(val)
	{
		/// <summary>Sets ability to drop.</summary>
		/// <param name="value" type="Boolean">True: droppable.</param>
		this._setFlagValue($IG.ClientUIFlags.Droppable, val);
	},

	getKBNavigable: function(parent)
	{
		/// <summary>
		/// Returns true if the UIObject and be navigated with the keyboard.
		/// </summary
		return this._getFlagValue($IG.ClientUIFlags.KBNavigable, parent);
	},
	setKBNavigable: function(val)
	{
		/// <summary>Sets ability to process keyboard.</summary>
		/// <param name="value" type="Boolean">True: process keyboard.</param>
		this._setFlagValue($IG.ClientUIFlags.KBNavigable, val);
	},

	// Returns a Bool
	_getFlagValue: function(flag, parent, isBoolFlag)
	{
		var returnDb = $IG.DefaultableBoolean.NotSet;
		var trueFlag = this._flags & (flag * .5);
		var falseFlag = this._flags & flag;

		if (trueFlag != 0 && falseFlag == 0)
			returnDb = $IG.DefaultableBoolean.True;
		else if (falseFlag != 0)
			returnDb = $IG.DefaultableBoolean.False;

		if (parent != null && returnDb == $IG.DefaultableBoolean.NotSet && parent._getFlags)
			returnDb = parent._getFlags()._getFlagValue(flag);

		if (isBoolFlag)
			return (returnDb == 2)
		else if (returnDb == $IG.DefaultableBoolean.True)
			return true;
		else
			return false;
	},


	// Sets a DefaultableBoolean
	_setFlagValue: function(flag, value)
	{
		if (typeof (value) == "boolean")
			value = (value) ? 1 : 2;

		var trueFlag = this._flags & (flag * .5);
		this._flags -= trueFlag;
		var falseFlag = this._flags & flag;
		this._flags -= falseFlag;

		this._flags += flag * (.5) * value;

		this._object._updateFlags(this._flags);
	},

	// Sets a Bool
	_setFlagValue2: function(flag, value)
	{
		if (typeof (val) == "boolean")
			val = (val) ? 1 : 0;

		this._flags -= this._flags & flag;
		this._flags += (value) ? flag : 0;
		this._object._updateFlags(this._flags);
	},

	_getFlags: function()
	{
		return this._flags;
	}
}

$IG.FlagsObject.registerClass('Infragistics.Web.UI.FlagsObject');




$IG.ImageObject = function(obj, element, props, owner, csm)
{
	///<summary>
	/// An object that has an associated image element and the concept of different states, such as Normal, Hover, Pressed, and Disabled.
	///</summary>
	if (!csm)
		csm = new $IG.ObjectClientStateManager(props[0]);
	$IG.ImageObject.initializeBase(this, [obj, element, props, owner, csm]);

	this._currentState = this._get_clientOnlyValue("s");
}

$IG.ImageObject.prototype =
{
	setState: function(state)
	{
		/// <summary>
		/// Sets the ImageState of the ImageObject.
		/// </summary
		if (this._element == null)
			return;
		var url = this._get_clientOnlyValue(state);
		if (url == null || url.length == 0)
			url = this._get_clientOnlyValue($IG.ImageState.Normal);

		this._element.src = url;
		this._currentState = state;
	},

	getState: function()
	{
		/// <summary>
		/// Returns the ImageState of the ImageObject
		/// </summary
		return this._currentState;
	}
}
$IG.ImageObject.registerClass('Infragistics.Web.UI.ImageObject', $IG.ObjectBase);

$IG.ImageState = new function()
{
	this.Normal = 'i';
	this.Hover = 'h';
	this.Pressed = 'p';
	this.Disabled = 'd';
};




Infragistics._Utility = function() { };

Infragistics._Utility.prototype =
{

	addCompoundClass: function(element, className)
	{
		Sys.UI.DomElement.addCssClass(element, className);
	},

	containsCompoundClass: function(element, className)
	{
		return (element.className.indexOf(className) >= 0);
	},

	removeCompoundClass: function(element, className)
	{
		element.className = element.className.replace(className, "");
		element.className = element.className.replace("  ", " ");
	},

	toggleCompoundClass: function(element, className, apply)
	{
		if (apply)
		{
			if (!this.containsCompoundClass(element, className))
				this.addCompoundClass(element, className);
		}
		else
			this.removeCompoundClass(element, className);
	},

	
	
	addClientEvent: function(obj, evtName, val)
	{
		/// <summary>For internal use. Adds client event.</summary>
		/// <param name="obj" type="Object">Reference to object.</param>
		/// <param name="evtName">Name of client event.</param>
		/// <param name="fnc" type="Object">Reference to function.</param>
		var fnc = this.toFunction(val);
		if (fnc)
			obj.get_events().addHandler(evtName, fnc);
		else
			alert('The "' + val + '" for "' + evtName + '" should be a function, function name, or function text');
	},

	
	
	removeClientEvent: function(obj, evtName, fnc)
	{
		/// <summary>For internal use. Removes client event.</summary>
		/// <param name="obj" type="Object">Reference to object.</param>
		/// <param name="evtName">Name of client event.</param>
		/// <param name="fnc" type="Object">Reference to function.</param>
		obj.get_events().removeHandler(evtName, fnc);
	},

	
	
	getPosition: function(elem)
	{
		/// <summary>For internal use. Gets location of element on page.</summary>
		/// <param name="elem" type="Object">Reference to html element which position should be calculated.</param>
		/// <returns type="Object">Object which contains 4 numeric values: x-left position of elem, y-top position, scrollX-horizontal scroll, scrollY-vertical scroll.</returns>
		var htm, name, style, elem0 = elem;
		var first = true, noTD = true, ieRect = false, end = false;
		var o = { x: 0, y: 0, scrollX: 0, scrollY: 0 };
		var ie = document.all && elem.getBoundingClientRect;
		var body2 = !ie;
		while (elem)
		{
			name = elem.nodeName;
			style = this.getRuntimeStyle(elem);
			htm = name == 'HTML';
			if (end)
			{
				if (htm) break;
				elem = elem.parentNode;
				continue;
			}
			var body = name == 'BODY';
			var bdr = false;
			var pos = this.getStyleValue(style, 'position');
			var abs = pos == 'absolute', rel = pos == 'relative';
			if (ie && rel)
				ieRect = abs = true;
			end = body && !ie;
			if ((abs && body) || name == 'FORM')
				break;
			var v = elem.offsetTop;
			if (v)
			{
				if (elem.nodeName == 'TD' && elem.offsetParent != elem.parentNode)
					v = elem.parentNode.offsetTop;
				o.y += v;
			}
			v = elem.offsetLeft;
			if (v) o.x += v;
			if (!first && !htm)
			{
				var td = name == 'TD', tbl = name == 'TABLE';
				if (ie)
				{
					if (!tbl || (noTD && abs))
					{
						if (name != 'DIV' || !rel)
							bdr = true;
						if (td)
							noTD = false;
					}
					if (tbl || (!td && !tbl))
						noTD = true;
				}
				else if ((!tbl && !td) || (td && abs))
					bdr = true;
			}
			if (bdr)
			{
				
				v = body2 && body;
				
				if (!ie && !v && (abs || rel))
					v = this._isScroll(style, name);
				this._addBorder(style, o, false, v);
			}
			if (elem != elem0)
			
				this._addScroll(elem, o);
			if (abs)
				body2 = false;
			first = false;
			var pe = elem.parentNode;
			elem = elem.offsetParent;
			if (!elem && end)
			{
				elem = pe;
				continue;
			}
			
			if (!ie && !abs && elem) while (pe && pe != elem)
			{
				if (this._isScroll(style = this.getRuntimeStyle(pe), pe.nodeName))
				{
					this._addScroll(pe, o);
					this._addBorder(style, o);
				}
				pe = pe.parentNode;
			}
		}
		if (body2 && htm)
			this._addBorder(style, o, true);
		if (ieRect)
		{
			v = elem0.getBoundingClientRect();
			o.x = v.left + o.scrollX;
			o.y = v.top + o.scrollY;
			if (htm && style)
				this._addBorder(style, o, true);
		}
		return o;
	},
	_addScroll: function(elem, o)
	{
		var v = elem.scrollLeft;
		if (v) o.scrollX += v;
		v = elem.scrollTop;
		if (v) o.scrollY += v;
	},
	_addBorder: function(style, o, neg, twice)
	{
		var v = this.toIntPX(style, 'borderLeftWidth', 0);
		if (twice) v += v;
		o.x += neg ? -v : v;
		v = this.toIntPX(style, 'borderTopWidth', 0);
		if (twice) v += v;
		o.y += neg ? -v : v;
	},
	_isScroll: function(style, name)
	{
		var v = name == 'DIV' ? this.getStyleValue(style, 'overflow') : '';
		return v == 'auto' || v == 'scroll';
	},

	
	cancelEvent: function(e, type, raw)
	{
		/// <summary>For internal use. Cancels browser event.</summary>
		/// <param name="e" type="Object">Reference to event.</param>
		/// <param name="type" type="String" mayBeNull="true" optional="true">Name of event.</param>
		/// <param name="raw" type="Boolean" mayBeNull="true" optional="true">Cancel rawEvent.</param>
		if (!e && !raw) e = window.event;
		if (!e) return true;
		if (type && type.substring && e.type != type)
			return true;
		if (e.stopPropagation)
			e.stopPropagation();
		if (e.preventDefault)
			e.preventDefault();
		e.cancelBubble = true;
		e.returnValue = false;
		if (raw)
			return false;
		return this.cancelEvent(e.rawEvent, null, true);
	},

	
	getRuntimeStyle: function(elem)
	{
		/// <summary>For internal use. Gets reference to run time style of element.</summary>
		/// <param name="elem" type="Object">Reference to html element which position should be calculated.</param>
		/// <returns type="Object" mayBeNull="true">Style.</returns>
		if (!elem)
			return null;
		var s = elem.currentStyle;
		if (s)
			return s;
		var win = document.defaultView;
		if (!win)
			win = window;
		if (win.getComputedStyle)
			s = win.getComputedStyle(elem, '');
		return s ? s : elem.style;
	},

	
	
	
	getStyleValue: function(style, prop, elem)
	{
		/// <summary>For internal use. Gets reference to run time style of element.</summary>
		/// <param name="style" type="Object" mayBeNull="true" optional="true">Reference to style.</param>
		/// <param name="prop" type="String" mayBeNull="false" optional="false">Name of property, like borderTopWidth.</param>
		/// <param name="elem" type="Object" mayBeNull="true" optional="true">Reference to html element.</param>
		/// <returns type="String" mayBeNull="true">Value of property.</returns>
		if (!style)
			style = this.getRuntimeStyle(elem);
		if (!style)
			return null;
		var val = style[prop];
		if (!this.isEmpty(val) || !style.getPropertyValue)
			return val;
		return style.getPropertyValue(prop);
	},

	
	toInt: function(val, def)
	{
		/// <summary>For internal use. Gets integer from string.</summary>
		/// <param name="val" type="Object">String or numeric value.</param>
		/// <param name="def" type="Number" mayBeNull="true" optional="true">Value returned in case of failure.</param>
		/// <returns type="Number">Integer.</returns>
		var ok = false;
		var i = -1, len = val ? val.length : 0;
		while (++i < len)
		{
			var ch = val.charCodeAt(i);
			if (ch == 45 && i == 0)
				continue;
			if (ch < 48 || ch > 57)
			{
				val = val.substring(0, i);
				break;
			}
			ok = true;
		}
		return ok ? parseInt(val) : def;
	},

	
	
	
	
	toIntPX: function(style, prop, def, elem)
	{
		/// <summary>For internal use. Gets integer from string with validation for pixel units.</summary>
		/// <param name="style" type="Object" mayBeNull="true" optional="true">Reference to style.</param>
		/// <param name="prop" type="String" mayBeNull="false" optional="false">Name of property, like borderTopWidth.</param>
		/// <param name="def" type="Number" mayBeNull="true" optional="true">Value returned in case of failure.</param>
		/// <param name="elem" type="Object" mayBeNull="true" optional="true">Reference to html element.</param>
		/// <returns type="Number">Integer.</returns>
		var px = this.getStyleValue(style, prop, elem);
		return (px && px.indexOf('px') > 0) ? this.toInt(px, 0) : (def ? def : 0);
	},

	
	toFunction: function(val)
	{
		/// <summary>For internal use. Gets reference to function.</summary>
		/// <param name="val" type="Object">Reference to function, its text, etc.</param>
		/// <returns type="Number" mayBeNull="true">Reference to function.</returns>
		if (val instanceof Function)
			return val;
		if (!val || !val.length || !val.charCodeAt)
			return null;
		var fnc = window[val];
		if (fnc instanceof Function)
			return fnc;
		try { fnc = eval(val); } catch (val) { }
		return (fnc instanceof Function) ? fnc : null;
	},

	
	isEmpty: function(val)
	{
		/// <summary>For internal use. Checks if value is empty.</summary>
		/// <param name="val" type="Object">Object to test.</param>
		/// <returns type="Boolean">True: string or array is empty.</returns>
		if (!val)
			return true;
		val = val.length;
		return !val || val.length < 1;
	},
	
	getOpacity: function(elem)
	{
		/// <summary>For internal use. Gets opacity of element.</summary>
		/// <param name="elem" type="Object">Object to test.</param>
		/// <returns type="Number">Value in range of 0-100.</returns>
		var op = this.getStyleValue(null, 'opacity', elem);
		if (op)
		{
			op = parseFloat(op);
			if (op)
			{
				op = Math.floor(op * 100);
				return (op < 100 && op >= 0) ? op : 100;
			}
		}
		op = this.getStyleValue(null, 'filter', elem);
		if (!op)
			return 100;
		op = this.replace(op.toLowerCase(), ' ', '');
		var i = op.indexOf('opacity=');
		return (i < 0) ? 100 : this.toInt(op.substring(i + 8), 100);
	},

	
	
	
	findControl: function(id, prefix)
	{
		/// <summary>Find Infragistics control from partial match of its id.</summary>
		/// <param name="id" type="String">Trailing part of id (after undescore).</param>
		/// <param name="prefix" type="String" mayBeNull="true" optional="true">Prefix of id.</param>
		/// <returns type="Object" mayBeNull="true">Reference to control.</returns>
		for (var ig in ig_controls)
		{
			var ctl = ig_controls[ig];
			if (!ctl.get_id || (prefix && ig.indexOf(prefix) != 0))
				continue;
			var i = ig.lastIndexOf(id);
			if (i == 0 || (i > 0 && i + id.length == ig.length && ig.charAt(i - 1) == '_'))
				return ctl;
		}
	},

	
	
	
	findChild: function(elem, id)
	{
		/// <summary>Find html element with partial match of its id.</summary>
		/// <param name="elem" type="Object">Parent container.</param>
		/// <param name="id" type="String">Trailing part of id (after undescore).</param>
		/// <returns type="Object" mayBeNull="true">Reference to html element.</returns>
		var id0 = elem.id;
		var i = id0 ? id0.lastIndexOf(id) : -1;
		if (i >= 0 && i + id.length == id0.length && id0.charAt(i - 1) == '_')
			return elem;
		var elems = elem.childNodes;
		i = elems ? elems.length : 0;
		while (i-- > 0)
		{
			elem = this.findChild(elems[i], id);
			if (elem)
				return elem;
		}
	},

	
	addLayoutTarget: function(target)
	{
		/// <summary>For internal use only.</summary>
		
		var index = -1, elem = target._element;
		while ((elem = elem.parentNode) != null)
		{
			if (!elem.getAttribute)
				continue;
			
			var ctl = null, id = elem.getAttribute('mkr');
			if (id && id.length > 1 && id.substring(0, 1) == 'c')
				index = this.toInt(id.substring(1), -1);
			id = elem.getAttribute('CtlMain');
			if (!id)
				continue;
			if (id == 'layout')
			{
				id = elem.id;
				if (id)
					ctl = ig_controls[id];
			}
			if (!ctl || !ctl.getLayoutManager)
			{
				index = -1;
				continue;
			}
			
			ctl = ctl.getLayoutManager(index);
			if (!ctl) continue;
			
			var i = -1, ids = ctl._layoutListeners, id = target._id;
			if (!ids)
				ctl._layoutListeners = ids = new Array();
			
			while (++i < ids.length)
				if (ids[i] == id)
				break;
			ids[i] = id;
			
			target._layoutManager = ctl;
			return true;
		}
		return false;
	},

	
	
	
	raiseLayoutEvent: function(man)
	{
		/// <summary>For internal use only.</summary>
		
		
		var ctl, elem = man._element;
		var lsnrs = elem ? elem._ctlsForLayout : null;
		var i = lsnrs ? lsnrs.length : 0;
		while (i-- > 0)
		{
			ctl = lsnrs[i];
			if (ctl && ctl.layout)
			
				if (ctl.layout(man.getClientWidth ? man.getClientWidth(ctl) : null, man.getClientHeight ? man.getClientHeight(ctl) : null))
				if (!ctl._layoutManager)
			
				this.addLayoutTarget(ctl);
			lsnrs[i] = null;
		}
		if (lsnrs)
		{
			elem._ctlsForLayout = null;
			return;
		}
		lsnrs = man._layoutListeners;
		i = lsnrs ? lsnrs.length : 0;
		while (i-- > 0)
		{
			var ctl = ig_controls[lsnrs[i]];
			if (ctl && ctl.layout)
			{
				var width = man.getClientWidth ? man.getClientWidth(ctl) : null, height = man.getClientHeight ? man.getClientHeight(ctl) : null;
				ctl.layout(width, height);
			}
		}
	},
	
	
	
	
	
	
	
	
	
	checkLayoutManager: function(ctl)
	{
		/// <summary>For internal use only.</summary>
		var i = 0, elem = ctl._element;
		
		
		while (i++ < 10 && elem && (elem = elem.parentNode) != null)
		{
			
			var css = elem.id ? elem.className : null;
			if (css && css.indexOf(':=CtlMain:layout') == css.length - 16)
			{
				
				if ((i = elem._ctlsForLayout) == null)
					i = elem._ctlsForLayout = new Array();
				i[i.length] = ctl;
				return true;
			}
		}
		return false;
	},

	
	
	
	
	
	getOffset: function(style, width, noTrail, noLead)
	{
		/// <summary>For internal use only.</summary>
		var val = 0;
		if (style) while (!noLead || !noTrail)
		{
			var prop = noLead ? (width ? 'Right' : 'Bottom') : (width ? 'Left' : 'Top');
			if (noLead)
				noTrail = true;
			noLead = true;
			val += this.toIntPX(style, 'border' + prop + 'Width') + this.toIntPX(style, 'padding' + prop);
		}
		return val;
	},

	
	
	
	getMargin: function(style, horiz)
	{
		/// <summary>For internal use only.</summary>
		return this.toIntPX(style, 'margin' + (horiz ? 'Left' : 'Top')) + this.toIntPX(style, 'margin' + (horiz ? 'Right' : 'Bottom'));
	},

	
	
	
	display: function(elem, hide)
	{
		/// <summary>For internal use only.</summary>
		var style = elem ? elem.style : null;
		if (!style) return;
		style.display = hide ? 'none' : '';
		style.visibility = hide ? 'hidden' : 'visible';
	},

	
	
	isOut: function(e, elem)
	{
		var to = e.toElement;
		if (!to) to = e.relatedTarget;
		e = e.rawEvent;
		if (!to && e) if ((to = e.toElement) == null)
			to = e.relatedTarget;
		while (to)
		{
			if (to == elem)
				return false;
			to = to.parentNode;
		}
		return true;
	},

	
	
	
	
	
	
	
	
	replace: function(str, oldVal, newVal)
	{
		/// <summary>For internal use only.</summary>
		if (newVal == null)
			for (var i = 0; i < oldVal.length; i += 2)
			str = this.replace(str, oldVal[i], oldVal[i + 1]);
		else while (str.indexOf(oldVal) >= 0)
			str = str.replace(oldVal, newVal);
		return str;
	},

	
	htmlEscapeCharacters: function(str)
	{
		/// <summary>For internal use only.</summary>
		return (typeof (str) === "string") ? str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
	},

	
	htmlUnescapeCharacters: function(str)
	{
		/// <summary>For internal use only.</summary>
		return (typeof (str) === "string") ? str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">") : str;
	},

	
	getHTML: function(win)
	{
		/// <summary>Find HTML element.</summary>
		/// <param name="win" type="Object" mayBeNull="true" optional="true">Reference to window.</param>
		/// <returns type="Object" mayBeNull="true">Reference to HTML.</returns>
		if (!win)
			win = window;
		var doc = win.document;
		var htm = doc.body;
		while (htm && htm.nodeName != 'HTML')
			htm = htm.parentNode;
		return htm ? htm : doc.body;
	},

	
	getWinRect: function(win)
	{
		/// <summary>For internal use only.</summary>
		if (!win)
			win = window;
		var doc = win.document;
		var body = doc.body, htm = this.getHTML(win), de = doc.documentElement;
		if (!de)
			de = htm;
		var x = de.scrollLeft, y = de.scrollTop, wi = win.innerWidth, hi = win.innerHeight, wd = de.clientWidth, hd = de.clientHeight, w = htm.clientWidth, h = htm.clientHeight;
		var maxWidth = w ? w : 0, maxHeight = h ? h : 0, w2 = htm.scrollWidth, h2 = htm.scrollHeight;
		if (wd)
		{
			maxWidth = Math.max(maxWidth, wd);
			maxHeight = Math.max(maxHeight, hd);
		}
		if (wi)
		{
			maxWidth = Math.max(maxWidth, wi);
			maxHeight = Math.max(maxHeight, hi);
		}
		if (w2 && h2)
		{
			maxWidth = Math.max(maxWidth, w2);
			maxHeight = Math.max(maxHeight, h2);
		}
		w2 = body.scrollWidth;
		if (w2)
			maxWidth = Math.max(maxWidth, w2);
		w2 = body.offsetWidth;
		h2 = body.offsetHeight
		maxWidth = Math.max(maxWidth, w2);
		maxHeight = Math.max(maxHeight, h2);
		var noClientSize = false;
		
		if (!x)
			x = htm.scrollLeft;
		if (!x)
			x = body.scrollLeft;
		if (!y)
			y = htm.scrollTop;
		if (!y)
			y = body.scrollTop;
		
		if (!wi || wi < 50)
			wi = 99999;
		if (!wd || wd < 50)
			wd = 99999;
		if (!w || w < 50)
			w = 99999;
		if (w > wd)
			w = wd;
		if (w > wi)
			w = wi;
		if (w == 99999)
		{
			w = w2;
			noClientSize = true;
		}
		
		if (!hi || hi < 50)
			hi = 99999;
		if (!hd || hd < 50)
			hd = 99999;
		if (!h || h < 50)
			h = 99999;
		if (h > hd)
			h = hd;
		if (h > hi)
			h = hi;
		if (h == 99999)
		{
			h = h2;
			noClientSize = true;
		}
		return { x: x, y: y, width: w, height: h, maxWidth: maxWidth, maxHeight: maxHeight, noClientSize: noClientSize };
	},

	
	setOpacity: function(element, opacity)
	{
		/// <summary>For internal use only.</summary>
		element.style.opacity = opacity / 100;
		if (element.filters)
		{
			if (!element.filters["alpha"] || element.style.filter.indexOf("alpha") == -1)
				element.style.filter += " alpha(opacity=" + opacity + ")";
			else
				element.filters["alpha"].opacity = opacity;
		}
	},

	
	
	_initAttr: function(elem)
	{
		var attr = elem.id;
		var j = 99, i = attr ? attr.length : 0;
		if (i < 1)
		
			return false;
		
		
		
		if (attr.length > 5 && attr.charAt(1) == ':' && attr.charAt(0) == 'x')
		{
			attr = attr.split(':');
			i = attr.length;
			if ((i >= 4 || (i % 2 == 0)) && attr[1].indexOf('.') > 0)
				j = 1;
		}
		
		if (j > 2)
		{
			
			
			
			var css = elem.className;
			j = (css && css.length > 5) ? css.indexOf(' :=') : -1;
			if (j < 0)
			
				return true;
			attr = css.substring(j + 3);
			if (attr.indexOf(' ') >= 0)
			
				return true;
			attr = attr.split(':');
			i = attr.length;
			if (i < 2 || (i & 1) != 0)
			
				return true;
			elem.className = css.substring(0, j);
			j = -1;
		}
		while ((i -= 2) > j)
			elem.setAttribute(attr[i], attr[i + 1]);
		
		return j < 0;
	},

	
	resolveMarkedElement: function(elem, checkControl)
	{
		/// <summary>For internal use only.</summary>
		var adr = null;
		var control = null;
		var secondWalkthrough = false;
		while (elem)
		{
			if (elem.getAttribute)
			{
				adr = elem.getAttribute("adr");
				if (adr == null)
					adr = elem.getAttribute("mkr");
				if (adr == null)
					adr = elem.getAttribute("obj");
				if (adr == null && !secondWalkthrough)
				{
					adr = elem.getAttribute("id");
					if (adr)
					{
						secondWalkthrough = true;
						if (!$util._initAttr(elem))
							continue;
						adr = null;
					}
				}
				else
					secondWalkthrough = false;
			}
			if (typeof (adr) == "string")
			{
				if (adr.length > 0)
					break;
			}
			else
				if (typeof (adr) != "undefined" && adr !== null)
				break;

			elem = elem.parentNode;
		}
		if (elem == null)
			return null;
		else if (checkControl)
		{
			var parent = elem.parentNode;
			while (parent)
			{
				if (parent.control != null)
				{
					control = parent.control;
					break;
				}
				parent = parent.parentNode;
			}
		}
		return [elem, adr, control];
	},

	compare: function(val1, val2)
	{
		/// <summary>For internal use only.</summary>
		if (val1 == val2)
			return true;
		else if (val1 != null && val2 != null)
		{
			var type1 = Object.getType(val1).__typeName;
			var type2 = Object.getType(val2).__typeName;
			if (type1 != type2 || type1 == "String" || type1 == "Number" || type1 == "Boolean")
				return false;

			if (type1 == "Array")
			{
				if (val1.length != val2.length)
					return false;

				for (var i in val1)
				{
					if (!$util.compare(val1[i], val2[i]))
						return false;
				}
				return true;
			}
			else if (type1 == "Date")
			{
				if (val1.getTime() == val2.getTime())
					return true;
			}
			else
			{
				for (var i in val1)
				{
					if (!$util.compare(val1[i], val2[i]))
						return false;
				}
				return true;
			}
		}
		return false;
	},

	ensureBrowserInfo: function()
	{
		/// <summary>For internal use only.</summary>
		try { this.AgentName = navigator.userAgent.toLowerCase(); } catch (e) { this.AgentName = ""; }
		this.MajorVersionNumber = parseInt(navigator.appVersion);
		this.IsSafari = this.AgentName.indexOf("safari") >= 0;
		this.IsFireFox = this.AgentName.indexOf("firefox") >= 0;
		if (this.IsFireFox)
		{
			this.IsFireFox2 = this.AgentName.indexOf("firefox/2") >= 0;
			this.IsFireFox3 = this.AgentName.indexOf("firefox/3") >= 0;
		}
		this.IsOpera = this.AgentName.indexOf("opera") >= 0;
		this.IsMac = this.AgentName.indexOf("mac") >= 0;
		this.IsIE = document.all != null && !this.IsOpera && !this.IsSafari;
	},

	_getWidthMargin: function(element)
	{
		var style = this.getRuntimeStyle(element);
		var borderLeftWidth = 0;
		if (style.borderLeftStyle != "none")
		{
			if (style.borderLeftWidth == "thin")
				borderLeftWidth = 1;
			else if (style.borderLeftWidth == "medium")
				borderLeftWidth = 3;
			else if (style.borderLeftWidth == "thick")
				borderLeftWidth = 5;
			else
			{
				var w = parseInt(style.borderLeftWidth, 10);
				if (isNaN(w))
					w = 0;
				borderLeftWidth = w;
			}
		}

		var borderRightWidth = 0;
		if (style.borderRightStyle != "none")
		{
			if (style.borderRightWidth == "thin")
				borderRightWidth = 1;
			else if (style.borderRightWidth == "medium")
				borderRightWidth = 3;
			else if (style.borderRightWidth == "thick")
				borderRightWidth = 5;
			else
			{
				var w = parseInt(style.borderRightWidth, 10);
				if (isNaN(w))
					w = 0;
				borderRightWidth = w;
			}
		}

		var paddingLeft = parseInt(style.paddingLeft, 10);
		if (isNaN(paddingLeft))
			paddingLeft = 0;

		var paddingRight = parseInt(style.paddingRight, 10);
		if (isNaN(paddingRight))
			paddingRight = 0;

		return borderLeftWidth + borderRightWidth + paddingLeft + paddingRight;
	},

	_getHeightMargin: function(element)
	{
		var style = this.getRuntimeStyle(element);
		var borderTopWidth = 0;
		if (style.borderTopStyle != "none")
		{
			if (style.borderTopWidth == "thin")
				borderTopWidth = 1;
			else if (style.borderTopWidth == "medium")
				borderTopWidth = 3;
			else if (style.borderTopWidth == "thick")
				borderTopWidth = 5;
			else
			{
				var w = parseInt(style.borderTopWidth, 10);
				if (isNaN(w))
					w = 0;
				borderTopWidth = w;
			}
		}

		var borderBottomWidth = 0;
		if (style.borderBottomStyle != "none")
		{
			if (style.borderBottomWidth == "thin")
				borderBottomWidth = 1;
			else if (style.borderBottomWidth == "medium")
				borderBottomWidth = 3;
			else if (style.borderBottomWidth == "thick")
				borderBottomWidth = 5;
			else
			{
				var w = parseInt(style.borderBottomWidth, 10);
				if (isNaN(w))
					w = 0;
				borderBottomWidth = w;
			}
		}

		var paddingTop = parseInt(style.paddingTop, 10);
		if (isNaN(paddingTop))
			paddingTop = 0;

		var paddingBottom = parseInt(style.paddingBottom, 10);
		if (isNaN(paddingBottom))
			paddingBottom = 0;

		return borderTopWidth + borderBottomWidth + paddingTop + paddingBottom;
	},

	setAbsoluteWidth: function(element, width)
	{
		///<summary>
		///Sets the outer width on an element. The width includes in itself the borders
		///and the paddings.
		///</summary>


		width -= this._getWidthMargin(element);

		if (width < 0)
			width = 0;

		element.style.width = width + "px";

		
		var adjustment = width + (width - element.offsetWidth + this._getWidthMargin(element));
		if (adjustment > 0)
			element.style.width = adjustment + "px";

	},

	getAbsoluteWidth: function(element)
	{
		///<summary>
		///Sets the outer width on an element. The width includes in itself the borders
		///and the paddings.
		///</summary>


		var width = element.offsetWidth + this._getWidthMargin(element);

		if (width < 0)
			width = 0;

		return width;
	},

	setAbsoluteHeight: function(element, height)
	{
		///<summary>
		///Sets the outer height on an element. The height includes in itself the borders
		///and the paddings.
		///</summary>

		height -= this._getHeightMargin(element);

		if (height < 0)
			height = 0;

		element.style.height = height + "px";
	},

	getAbsoluteHeight: function(element)
	{
		///<summary>
		///Sets the outer height on an element. The height includes in itself the borders
		///and the paddings.
		///</summary>

		var height = element.offsetHeight - this._getHeightMargin(element);

		if (height < 0)
			height = 0;

		return height;
	},

	addHandler: function(element, eventName, handler)
	{
		/// <summary>For internal use only.</summary>
		if(!handler)
			return;
		var browserHandler;
		if (element.addEventListener)
		{
			browserHandler = function(e)
			{
				return handler.call(element, new Sys.UI.DomEvent(e));
			}
			element.addEventListener(eventName, browserHandler, false);
		}
		else if (element.attachEvent)
		{
			browserHandler = function(e)
			{
				return handler.call(element, new Sys.UI.DomEvent(e));
			}
			element.attachEvent('on' + eventName, browserHandler);
		}
	},

	removeHandler: function(element, eventName, handler)
	{
		if(!handler)
			return;
		if (element.removeEventListener)
			element.removeEventListener(eventName, handler, false);
		else if (element.detachEvent)
			element.detachEvent('on' + eventName, handler);
	},

	isChild: function(parent, child)
	{
		var p = child.parentNode;
		while (p != parent && p != document.body && p != null)
			p = p.parentNode;
		return (p == parent)
	},
	getRows: function(tbl)
	{
		if (!tbl)
			return null;
		try
		{
			if (typeof tbl.rows == 'object')
				return tbl.rows;
		} catch (e) { }
		
		if (tbl.nodeName == 'TABLE')
			tbl = tbl.firstChild;
		return (tbl.nodeName == 'TBODY') ? tbl.childNodes : null;
	},
	
	
	createDelegate: function(instance, method, args)
	{
		return function()
		{
			return method.apply(instance, args);
		}
	},
	
	
	
	_setMouseBlock: function(targetDIV)
	{
		
		
		var mouseBlock = this._mouseBlock;
		if(!targetDIV && !mouseBlock)
			return;
		if(!mouseBlock)
		{
			this._mouseBlock = mouseBlock = document.createElement('DIV');
			var style = mouseBlock.style;
			style.zIndex = 100000;
			style.position = 'absolute';
			style.background = 'white';
			style.filter = 'alpha(opacity:0)';
			style.opacity = 0.0;
		}
		if(targetDIV)
		{
			if(mouseBlock._targetDIV != targetDIV)
			{
				
				this._setMouseBlock();
				mouseBlock._targetDIV = targetDIV;
				targetDIV.insertBefore(mouseBlock, targetDIV.firstChild);
			}
			if(mouseBlock._w != targetDIV.offsetWidth)
				mouseBlock.style.width = (mouseBlock._w = targetDIV.offsetWidth) + 'px';
			if(mouseBlock._h != targetDIV.offsetHeight)
				mouseBlock.style.height = (mouseBlock._h = targetDIV.offsetHeight) + 'px';
			return;
		}
		if(!mouseBlock._targetDIV)
			return;
		mouseBlock._targetDIV = null;
		mouseBlock.parentNode.removeChild(mouseBlock);
	}
};
Infragistics._Utility.registerClass("Infragistics._Utility");

Infragistics.Utility = new Infragistics._Utility();
var $util = Infragistics.Utility;
$util.ensureBrowserInfo();



var ig_ui_all = null; 
function ig_ui_timer(o, del)
{
	var all = ig_ui_all;
	var i, fn = all ? all._timerFn : null;
	
	if (typeof o != 'object')
		o = null;
	if (o)
	{
		if (!o._onTimer) return; 
		if (!all) ig_ui_all = all = new Array();
		i = all.length;
		while (i-- > 0) if (all[i] == o) break; 
		if (del)
		{
			if (i < 0) return;
			delete o._onTimer;
			delete all[i];
			o = null; 
			i = all.length;
			while (i-- > 0) if (all[i]) o = true; 
		}
		else
		{
			if (i < 0)
			{
				
				while (all[++i]);
				all[i] = o;
			}
			if (!fn) all._timerFn = fn = window.setInterval(ig_ui_timer, 200); 
		}
	}
	if (o) return;
	
	if (!del && fn) for (i = 0; i < all.length; i++)
	{
		o = all[i]; 
		if (o && o._onTimer)
		{
			if (!o._onTimer())
			{
				fn = null; 
				continue;
			}
			delete o._onTimer; 
			delete all[i];
		}
	}
	if (!fn) return; 
	window.clearInterval(fn); 
	delete all._timerFn;
	ig_ui_all = null;
}




$IG.EventArgs = function()
{
	/// <summary>Base class for object used as parameter while raising client events related to browser action.</summary>
	$IG.EventArgs.initializeBase(this);
	this._props = [null, 0];
}
$IG.EventArgs.prototype =
{
	get_browserEvent: function()
	{
		/// <summary>Gets reference to browser event.</summary>
		/// <returns type="Object" mayBeNull="true">Reference to browser event.</returns>
		return this._props[0];
	},
	dispose: function()
	{
		/// <summary>Disposes object.</summary>
		this._props[0] = null;
	}
}
$IG.EventArgs.registerClass('Infragistics.Web.UI.EventArgs', Sys.EventArgs);


$IG.PostBackEventArgs = function()
{
	/// <summary>Base class for object used as parameter while raising client events related to postback action.</summary>
	$IG.PostBackEventArgs.initializeBase(this);
}
$IG.PostBackEventArgs.prototype =
{
	
	get_postBack: function()
	{
		/// <summary>Gets postback flag.</summary>
		/// <returns type="Number">One of the following: 0 - do not trigger postback, 1 - trigger full postback, 2 - trigger async postback.</returns>
		return this._props[1];
	},
	
	set_postBack: function(val)
	{
		/// <summary>Sets postback flag.</summary>
		/// <param name="val" type="Number">One of the following: 0 - do not trigger postback, 1 - trigger full postback, 2 - trigger async postback.</param>
		this._props[1] = val;
	}
}
$IG.PostBackEventArgs.registerClass('Infragistics.Web.UI.PostBackEventArgs', $IG.EventArgs);


$IG.CancelEventArgs = function()
{
	/// <summary>Base class for object used as parameter while raising cancelable client events related to browser action.</summary>
	$IG.CancelEventArgs.initializeBase(this);
	this._cancel = false;
}
$IG.CancelEventArgs.prototype =
{
	
	get_cancel: function()
	{
		/// <summary>Checks if event was canceled.</summary>
		/// <returns type="Boolean">True: event was canceled.</returns>
		return this._cancel;
	},
	
	set_cancel: function(val)
	{
		/// <summary>Cancel event.</summary>
		/// <param name="val" type="Boolean">True: cancel event.</param>
		this._cancel = val;
	}
}
$IG.CancelEventArgs.registerClass('Infragistics.Web.UI.CancelEventArgs', $IG.EventArgs);


$IG.MoveEventArgs = function()
{
	/// <summary>Class for object used as parameter while raising Move events.</summary>
	$IG.MoveEventArgs.initializeBase(this);
}
$IG.MoveEventArgs.prototype =
{
	
	get_x: function()
	{
		/// <summary>Gets new left position.</summary>
		/// <returns type="Number">Left position in pixels.</returns>
		return this._props[2];
	},
	get_y: function()
	{
		/// <summary>Gets new top position.</summary>
		/// <returns type="Number">Top position in pixels.</returns>
		return this._props[3];
	},
	get_oldX: function()
	{
		/// <summary>Gets old left position.</summary>
		/// <returns type="Number">Left position in pixels.</returns>
		return this._props[4];
	},
	get_oldY: function()
	{
		/// <summary>Gets old top position.</summary>
		/// <returns type="Number">Top position in pixels.</returns>
		return this._props[5];
	},
	set_x: function(val)
	{
		/// <summary>Sets new left position.</summary>
		/// <param name="val" type="Number" integer="true">New left position in pixels.</param>
		this._props[2] = this._x = val;
	},
	set_y: function(val)
	{
		/// <summary>Sets new top position.</summary>
		/// <param name="val" type="Number" integer="true">New top position in pixels.</param>
		this._props[3] = this._y = val;
	}
}
$IG.MoveEventArgs.registerClass('Infragistics.Web.UI.MoveEventArgs', $IG.CancelEventArgs);





var _bugE = null;
function _bug4(v) { _bug3(v); _bugE.style.background = 'yellow'; }
function _bug3(v) { _bug("<br />" + v, true, "400px"); }
function _bug2(v) { _bug(v, true, "400px"); }
function _bug1(v) { _bug(v, false, "400px"); }
function _bug(v, a, l, t)
{
	if (!_bugE)
	{
		_bugE = document.createElement('DIV');
		document.body.insertBefore(_bugE, document.body.firstChild);
		var s = _bugE.style;
		s.position = 'absolute';
		s.zIndex = 10000;
		s.left = s.top = '0px';
		s.border = '1px dotted red';
		s.fontSize = '12px';
		s.fontFamily = 'courier';
	}
	if (l) _bugE.style.left = l;
	if (t) _bugE.style.top = t;
	_bugE.innerHTML = (a ? _bugE.innerHTML : '') + v;
}
//*/
