
/*
The following describes the methods and their purposes.

	StringDictionary(): 
		This is the main constructor for the object.

	addItem( key, value ):
		This method adds a new key/value pair to the collection.

	getItem( key ):
		This method returns the value of a specificed key. If the item
		doesn't exist, it will return undefined.

	removeItem( key ):
		This method removes a key from the collection.

	count():
		This method retuns a count of all the keys in the collection.

	getKeys():
		This method retuns an array of the keys in the collection.

	getValues():
		This method retuns an array of the values in the collection.

	getQueryString( leadingCharacter ):
		This method returns a url safe query string of the key/values in 
		the collection. It will pad the results strings leading character 
		with the leadingCharacter passed into the method. 

*/

function StringDictionary() {
	this._StringDictionary = new Array();
}

StringDictionary.prototype.addItem = function( key, value ) {
	if ( key != "" && key != null && 
	     value != "" && value != null ) 
	{
		this._StringDictionary[ key ] = value;
	}
};

StringDictionary.prototype.getItem = function( key ) {
	if ( this._StringDictionary.hasOwnProperty( key )	) {
		return this._StringDictionary[ key ];
	}
	else {
		return undefined;
	}
};

StringDictionary.prototype.removeItem = function( key ) {
	if ( key != "" && key != null )
		delete this._StringDictionary[ key ];
};

StringDictionary.prototype.count = function() {
	var totalItems = 0;
	
	for( var key in this._StringDictionary ) {
		if ( this._StringDictionary[ key ] != null && this._StringDictionary.hasOwnProperty( key ) ) 
			totalItems++;
	}
	
	return totalItems;
};

StringDictionary.prototype.getKeys = function() {
	var collectionKeys = new Array();
	
	for( var key in this._StringDictionary ) {
		if ( this._StringDictionary.hasOwnProperty( key ) )
			collectionKeys.push( key );
	}
	
	return collectionKeys
};

StringDictionary.prototype.getValues = function() {
	var collectionValues = new Array();
	
	for( var key in this._StringDictionary ) {
		if ( this._StringDictionary.hasOwnProperty( key ) ) 
			collectionValues.push( this._StringDictionary[ key ] );
	}
	
	return collectionValues;
};

StringDictionary.prototype.getQueryString = function( leadingCharacter ) {
	var results = leadingCharacter;

	for( var key in this._StringDictionary ) {
		if ( this._StringDictionary[ key ] != null && this._StringDictionary.hasOwnProperty( key ) )
			results += escape( key ) + '=' + escape( this._StringDictionary[ key ] ) + '&';
	}
	
	return results.slice( 0, results.length - 1 );	
};
