/*
Created by Adrian Pelletier
http://www.designkindle.com
*/

// Begin jQuery
	
$(document).ready(function() {

	/* =Local Scroll
    -------------------------------------------------------------------------- */
    	
    	// Main Navigation
    	
    	$("#mainNav").localScroll();
    	
    	// "To the Top" links
    	
    	$(".toTheTop").localScroll();
    	
    /* =Cycle - Used for phone slideshow at the top of the page
    -------------------------------------------------------------------------- */
    
    	$("#slideshow").cycle({
			fx: 'fade',
			speed:  1000,
			timeout:  3500
		});

    /* =Small Work Thumbnails - Realistic Navigation Hover created by Adrian Pelletier - http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/
    -------------------------------------------------------------------------- */
    
    // Append shadow image to normal sized work item
    	
    	$(".workThumbs span").not("#featuredWork").append('<img class="shadow" src="images/work-shadow-sm.jpg" width="148" height="43" alt="" />');
    

    /* =Carousel
    -------------------------------------------------------------------------- */
    
    	// work thumbnails
    
    	var thumbsCallback = function(visible){
    		// If current group of thumbs is the last set, disable "next" button
    		if($(visible).hasClass("last")){
    			$(".nextWork").addClass("disabled");
    		}
    		// If current group of thumbs is first set, disable "prev" button
    		if($(visible).hasClass("first")){
    			$(".prevWork").addClass("disabled");
    		}
    	}
    $(".design").jCarouselLite({
               btnNext: "#designControls .nextWork",
               btnPrev: "#designControls .prevWork",
               speed: 900,
               visible: 1,
               circular: false,
               easing: "easeInOutExpo",
           afterEnd: thumbsCallback
       });

$(".photo").jCarouselLite({
               btnNext: "#photoControls .nextWork",
               btnPrev: "#photoControls .prevWork",
               speed: 900,
               visible: 1,
               circular: false,
               easing: "easeInOutExpo",
           afterEnd: thumbsCallback
       });


    /* =FancyBox Work Thumbnails
    -------------------------------------------------------------------------- */
	
    $(".workThumbs a[rel=design_group]" ).fancybox({
				'padding' : 0,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',	
				'titlePosition'		: 'outside',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});

	/* =Clear Form Fields
    -------------------------------------------------------------------------- */
		
		$("input, textarea").searchField();
						
// End document ready
	
});

