AjaxQuery.IdentifyMap=function(item, json){
	var map=MapFactory.GetMM(item);
	json.mapId=map.options.mapId;
};
AjaxQuery.IdentifyLayer=function(item, json){
	var l=MapFactory.GetLayer(item);
	json.layerId=l.options.id;
};
AjaxQuery.IdentifyItem=function(item, json){
	//TODO: for polys and layers
	var mapItem=MapFactory.AbstractItem(item);
	if(mapItem instanceof GeoliveMarker && MapFactory.HasTag(mapItem, "ID")){
		json.markerId=MapFactory.TagValue(mapItem, "ID");
	}
	if((mapItem instanceof GeoliveShape) && MapFactory.HasTag(mapItem, "ID")){
		json.shapeId=MapFactory.TagValue(mapItem, "ID");
	}
	if(mapItem instanceof Layer){
		json.layerId=mapItem.options.id;
		json.name=mapItem.options.name;
		json.description=mapItem.options.description;
		json.style=mapItem.options.style;
	}
};

/**
 * Static function retrieves all the updateable values for saveable items and 
 * pushes them into the json object
 */
AjaxQuery.ItemAttributes=function(item, json){
	var mapItem=MapFactory.AbstractItem(item);
	if(mapItem instanceof GeoliveMarker){
		json.marker={
				coordinates:[mapItem.getLatLng().lat(),mapItem.getLatLng().lng()],
				name:mapItem.getTitle(),
				style:mapItem.getIcon(),
				description:mapItem.getDescription()
		};

		if(mapItem.tags)
			json.tags=mapItem.tags;
	}
	if(mapItem instanceof GeoliveShape){
		json.shape={
				coordinates:[],
				name:mapItem.name,
				style:{
			lineColor:mapItem.lineColor,
			lineWidth:mapItem.lineWidth
		}
		};
		if(mapItem instanceof GeolivePolygon){
			json.shape.style.polyColor=mapItem.polyColor;
			json.shape.style.outline=mapItem.outline;
		}

		var j=mapItem.item.getVertexCount();
		var i;
		for(i=0;i<j;i++){
			json.shape.coordinates.push([mapItem.item.getVertex(i).lat(),mapItem.item.getVertex(i).lng()]);
		}
		if(mapItem.item.description!=null){
			json.shape.description=mapItem.item.description;
		}
		if(mapItem.tags)
			json.tags=mapItem.tags;
	}
};

