/**
 * Creates a new PositionedContent.
 * Consists of all data important to display in spatial context.
 * 
 * TODO new constructor: PositionedContent(id, positionId, type, title, geo, address, description, image, url)
 * 
 * @param {String} id The id of the content.
 * @param {String} positionId The id of the position, if already existing.
 * @param {String} title The title to display.
 * @param {MaceAddress} address The address. 
 * @param {MaceGeo} geo The Geo position.
 * @param {String} description A description to display.
 * @param {String} image An image to display.
 * @param {String} url The URL to link to.
 * @param {PositionedContentType} type The type, i.e. an MACE internal or an external.
 */
function PositionedContent(id, positionId, title, address, geo, description, image, url, type) {
	// content id
	this.id = id;
	// position id
	this.positionId = positionId;
	// type (LOM, external, etc)
	this.type = (type != null) ? type : PositionedContentType.MACE;

	// title and position
	this.title = title
	this.geo = geo;
	
	// optional data
	this.address = address;
	this.description = description;
	this.image = image;
	this.url = url; // REVISIT URL not in use. See MaceLocation.js#createMarker click handler 
}

PositionedContent.prototype.hasImages = function() {
	return (this.images) ? this.images.length > 0 : false;
}

PositionedContent.prototype.isSelected = function() {
	return this.type == PositionedContentType.MACE_SELECTED;
}

PositionedContent.prototype.isExternal = function() {
	return this.type >= PositionedContentType.EXTERNAL;
}

PositionedContent.prototype.toString = function() {
	return this.title ? this.title : this.id; 
}

function PositionedContentType() {
}

// TODO Remove MACE_SELECTED (this is view!)
PositionedContentType.MACE_SELECTED			= 1;
PositionedContentType.MACE					= 2;
PositionedContentType.EXTERNAL				= 10;
PositionedContentType.EXTERNAL_GEONAMES		= 11;
PositionedContentType.EXTERNAL_FLICKR		= 12;
PositionedContentType.EXTERNAL_DBPEDIA		= 13;
PositionedContentType.EXTERNAL_FREEBASE		= 14;

function MaceAddress(street, city, state, zipCode, country) {
	this.street = street;
	this.city = city;
	this.state = state;
	this.zipCode = zipCode;
	this.country = country;
}

function MaceGeo(latitude, longitude) {
	this.latitude = latitude;
	this.longitude = longitude;
}
MaceGeo.prototype.toString = function() {
	return "(" + this.latitude + ", " + this.longitude + ")";
}