var myMLSC = null;

CJP.MapLocationSetCollection = Class.create();
CJP.MapLocationSetCollection.prototype = {

	initialize: function() {		
		myMLSC = this;	
		
		//Create the data object constructs for holding data retrieved from the server
		this.currentMapLocationSet = null;
		this.allMapLocationSets = new Array();			
	},

	getMapLocationSetCount: function(){return this.allMapLocationSets.length;},
	
	getMapLocationSet: function(lookupKey){
		for(var i = 0; i < this.allMapLocationSets.length; i++){
			if(this.allMapLocationSets[i].lookupKey == lookupKey){return this.allMapLocationSets[i];}}
		return null;
	},
	
	addMapLocationSet: function(lookupKey, mapXML, locationXML){
		var mapLocationSet = this.getMapLocationSet(lookupKey);
		
		if(mapLocationSet == null){
			mapLocationSet = new CJP.MapLocationSet(lookupKey, mapXML, locationXML);
			this.allMapLocationSets[this.allMapLocationSets.length] = mapLocationSet;
		}else{
			mapLocationSet.setMapXML(mapXML);
			mapLocationSet.setLocationsXML(locationXML);
		}  
		this.currentMapLocationSet = mapLocationSet;
	},
	
	removeMapLocationSet: function(lookupKey){
		var mapLocationSet = this.getMapLocationSet(lookupKey);
		
		if(mapLocationSet != null){
			for(var i = 0; i < this.allMapLocationSets.length; i++){
				if(this.allMapLocationSets[i].lookupKey == lookupKey){
					this.allMapLocationSets = this.allMapLocationSets.resizeArray(this.allMapLocationSets, i, 1);
					if(this.currentMapLocationSet == mapLocationSet){this.currentMapLocationSet = null;}
					return;
				}
			}
		}	
	}	
};




CJP.MapLocationSet = Class.create();
CJP.MapLocationSet.prototype = {
	initialize: function(lk, mdoXML, ldoXML) {	
		this.lookupKey = lk;
		this.map = null;
		this.locations = null;
		
		this.setMapXML(mdoXML);
		this.setLocationsXML(ldoXML);
	},
	
	setMapXML: function(mapXML){this.map = new CJP.Map(mapXML);},
	
	setLocationsXML: function(locationXML){this.locations = new CJP.LocationCollection(locationXML);}
}
