//create the args object!
//(function($) {
function NameValueCollection() {
	//create the nvc arrays
	this.names = [];
	this.values = [];
};

//extend the jquery object to prototype a jscript args object
$.extend(NameValueCollection.prototype, {
	
	remove: function(name) {
		//cycle the names array till we find the correct index for the value
		for(var i=0;i<this.names.length;i++) {
			if(this.names[i] == name) {
				this.values.pop(values[i]);
				this.names.pop(names[i]);
			}
		}	
	},
	
	//function to add a value to the array
	add: function(name,value) {
		this.names.push(name);
		this.values.push(value);
	},
	
	//function to get a value by its name
	getValue: function(name) {
		//cycle the names array till we find the correct index for the value
		for(var i=0;i<this.names.length;i++) {
			if(this.names[i] == name) {
				return this.values[i];
			}
		}
	},
	
	//function used to init the array
	init: function() {
		//init the nvc arrays
		this.names = [];
		this.values = [];
	},
	
	//function return the array as a delimited string
	getString: function(delimiter) {
		//ok if we have no delimiter assume its & for the QS
		if(!delimiter)
			delimiter = '&';
		
		var retval = '';
		
		//cycle the names array and build the string
		for(var i=0;i<this.names.length;i++) {
			retval += this.names[i] + '=' + this.values[i] + delimiter;
		}
		
		//no trim the trailing delimiter from the args string
		retval = retval.substr(0,retval.length-1);
		
		//return the build string
		return retval + '';
	}
});