// THE SILLY CONTENT FADE-IN

$(document).ready(function(){
 	$('#mainContent').hide().fadeIn(2000);
 });
 
 
 
 // THE SLIDESHOW
 
 $(document).ready(function(){
	var Idx = 1;
	var IntervalKey;
	var ChangeImage = function(){
		//If the image still animating, stop it and start the new one
		$("#MainImage").ImageStop(false,true);
		$("#MainImage").ImageSwitch({
			Type: "FadeIn",
			NewImage: $(".TnImage").eq(Idx).attr("src").replace("tn-",""),
			Speed: 500,
			EffectOriginal: true,  
			});		
		//Mark which thumbnail is displaying
		$(".TnImage").css("opacity","1");
		$(".TnImage").eq(Idx).css("opacity","0.5");
		//Set the next image will be display
		Idx++;
		if(Idx>1){
			Idx = 0;
		}
		//Start preload the next image
		$.ImagePreload($(".TnImage").eq(Idx).attr("src").replace("tn-",""));			
	};
	//When a thumbnail's clicked
	$(".TnImage").click(function(){
		Idx = $(".TnImage").index(this);
		ChangeImage();
	});		
	
	
});



 // SCROLLERS - URGH 

$(function()
{
	$('.scroll-pane').jScrollPane(
		{
			verticalDragMinHeight: 190,
			verticalDragMaxHeight: 190,
			horizontalDragMinWidth: 21,
			horizontalDragMaxWidth: 21
		}
	);
});
