// FMMarker est une extension des markers de GoogleMap de façon à afficher
// systématiquement une info sur le candidat en même temps que la 'punaise'.

function FMMarker(gLatLng,icon,title)
{
    this.inheritFrom = GMarker;
    this.inheritFrom(gLatLng,icon);
    this.point_ = gLatLng;
    this.icon_ = icon;
    this.title_ = title;
}

// FMMarker implémente l'interface GOverlay

FMMarker.prototype = new GMarker(new google.maps.LatLng(this.point_));
FMMarker.prototype.initialize = InitializeMethod;
FMMarker.prototype.remove = RemoveMethod;
FMMarker.prototype.copy = CopyMethod;
FMMarker.prototype.redraw = RedrawMethod;
FMMarker.prototype.hide = DoHide;
FMMarker.prototype.show = DoShow;

function InitializeMethod(map)
{
    GMarker.prototype.initialize.call(this, map);

    // on crée les div représentant notre marker
   
    // Le texte
    var divTitle = document.createElement("div");
    divTitle.style.position = "absolute";
    var title = document.createTextNode(this.title_);
    divTitle.appendChild(title);
     divTitle.style.backgroundColor = "#FFFF00";
    divTitle.style.color = "#000000";
    divTitle.style.fontSize = "10px";

    map.getPane(G_MAP_MARKER_PANE).appendChild(divTitle);
    
    this.map_ = map;
    this.divTitle_ = divTitle;
 }
 
//-----------------------------------------------
function RemoveMethod()
{
    GMarker.prototype.remove.call(this);
   this.divTitle_.parentNode.removeChild(this.divTitle_);
}
//-----------------------------------------------
function CopyMethod()
{
    return new FMMarker();
}
//-----------------------------------------------
function RedrawMethod(force)
{    
   if (force)
   {
        GMarker.prototype.redraw.call(this,force);
            
        var point = this.map_.fromLatLngToDivPixel(this.point_);
        var x = point.x;
        var y = point.y;
        
        var xOffset = this.divTitle_.offsetWidth-2;
        var yOffset = this.divTitle_.offsetHeight-2;
        this.divTitle_.style.left = (x -xOffset)+"px";
        this.divTitle_.style.top = (y -yOffset)+"px";
    }
}
//--------------------------------------------------------------------------------------
function DoHide()
{
    GMarker.prototype.hide.call(this);
    this.divTitle_.style.visibility = 'hidden';
}
//--------------------------------------------------------------------------------------
function DoShow()
{
    GMarker.prototype.show.call(this);
    this.divTitle_.style.visibility = 'visible';
}
//--------------------------------------------------------------------------------------
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();