/**
* Dreamsocket
*  
* Copyright  2005 Dreamsocket.
* All Rights Reserved.  
*
* This software (the "Software") is the property of Dreamsocket and is protected by U.S. and
* international intellectual property laws. No license is granted with respect to the
* software and users may not, among other things, reproduce, prepare derivative works
* of, modify, distribute, sublicense, reverse engineer, disassemble, remove, decompile,
* or make any modifications of the Software without written permission from Dreamsocket.
* Further, Dreamsocket does not authorize any user to remove or alter any trademark, logo,
* copyright or other proprietary notice, legend, symbol, or label in the Software.
* This notice is not intended to, and shall not, limit any rights Dreamsocket has under
* applicable law.
*  
*/

var HttpUtils = {};

/**
*  @method 
* 		getQueryAsObject
* 
* @description
* 		returns the query string of a url as an object
* 
* @example
* 		The can access the query values of the folling url http://www.foo.com?prop1=val1&prop2=val2
* 		var query = HttpUtils.getQueryAsObject();
* 		alert(query.prop1);
* */
HttpUtils.getQueryAsObject = function()
{
	var vals = location.search.substring(1, location.search.length).split("&");
	var val;
	var i = vals.length;
	var result = {};

	while(i--)
	{
		val = vals[i].split("=");
		result[val[0]] = val[1];
	}
	
	return result;
}


/**
*  @method 
* 		convert2QueryString
* 
* @description
* 		converts a query object into a string
* 
* @example
*		var queryObj = {sampleProp1:"value1",sampleProp2:"value2"};
* 		var queryString = HttpUtils.convert2QueryString(queryObj);
* 		alert(queryString);
* */
HttpUtils.convert2QueryString = function(p_obj)
{
	var s = "";
	var each;
	for(each in p_obj)
	{
		s += each + "=" + p_obj[each] + "&";
	}
	
	return s;
}



