// My faster marker implementation, copyright © 2010 Tim Alston.

liteMarker.prototype = new google.maps.OverlayView();

function liteMarker(latlng, image, offsetx, offsety, map, title, url) {
	this.latlng_ = latlng;
	this.image_ = image;
	this.offsetx_ = offsetx;
	this.offsety_ = offsety;
	this.map_ = map;
	this.element_ = null;
	this.title_ = title;
	this.url_ = url;
	this.setMap(map);
}

liteMarker.prototype.onAdd = function() {
    var img = document.createElement("img");
    img.src = this.image_;
    img.style.position = "absolute";
    img.style.cursor = "default";
    img.title = this.title_;

    if (this.url_) {
        var a = document.createElement("a");
        a.style.position = "absolute";
        a.href = this.url_
        a.title = img.title
        a.appendChild(img);
        img.style.cursor = "pointer";
        this.element_ = a;
    } else {
        this.element_ = img;
    }
    
    var panes = this.getPanes();
    panes.overlayImage.appendChild(this.element_);
}

liteMarker.prototype.draw = function() {
	var overlayProjection = this.getProjection();
	var pos = overlayProjection.fromLatLngToDivPixel(this.latlng_); 
	var element = this.element_;
	element.style.left = (pos.x - this.offsetx_) + 'px';
	element.style.top = (pos.y - this.offsety_) + 'px';
}

liteMarker.prototype.onRemove = function() {
	this.element_.parentNode.removeChild(this.element_);
	this.element_ = null;
}