GPolyline.prototype.getPoints = function() {
	var r = new Array();
	for ( var i = 0; i < this.points.length / 2; i++ )
		r.push( this.getPoint( i ) );
	return r;
};

GMap.prototype.animate = function(p,d,l,m) {
	this.pause = ( l == null ? 3000 : l );
	this.markerPause = ( m == null ? 6000 : m )
	if ( p.points != null )
		p = p.getPoints();
	this.points = p;
	this.cur = 0;
	this.done = d;
	this.move();
};

GMap.prototype.move = function() {
	this.closeInfoWindow();
	var t;
	var p = this.points[ this.cur ];
	if ( p.x != null ) {
		t = this.pause;
		this.recenterOrPanToLatLng( p );
	} else {
		if ( p[ GEvent.getPropertyName("click") ].length > 1 ) {
			GEvent.trigger( p, "click" );
			t = this.markerPause;
		} else {
			t = this.pause;
			this.recenterOrPanToLatLng( p.point );
		}
	}
	
	var self = this;
	if ( ++this.cur < this.points.length )
		setTimeout( function(){self.move();}, t );
	else if ( this.done != null )
		setTimeout( function(){self.done();}, t );
};

