﻿// $Id: spotlight.js 2271 2008-06-02 20:35:50Z michaelw $

if (jQuery) {
	$(document).ready(function() {
		//----------spotlight navigation----------/
		spot_max=6;
		spot_current = 3;
		spot_slideWidth = 234;
		
		spot_next = spot_current;
		spot_next++;
		//init current;
		$spot = $("#spotlight");
		//alert('showing spotlight ' + spot_current);
		ga_tagSpotlightViewed(spot_current, SpotTracker);
		//alert('showing spotlight ' + spot_next);
		$spot.find("ul").css({left: (-(spot_current-1) * spot_slideWidth)+"px"});
		ga_tagSpotlightViewed(spot_next, SpotTracker);
		
		function spot_slideto(num) {
			tox = -(num-1) * spot_slideWidth;
			$spot.find("ul").animate({ left: tox+"px" }, "normal");
			
			$("#spotNumbers",$spot).find("a.current").removeClass("current");
			n=(num+1)/2;
			n--;
			$("a:eq("+n+")", "#spotNumbers").addClass("current");
			
			spot_current = num;
			//alert('sliding to ' + spot_current);
			ga_tagSpotlightViewed(spot_current, SpotTracker);
			ga_tagSpotlightViewed(spot_current+1, SpotTracker);
		}
		
		$("#spotNumbers",$spot).find("a").each(function() {
			$(this).click(function() {
				rel = parseInt($(this).attr("rel"));
				spot_slideto(rel);
				this.blur();
				return false;
			});
		});
		
		$(".spotFooter",$spot).find("a.prev").click(function(){
			if (spot_current > 1) {
				spot_slideto(spot_current-2);
			}
			this.blur();
			return false;
		});
		$(".spotFooter",$spot).find("a.next").click(function(){
			if (spot_current < (spot_max-1)) {
				spot_slideto(spot_current+2);
			}
			this.blur();
			return false;
		});
	});
}
