// Query String Manager - version 0.1
// Trevor Hayes thayes@shopcity.com

function QueryStringManager()
{
	this.query_string = window.location.search;
}

QueryStringManager.prototype.setField = function (field, value)
{
	var expression = new RegExp("[\?|&](" + field + "=)[^&]*");
	
	var found = expression.exec(this.query_string);
	
	if(found != null)
	{
		this.query_string = this.query_string.replace(expression, String(found).charAt(0) + escape(field) + "=" + escape(value));
	}
	else
	{
		var symbol = (this.query_string == "") ? "?" : "&";
		this.query_string += symbol + escape(field) + "=" + escape(value);
	}
}

QueryStringManager.prototype.commit = function ()
{
	window.location.search = this.query_string;
}
