window.addEvent("domready", function ()
{
	// config options
	var link_class = "featurelink";
	var featured_id_prefix = "sec";
	var filmstrip = "rubberband";
	var feature_class = "feature";
	var initialSection = "sec1";
	var feature_tag = "a";
	
	var features = $$("." + link_class);
	var currentSection = initialSection;
	features.addEvent("click", function (e)
	{
		moveStrip(featured_id_prefix + this.name, true);
		e.stop();
	});
	features.addEvent("mouseover", function (e)
	{
		goto(featured_id_prefix + this.name, false);
		e.stop();
	});
	
	$(filmstrip).tween("top", 0);
	
	function findDistance (newSection)
	{
		if(newSection)
		{
			var distance = 0;
			lis = $(filmstrip).getElementsByTagName(feature_tag);
			var found = false;
			for (var i = 0; i < lis.length; i++) {
				var li = lis[i];
				if(li == $(newSection))
				{
					break;
				}
				if(li.className == feature_class)
				{	
					distance += li.offsetHeight;
				}	
			}
			return distance;
		}
		return false;
	}
	var myFx = new Fx.Tween($(filmstrip));
	function moveStrip (section, bypassTween)
	{
		newSpot = 0 - findDistance(section);
		myFx.pause();
		if(bypassTween)
		{
			$(filmstrip).setStyle("top", newSpot);
			currentSection = section;
		}
		else
		{
			myFx.start('top', newSpot);
			currentSection = section;
		}
	}
	function goto (section, noanimation)
	{
		lastSection = currentSection;
		if(section != currentSection)
		{
			moveStrip(section, noanimation);
		}
		
		
	}
});