
var SPEECH_MARKER_TEXT = 0;
var SPEECH_MARKER_IMAGE = 1;


function SpeechMarker(type, point) {
	this.selected = false;
	this.type 	= type;
	this.trunTitle = '';
	this.point = point;
}

SpeechMarker.prototype = new GOverlay();

SpeechMarker.prototype.setPosition = function(point){
	this.updateType();
	
	this.point = point;
	this.redraw(true);
}

SpeechMarker.prototype.setType = function(type){
	this.type = type;	
}

SpeechMarker.prototype.updateType = function(){
	if (this.type == SPEECH_MARKER_TEXT){
		this.nClass	 	=	'tlabel';	
		this.hClass	 	=	'tlabels';	
	} else {
		this.nClass	 	=	'ilabel';	
		this.hClass	 	=	'ilabels';
	}
	
	this.selected = false;
	this.div_.className = this.nClass;
}
												
SpeechMarker.prototype.initialize = function(map) {
	this.map_ 	= map;
	var div 	= document.createElement("div");
	div.style.position = "absolute";
	div.className	= this.nClass;
	
	this.div_	= div;
	
	map.getPane(G_MAP_MARKER_PANE).appendChild(div);
}

SpeechMarker.prototype.setContent = function(html){
	this.div_.innerHTML = html;	
}

SpeechMarker.prototype.remove = function() {
  this.div_.parentNode.removeChild(this.div_);
}


SpeechMarker.prototype.redraw = function(force) {
  // We only need to redraw if the coordinate system has changed
  if (!force) return;

  // Calculate the DIV coordinates 
  var c1 = this.map_.fromLatLngToDivPixel(this.point);

  //height
  var height 	= parseInt(this.div_.offsetHeight);
  var offset	= 5 - (this.type*2);

  // Now position our DIV 
  this.div_.style.left 		= c1.x - offset + "px";
  this.div_.style.top 		= c1.y - 2 - height  + "px";
  
  //MS.debug(this.div_.style.left+' '+this.div_.style.top);
}

