var $j = jQuery.noConflict();

$j(document).ready(function() {
			
			
	/*--------------------------------*/
	/*            50 Badges           */
	/*--------------------------------*/		
		$j('#viewer').removeClass('loading');
		$j('#imgviewer').animate({opacity: 1}, 5000);
		
		$j('#pictoral #container').ready(function() {
			//Begin LAT Slider
			//Get length of images plus spacing between
			var sliderLength = 8; //slider begins at 8 to compensate for padding
			
			$j("div#container").attr("id", "sliderContainer").css({ position:'absolute', left: '0px'}).height(273).appendTo("div#viewer");
			var pictoLength = $j("#imgviewer li img").length;
			
			// Commented out by Thom
			$j("#imgviewer li img").eq(pictoLength-1).addClass('last');
			//alert(pictoLength);
		
	
			//add each image's width plus its margin
			$j("#imgviewer li img").each(function() {
						sliderLength = parseInt(sliderLength + $j(this).width());
						//console.log('completed');
						//console.log(sliderLength);
						$j('#sliderContainer').width(sliderLength);
						
					if ( $j(this).is('.last') ) {
						$j('#buttonLeft img, #buttonRight img').fadeIn(1000);
					}
			});
			
			
			//change the copy below the viewer to the content in the alt tag
			
			$j("#imgviewer li img").mouseover(function() {
				
				if($j(this).attr("alt")) {
					$j(this).attr('style','cursor:pointer');
					$j('#backstory').attr('innerHTML',$j(this).attr("alt"));
					//$j(this).attr("alt","");
					Cufon('h1',{fontFamily: 'Serif'});
				}
			});
		

		
			//compute length of slider to get accurate speed
			//change first integer to # of pixels per second
			//currently 800px 
			var s = (sliderLength/200) * 1000;
		
			//use these to check to see we get numbers we like
			//console.log(sliderLength);
			//console.log(s);
			//console.log(duration);
			//console.log(speed);
			if ($j("div#sliderContainer").length > 0) {
				var travel = parseFloat($j("div#sliderContainer").css('left').replace("px", ""));
				
				//create animation function
			 jQuery.fn.latslide = function(dir) {  
				//get lr position of container 
				var travel = parseFloat($j("div#sliderContainer").css('left').replace("px", ""));
				//move left
				if (dir =="left") {
					var speed = s * (((travel + sliderLength) - 936)/sliderLength);
						$j("div#sliderContainer").animate ({
							left:"-" + (sliderLength - 936) + "px"},
							speed,
							"linear");

				} else if (dir =="right") {
					var speed = s * (((sliderLength - travel) - sliderLength)/sliderLength);
						$j("div#sliderContainer").animate ({
							left: 0 + "px"},
							speed,
							"linear");

				}
			 };
				
			} 
			
		
			//create function for hover buttons
			$j("#buttonLeft a img").hover(function() {
				$j("div#sliderContainer").latslide("right");
			}, function() {
				$j("div#sliderContainer").stop();
			});
			
			$j("#buttonLeft a img").click(function() {
				return false;
			});
		
		
			//-------------------------
			//-------HOVER RIGHT-------
			$j("#buttonRight a img").hover(function() {
				$j("div#sliderContainer").latslide("left");
			}, function() {
				$j("div#sliderContainer").stop();
			});
			
			$j("#buttonRight a img").click(function() {
				return false;
			});		
		
			$j("#imgviewer p").fadeOut(0);
		
			$j("#imgviewer li").hover(function() {
				$j(this).children("p").fadeIn(500);
			}, function() {
				$j(this).children("p").fadeOut(500);
			});
	

		});
 // END PICTORIAL
		
		

			
			
});
<!-- ph=1 -->

