var URLUtil = {
    
	/**
     * Strips slashes from the specified string
     *
     * @param str String to strip slashes from.
     */
	stripSlashes : function(str)
	{
		if (str)
		{
			str=str.replace(/\\'/g,'\'');
			str=str.replace(/\\"/g,'"');
			str=str.replace(/\\0/g,'\0');
			str=str.replace(/\\\\/g,'\\');
		}
		
		return str;
	},
    
	/**
     * Converts a search string into an object with
     * key = >value pairs.
     *
     * @param string String prepended with a search param (?) whose
     * properties are separated by the ampersand (&)
     * @param decodeUrl Boolean indicating whether or not the key and value
     * should be passed through the decodeURIComponent() method.
     * @return Object created from the specified search string.
     */
	searchStringToObject : function(string /* String */, decodeUrl /* Boolean */)
	{
		var str = string.replace(/^(.+){0,1}(\?)/, '');
		return this.stringToObject(str, '&', decodeUrl);
	},

	/**
     * Converts a hash string to an Object.
     *
     * @param string String to convert to a has object.
     * @param seperator String used to separate the hash properties.
     * @param decodeUrl Boolean indicating whether or not the key and value
     * should be passed through the decodeURIComponent() method.
     * @return Object created from the specified hash string.
     */
	stringToObject : function(string/* String */, seperator/* String */, decodeUrl/* Boolean */)
	{
		if (!seperator)
			seperator = ";";
		var obj = {};
		if (!string)
			return obj;
		var arr = string.split(seperator);
		var len = arr.length;
		for (var i = 0; i < len; i++)
		{
			var keyValue = arr[i];
			var pieces = keyValue.split("=");
			var key = decodeUrl ? decodeURIComponent(pieces[0]) : pieces[0];
			var value = decodeUrl ? decodeURIComponent(pieces[1]) : pieces[1];
			// Attempt to convert string values to primitives
			if (value == "true")
				value = true;
			else if (value == "false")
				value = false;
			else if (value.toFloat().toString() == value)
				value = value.toFloat();
			obj[key] = value;
		}
		return obj;
	},

	/**
     * Converts an object to a hash string.
     *
     * @param object Object to convert.
     * @param seperator String used to separate the object properties.
     * @param encodeURL Boolean indicating whether or not the key and value
     * should be passed through the encodeURIComponent() method.
     * @return String created from the specified hash object.
     */
	objectToString : function(object/* Object */, seperator/* String */, encodeURL/* Boolean */)
	{
		var payload = '';
		var first = true;
		if (!seperator)
			seperator = ";";
		for (var name in object)
		{
			if (first)
				first = false;
			else
				payload += seperator;
			var value = object[name];
			if (encodeURL)
				name = encodeURIComponent(name);
			// Attempt to detect and convert primitives
			if (typeof value == 'string')
				payload += name + "=" + (encodeURL ? encodeURIComponent(value) : value);
			else if (typeof value == 'number')
			{
				payload += name + "=" + (encodeURL ? encodeURIComponent(value.toString()) : value.toString());
			}
			else if (typeof value == 'boolean')
				payload += name + "=" + (value ? "true":"false");
		}
		return payload;
	}
};
