var htmlHelper =
{
	/** 
	*	Check all checkboxes with specified name
	*
	*	@param		name		string				checkboxes name
	*	@param		ob			element				'select all' checkbox object
	*
	*	@return		void
	*/
	checkall: function(name, ob)
	{
		var checkboxes = document.getElementsByName(name);

		if (!checkboxes)
			return;
		
		if (checkboxes.length>0)
		{
			for(i=0; i<checkboxes.length; i++)
				checkboxes[i].checked = ob.checked;
		}
		else
		{
			checkboxes.checked = ob.checked;
		}
	},

	/** 
	*	Move cursor to the start of the textarea
	*
	*	@param		ob			element			textarea element
	*
	*	@return		void
	*/
	moveCaretToStart: function(ob)
	{
		if (ob.createTextRange)
		{
			var r = ob.createTextRange();
			r.collapse(true);
			r.select();
		}
	},

	/** 
	*	Move cursor to the end of the textarea
	*
	*	@param		ob			element			textarea element
	*
	*	@return		void
	*/
	moveCaretToEnd: function (ob)
	{
		if (ob.createTextRange)
		{
			var r = ob.createTextRange();
			r.collapse(false);
			r.select();
		}
	},

	/** 
	*	Delete all options of the dropdown select element.
	*
	*	@param		dropdown		element				dropdown element
	*
	*	@return		bool	success
	*/
	removeOptions: function (dropdown)
	{
		dropdown.options.length=0;
		return true;
	},

	/** 
	*	Add new options to the specified dropdown list.
	*
	*	@param		dropdown	element				dropdown element
	*	@param		options		list<value:title>	dropdown options
	*
	*	@return		bool		success
	*/
	addOptions: function (dropdown, options)
	{
		$H(options).each(function(pair)
		{
			var option = document.createElement("OPTION");
			dropdown.options.add(option);
			option.innerHTML = pair.value;
			option.value = pair.key;
		});

		return true;
	},

	/** 
	*	Select option with specified value.
	*
	*	@param		dropdown	element		dropdown element
	*	@param		value		string		value of the option to be selected
	*
	*	@return		bool		success
	*/
	selectOption: function (dropdown, value)
	{
		$A(dropdown.options).each(function(option)
		{
			if (option.value==value)
			{
				dropdown.selectedIndex = option.index;
				return true;
			}
		});
		return false;
	}
}