function ItemManager () {
	this.items = new Object();
}

ItemManager.prototype.addItem = function (id, item) {
	this.items[id] = item;
	return id;
}

ItemManager.prototype.getItem = function (id) {
	return this.items[id];
}

ItemManager.prototype.updateItem = function (id, item) {
	this.items[id] = item;
}

ItemManager.prototype.deleteItem = function (id) {
	this.items[id] = null;
}

ItemManager.prototype.getItems = function () {
	var itemArray = new Array();
	console.log(this.items);
	for (var i in this.items) {
		console.log("Push: "+this.items[i]);
		itemArray.push(this.items[i]);
	}
	console.log("Num ret: "+itemArray.length)
	return itemArray;
}

var layerId =0;
function Layer (url, title, description) {
	this.url = url;
	this.title = title;
	this.description = description;
	this.gmapOverlay= null;
	this.id = layerId++;
	console.log("id:"+this.id);
}


Layer.prototype.getId= function () {
	return this.id;
}

Layer.prototype.getUrl = function () {
	return this.url;
}

Layer.prototype.setUrl = function (s) {
	this.url =s;
}

Layer.prototype.getTitle= function () {
	return this.title;
}

Layer.prototype.setTitle= function (s) {
	this.title=s;
}

Layer.prototype.getDescription= function () {
	return this.description;
}

Layer.prototype.setDescription= function (s) {
	this.description=s;
}

Layer.prototype.getGMapOverlay= function () {
	return this.gmapOverlay;
}

Layer.prototype.setGMapOverlay= function (s) {
	this.gmapOverlay=s;
}

Layer.prototype.toString = function () {
	return "Layer {title: "+ this.getTitle() + ", url:"+this.getUrl()+", description: "+this.getDescription()+"}";
}



function MapInfo (mapInfo) {

	var mapId     = mapInfo.Id;			
	var mapUserId = mapInfo.userId;				
	var mapUserName = mapInfo.userName;					
	var mapName   = mapInfo.mapName;
	var mapDesc   = mapInfo.mapDescription;		
	var mapPrivate= mapInfo.mapPrivate? mapInfo.mapPrivate: false;
	var mapShared = mapInfo.mapShared ? mapInfo.mapShared : false;
	var mapPublished = mapInfo.mapPublished ? mapInfo.mapPublished: false;		
	var mapTags      = mapInfo.mapTags ? mapInfo.mapTags : "";
	
	var mapZoom   = mapInfo.mapZoom;
	var mapCenter = mapInfo.mapCenter;
	
	var mapCenterLatLng = null;
	var mapAddresses = mapInfo.mapAddresses;
	var mapLayers    = mapInfo.mapLayers;
	
	this.getLocations= function () {
		return mapAddresses;
	}
	
	this.getLayers= function () {
		return mapLayers;
	}
		
	this.getCenter = function () {
		if (null != mapCenterLatLng) {
			return mapCenterLatLng;
		}
		if (null != mapCenter) {
			mapCenterLatLng = new GLatLng(mapCenter[0], mapCenter[1]);
			return mapCenterLatLng;
		}
		return null;
	}
	
	this.getZoom = function () {
		return mapZoom;
	}
	
	
	this.clear = function () {
		mapId     = 0;
		mapUserId = 0;
		mapUserName = null;
		mapName   = null;
		mapDesc   = null;
	}
	
	this.getId= function () {
		return mapId;
	}
	
	this.getUserId= function () {
		return mapUserId;
	}	
	
	this.getUserName= function () {
		return mapUserName;
	}		
	
	this.getName = function () {
		return mapName;
	}
		
	this.getDescription = function () {
		return mapDesc;
	}

	this.getPrivate= function () {
		return mapPrivate;
	}		
	
	this.getShared= function () {
		return mapShared;
	}	
	
	this.getPublished= function () {
		return mapPublished;
	}			
	
	this.getTags = function () {
		return mapTags;
	}
	
	this.setTags = function (t) {
		mapTags = t;
	}
	
	// see if the id of the map is the same one passed in
	this.isMyMap = function (id) {
		return (id == this.getUserId());
	}
	
	this.toString = function () {
		return "MapInfo: "+ this.getName();
	}
	

}
		
