$(document).ready(function(){
	
	$('.clone_me').clone().insertAfter('.clone_me');
	$('.clone_me').clone().insertAfter('.clone_me');
	$("ul#thumbs_list li a img").fadeTo(300, 0.4);
	$("ul#thumbs_list li a img").hover(function(){
	$(this).stop().fadeTo(300, 1.0);
	},function(){
	$(this).stop().fadeTo(300, 0.4);
	});
	$("body.section-5 #thumb_button, body.section-6 #thumb_button, body.section-8 #thumb_button, body.section-7.Tearsheets #thumb_button").fadeTo(450, 1.0);
	$("#wrap_test").slideToggle(450);
	$("a#thumbs").click(function(){
		$(this).text($(this).text() == 'Show thumbnails' ? 'Hide thumbnails' : 'Show thumbnails');
		$("#wrap_test").slideToggle(450);
		$('#d-image').toggleClass('no_arrows');
		return false;
	});

	var myTimer = {};
	
	// Wait for #start to be clicked...
	$("body.section-5 ul.nav.sectional li ul li a, body.section-6 ul.nav.sectional li ul li a, body.section-7 ul.nav.sectional li ul li a, body.section-8 ul.nav.sectional li ul li a ").click(function(){

		var toLoad = $(this).attr('href');
		$("#d-thumbs").slideToggle(450);
		$("body.section-5 #thumb_button, body.section-6 #thumb_button, body.section-8 #thumb_button, body.section-7.Tearsheets #thumb_button").fadeTo("slow", 0.0);

		// Set the timer for 2 seconds
		myTimer = $.timer(450,function(){
			
			// Display hello message when timer goes off
			window.location = toLoad;

		// Optional function to call when timer is canceled
		});
		
		return false;
	});

// Scroll Thumbs
	$('ul#thumbs_list');
	$('div#thumb_next a').click(function() {
		$('ul#thumbs_list').animate({left: '-=793px'}, 500);
		return false;
	});
	
	
	$('div#thumb_prev a').click(function() {
		var noAnim = 0
		var thumbs = $("ul#thumbs_list");
		var thumbPos = thumbs.position();
		
		if (thumbPos.left == noAnim){
			return false;
		} else {
		  
			$('ul#thumbs_list').animate({left: '+=793px'}, 500);
		}
		
		return false;
	});
});

