(function($) {
	/**
	 * Selects an option by value
	 *
	 * @name     selectOptions
	 * @author   Mathias Bank (http://www.mathias-bank.de), original function
	 * @author   Sam Collett (http://www.texotela.co.uk), addition of regular expression matching
	 * @author   Extera s.r.l. (http://www.extera.com), addition of number matching
	 * @type     jQuery
	 * @param    String|RegExp value  Which options should be selected
	 * can be a string or regular expression
	 * @param    Boolean clear  Clear existing selected options, default false
	 * @example  $("#myselect").selectOptions("val1"); // with the value 'val1'
	 *
	 */
	$.fn.selectOptions = function(value, clear)
	{
		var v = value;
		var vT = typeof(value);
		var c = clear || false;
		// has to be a string or regular expression (object in IE, function in Firefox)
		if(vT != "string" && vT != "number" && vT != "function" && vT != "object") return this;
		this.each(
			function()
			{
				if(this.nodeName.toLowerCase() != "select") return this;
				// get options
				var o = this.options;
				// get number of options
				var oL = o.length;
				for(var i = 0; i<oL; i++)
				{
					{
						if(o[i].value == v)
						{
							o[i].selected = true;
						}
						else if(c)
						{
							o[i].selected = false;
						}
					}
				}
			}
		);
		return this;
	};
})(jQuery);