/** MapItemCollection
* A container for holding all map items
* 
* @class MapItemCollection
*	@constructor
* @returns {void}
*/
var MapItemCollection = function() {
	this.mapItems = new Object();		// Struct to hold map items based on their map item ID
}

	
MapItemCollection.prototype = {

	/** add
	* Method to add a map item to the collection
	*
	* @method add
	* @param {int} mapItemID
	* @param {String} name
	* @param {String} address
	* @param {String} img
	* @param {String} url
	* @param {GMarker | GPolygon | GPolyline} gItem
	* @return {void}
	*/
	add : function( mapItemID, name, address, img, url, wirelessLocation, gItem ) {
		if( !this.mapItems[ mapItemID ] )
			this.mapItems[ mapItemID ] = new MapItem( mapItemID, name, address, img, url, wirelessLocation );
		
		this.mapItems[ mapItemID ].addGItem( gItem );
	},
	
	
	/** get
	* Returns a map item by ID
	* 
	* @method get
	* @param {int} mapItemID
	* @return {MapItem}
	*/
	get : function( mapItemID ) {
		return this.mapItems[ mapItemID ] || null;
	},
	
	
	/** show
	* 
	*
	* @method show
	* @param {Array} mapItemIDs
	* @returns {void}
	*/
	show : function( mapItemIDs ) {
		// Show map items sent in the mapitemIDs argument
		for( var i = 0, numMapItems = mapItemIDs.length; i < numMapItems; i++ ) {
			if( this.mapItems[ mapItemIDs[ i ] ] ) {
				this.mapItems[ mapItemIDs[ i ] ].show();
			}
		}
	},
	
	
	
	/** hideAll
	* Hides all map items
	*
	* @method hideAll
	* @returns {void}
	*/
	hideAll : function() {
		for( var mapItemID in this.mapItems ) 
			this.mapItems[ mapItemID ].hide();
	},
	
	
	/** showMapItemInfoWindow
	*
	*
	* @method showMapItemInfoWindow
	* @param {int} mapItemID
	* @return {void}
	*/
	showInfoWindow : function( mapItemID ) {
		var mapItem = this.mapItems[ mapItemID ];
		
		// If the map item was found
		if( mapItem ) {
			mapItem.show();						// Make sure this map item is shown, in the case of using the marker search
			mapItem.openInfoWindow();	// Open its info window with its address
		}
	}
}