;(function($)
{
	
$.querystring = function(qs)
{
	var data = {};
	var e,
	    d = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
	    q = qs.substring(1),
	    r = /([^&=]+)=?([^&]*)/g;
	
	while (e = r.exec(q))
		data[d(e[1])] = d(e[2]);
	return data;
};

$.buildQuerystring = function(data)
{
	// Build querystring.
	var qs = '?';
	var key;
	for(key in data)
	{
		if(data[key] != null)
		{
			if(data[key] === true)
				qs += '&' + encodeURIComponent(key);
			else if(typeof(data[key]) != 'boolean')
				qs += '&' + encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
		}
	}
	qs = qs.replace('?&', '?');
	qs = (qs == '?') ? '' : qs;
	return qs;
};

})(jQuery);
