var posFound = -1;

function findPos(obj) {
	if (posFound > -1)
		return posFound;
	var left = 0;
	if (obj.offsetParent)
	{
		do
		{
			left += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	posFound = left;
	return left;
}

function movingFinger()
{
	this.direction = 1; // 1px forward
	this.margin = 25;
	this.offset = 90;
	this.offset_min = this.margin;
	this.offset_max = this.margin + 365;
	this.move = function(offset)
	{
		if (offset < this.offset_min)
			offset = this.offset_min;
		if (offset > this.offset_max)
			offset = this.offset_max;
		this.offset = offset;
		$('#days').html(offset - this.margin + 1);
		$('#amount').html(day[offset-this.margin]);
		$('#marker').css({'margin-left':offset-this.margin+5});
	}
}

var finger = new movingFinger();

function fingerAnimate()
{
	if (!finger.direction)
		return;
	else if (finger.offset == finger.offset_max)
		finger.direction = -1;
	else if (finger.offset == finger.offset_min)
		finger.direction = 1;
	finger.move(finger.offset + finger.direction);
	setTimeout('fingerAnimate()', 50);
}

$('#horizontal').ready(function(){
	fingerAnimate();
	$('#horizontal').mousemove(function(e){
		finger.direction = 0;
		finger.move(e.clientX - findPos(this));
	});
	//$('#id_interest_rate').numeric({allow:','});
	//$('#id_capitalization_days').numeric();
});