/**
 * @version MyMarker.js version 1.0
 * @author Nathan Meurrens < nathan@meurrens.org >
 * @author Marc Meurrens < marc@meurrens.org >
 * @copyright Brussels, July 23, 2007 15:13
 * @license LGPL http://creativecommons.org/licenses/LGPL/2.1/
 * @requires ooTools.js (ooTools.extend used below)
 * @requires MyGLatLng.js (proper extensions of GLatLng used below)
*/

// Make sure GMarker is defined :
if(undefined === window.GBrowserIsCompatible) alert("Google API must be loaded prior to MyMap") ;

/**
 * Create a subclass MyMarker of GMarker
 * constructor + 3 instance variables
 */
function MyMarker(a,b)
{
	MyMarker.baseConstructor.call(this, a,b); // see ooTools.js
	this.arrInfo = false ;
	this.szMarkerLabel = "" ;
	this.fnsPositionCallBack = null ;
}


// inheritance subclass GMarker
ooTools.extend(MyMarker, GMarker); // see ooTools.js

// Add instance methods to MyMarker
// Accessors :
MyMarker.prototype.clearInfoArray = function() {this.arrInfo = false ;}
MyMarker.prototype.setInfoArray = function(arr) {this.arrInfo = arr ;}
MyMarker.prototype.setMarkerLabel = function(sz) {this.szMarkerLabel = sz;}
MyMarker.prototype.getMarkerLabel = function() {return this.szMarkerLabel;}
MyMarker.prototype.setPositionCallBack = function(fns) {this.fnsPositionCallBack = fns;}

/**
 * these 2 methods rely on modified GLatLng (see MyGLatLng.js) :
 * each GMarker, thus each MyMarker, has a Point of type GLatLng
 */
MyMarker.prototype.getLatLngHtmlInfo = function()
{
	var objGLatLng = this.getPoint() ;
	return objGLatLng.getLatLngHtmlInfo() ;
}

MyMarker.prototype.getLatLngTextInfo = function()
{
	var objGLatLng = this.getPoint() ;
	return objGLatLng.getLatLngTextInfo() ;
}
/**
 * calls google's openInfoWindowTabsHtml if usefull
 */
MyMarker.prototype.openInfoWindowRepeat = function()
{
	if(this.arrInfo) this.openInfoWindowTabsHtml(this.arrInfo) ;
}

/** 
 * function called after a modif of the position of the marker. calls either
 * google's openInfoWindowTabsHtml or google's openInfoWindowHtml in the later
 * case building a single info with Lat+Lng data furthermore, if zFns == true
 * and there is a callback function defined, then this callback is called
 * @param {Object} zFns
 */
MyMarker.prototype.openInfoWindowLatLng = function(zFns)
{
	if(this.arrInfo) this.openInfoWindowTabsHtml(this.arrInfo) ;
	else this.openInfoWindowHtml( this.getLatLngHtmlInfo() );
	if(zFns && this.fnsPositionCallBack)
	{
		var objGLatLng = this.getPoint() ;
		this.fnsPositionCallBack(	objGLatLng.getRoundLat() , 
									objGLatLng.getRoundLng() , 
									objGLatLng) ;
	}
}
// EoF
