/**
 * Written by chardcastle
 * as a replacement for timeline api
 * 
 * Depends on 
 * jquery-latest-min.js
 * ui.core-min.js
 * ui.draggable-min.js
 */

if(!timeline){
	var timeline = {}	
}
timeline = {
	init: function(){
		if ($("#topInner").html() != null) {
			$("#topInner").animate({
				marginLeft: 0
			}, 500, null, function(){
				$("#push").animate({
					width: 0
				}, 500, null, dragInit);
			});
		}
		function dragInit(){
			//set up the timeline
			$("#topInner").draggable({
				"axis": "x",
				stop: function(ev, ui){
					var unit = $("#topInner").offset().left;
					var x = 7; // use this number to ajust the position of focus on time zone					
					var toMove = (unit - unit - unit / x);
					//alert(toMove);
					// push the focus over
					$("#push").animate({
						width: toMove
					}, 500);
					// years out of range - revert back
					if ($("#topInner").position().left > 0) {
						// too far over to right snap back.
						$("#topInner").animate({
							left: 0
						}, 200);
					}
				}
			});
		}
	}	
}			