$(document).ready(function() {	


	// Scroll the Gallery Page
	$("#slider_buttons").localScroll({
		target:		"#slider",
		axis:		'xy',
		duration:	500
	});
	
	// Scroll the nav links on all standard pages
	$("#nav_content").localScroll({
		duration:	500	
	});
	
	// Scroll the Gallery Page
	$("#nav_gallery").localScroll({
		target:		"#gallery_content",
		duration:	500
	});	


	
	// Image galleries on Gallery page
	$(".galleries").each(function(i) {
		$(this).after('<div class="cf imgSelect imgSelect'+i+'">').cycle({
			fx:     	'fade',
			speed:		500,
			pager:  	'.imgSelect' + i,
			next:		'.galleries' + i,
			sync:		1,
			timeout:	0,
			
			// callback fn that creates a thumbnail to use as pager anchor 
		    pagerAnchorBuilder: function(idx, slide) { 
		        return '<a href="#"><img src="' + slide.src + '" /></a>'; 
		    } 			
		});
	});    	


	
	// Assigns a selected class to a nav_gallery link when clicked 	
	$("#nav_content a" ).click(function(){
		$(this).addClass('selected').parents().siblings().children("a").removeClass('selected');
	});

	$("#nav_gallery a" ).click(function(){
		$(this).addClass('selected').parents().siblings().children("a").removeClass('selected');
	});

	$("#slider_buttons a:first").addClass("selected");
	
	$("#slider_buttons a").click(function(e) {
	  $(".selected").removeClass("selected");
	  $(this).addClass("selected");
	});
	    
    $("#tab_0").click(function() {
      setTimeout("$.backstretch('http://conceptillumination.com/wp-content/themes/ci_dark2011/images/background/1.jpg', {speed: 400})", 600);
    });

	$("#tab_1").click(function() {
      setTimeout("$.backstretch('http://conceptillumination.com/wp-content/themes/ci_dark2011/images/background/2.jpg', {speed: 400})", 600);
	});
	
	
	$("#tab_2").click(function() {
      setTimeout("$.backstretch('http://conceptillumination.com/wp-content/themes/ci_dark2011/images/background/3.jpg', {speed: 400})", 600);
	});
	
	
	$("#tab_3").click(function() {
      setTimeout("$.backstretch('http://conceptillumination.com/wp-content/themes/ci_dark2011/images/background/4.jpg', {speed: 400})", 600);
	});




	// Assigns a selected class to a product_nav link when clicked 	
	$("#product_nav ul li a").click(function(){
		$(this).addClass('selected').parents().siblings().children("a").removeClass('selected');
	});
	          
	// The product_nav goes to 50% opacity on page load
	$("#product_nav").fadeTo("slow", 0.5);
	
	// product_nav goes to full opacity on hover and returns to half opacity on mouse out
	$("#product_nav").hover(function(){
	    $(this).stop().fadeTo("slow", 1.0);
	},
	function(){
	    $(this).stop().fadeTo("slow", 0.3);
	});		

	// show and hide the product_nav links menu
	$("#button_dropmenu").click(function(){
		  $("#product_nav ul").fadeToggle("slow");
		  $(this).toggleClass("active");
	});
	
});


