
function InfoArrow() {

	this.interval = 20;
	this.intervalId;
	this.onAfterRotate = null;

	this.angle = 0;
	this.endAngle = 0;
	this.deltaAngle = 5;
	this.delta = 0;
}

InfoArrow.prototype.setAngle = function(angle) {
	this.angle = angle;
	infoArrow.style.rotation = this.angle;
}

InfoArrow.prototype.rotate = function(end) {

	this.endAngle = end;
	if (this.angle > this.endAngle)
		this.delta = this.deltaAngle * -1;
	else
		this.delta = this.deltaAngle;

	var self = this;
	this.intervalId = setInterval(function() { self.doRotate(); }, this.interval);
}

InfoArrow.prototype.doRotate = function() {

	if (Math.abs(this.endAngle - this.angle) < Math.abs(this.delta)) {
		this.setAngle(this.endAngle);
		clearInterval(this.intervalId);
		if (this.onAfterRotate != null)
			this.onAfterRotate();
		return;
	}

	this.setAngle(this.angle + this.delta);
}

InfoArrow.prototype.setActionHandler = function(handler) {
	this.onAfterRotate = handler;
}

