/**
 * Enhancements
 * - Label: offset, class
 */

var Spot = Class.create();

Spot.prototype = {	
	id: null,
	category: null,
	point: null,
	marker: null,
	tooltip: null,
	window: null,
	label: "",
	
/**
 * Creates a new Spot. A spot is group of items (marker, tooltip, infoWindow, label) 
 * that represent a mark in the map
 *
 * @constructor
 * @param {String} id 			Unique identifier. It must have the format: category.id 
 *													(e.g. poi_567).
 * @param {Float} latitude 	Latitude coordinate
 * @param {Float} longitud 	Longitude coordinate
 * @param {String} category Category. It must have the format: category.subcategory.
 *													(e.g. poi.theaters)
 * @param {String} html 		The HTML contents for the infoWindow. If it is null the 
 *													infoWindow will not be created.
 * @param {String} label 		The text displayed beneath the icon. If it is null the 
 *													label will not be created.
 * @param {String} title 		The text displayed when the icon is hovered. If it is 
 *													null the tooltip will not be created.  
 * @param {Object} options 	A container for optional arguments:
 *    		
 */	
	
	initialize: function(id, latitude, longitude, category, title, html, label, options) {
		this.id = id;
		this.category = category;		
		this.point = new GLatLng(latitude, longitude);
		options = options == null ? {} : options;				
		
		//Set icon				
		
		if (options.icon == null) {
			if (options.iconId == null) {
				options.icon = Icons.build(category);
			} else {
				options.icon = Icons.get(options.iconId);
			}
		}
		//Set marker type
		
   	if (typeof(label) == 'string' && label != '') {
			//options.labelClass : markerLabel, "labelOffset": new GSize(5, -16)						   		
			options.labelText = label == null ? '' : label;
			options.labelClass = 'map-label';
			options.labelOffset = new GSize(-16,0);   		
    	this.marker = new LabeledMarker(this.point, options);		
   	} else {
   		this.marker = new GMarker(this.point, options);
   	}				
				   
   	//Set tooltip
   	
   	this.tooltip = null;
   	if (title != null || title != '') {
    	this.tooltip = new ToolTip(this.marker, title);   		
   	}
   	
   	//Set infoWindow

   	this.html = null;
   	if (typeof(html) == 'string' && html != '') {
    	this.window = new InfoWindow(html, 288, 105, this.marker);
    	this.html = html;
   	}   	    
	}
}
