
jQuery(document).ready(function(){  
 
            //Work Thumb Hover
            $(".workItem h3").hide();
            $("div.workItem").hover(function () {
                $(this).find("img").animate({
                    opacity: .5
	                }, 200);
                $(this).find("h3").fadeIn(150);
                },function(){
                $(this).find("img").animate({
                    left: "0px",
                    opacity: 1                  
                }, 200);
                $(this).find("h3").fadeOut(150);
            });           
        
        
        //AJAX loader for work section
        jQuery(document).ready(function(){
			
			//When clicking this link, load the content
			$(".loadWork").fancybox({
				'overlayShow'		:  true,
				'transitionIn'		: 'Elastic',
				'onComplete'        : function(){$("#fancybox-overlay").css({'height': $(document).height(), 'width': $(window).width()})}
			});
		});
		
		jQuery(document).ready(function(){
						$('#close').live("click", function (e){
							e.preventDefault();
							$.fancybox.close();
						});
						
						$('#largeleftArrow').live("click", function(e) {
							e.preventDefault();
							$.fancybox.prev();
						});
						$('#largerightArrow').live("click", function(e) {
							e.preventDefault();
							$.fancybox.next();
						});
						
					});

        
        	/* Scrolling goodness for the arrows 
        	
			$(function() {
			
			    function scroll(direction) {
			
			        var scroll, i,
			                positions = [],
			                here = $(window).scrollTop(),
			                collection = $('div');
			
			        collection.each(function() {
			            positions.push(parseInt($(this).offset()['top'],10));
			        });
			
			        for(i = 0; i < positions.length; i++) {
			            if (direction == 'leftArrow' && positions[i] > here) { scroll = collection.get(i); break; }
			            if (direction == 'rightArrow' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
			        }
			
			        if (scroll) {
			            $.scrollTo(scroll, {
			                duration: 750,
			            });
			        }
			
			        return false;
			    }
			
			    $("#leftArrow, #rightArrow").click(function() {        
			        return scroll($(this).attr('id'));        
			    });
			
			    $(".scrolltoanchor").click(function() {
			        $.scrollTo($($(this).attr("href")), {
			            duration: 750
			        });
			        return false;
			    });
			
			});
			
			*/
			
		
			/* Scroll to the next/prev grid row when clicking the arrows	
			jQuery(document).ready(function(){ 
				$('#rightArrow').click(function () {
					$.scrollTo( '+=200px', 500 );
				});
				
				$('#leftArrow').click(function () {
					$.scrollTo( '-=200px', 500 );
				});
			});
			
			*/
			
		
		 //Key Nav for scrolling – This simulates a click for the scrolly function above 
            $(document.documentElement).keyup(function (event) {
                var direction = null;               
                //Left
                if (event.keyCode == 37) {
                    $('#leftArrow').click();
                    	console.log('left arrow pressed')	
                     }
                //Right 
                if (event.keyCode == 39) {
                    $('#rightArrow').click();
                    	console.log('right arrow pressed')
                     }
              });
              
          
              
         // Filter parameters for isotope
		jQuery(document).ready(function(){  
		  
		  	//find the thing we want to filter within
		    var $container = $('#mainContent');
		
		    // filter buttons
		    $('#filter_work a').click(function(){
				
		      var selector = $(this).attr('data-filter');
  
  				if( selector == 'sites, illustration, ads' )
				{
					console.log( 'one' );
					
					selector = '.sites, .illustration, .ads';	
					
					$(".workItem").find("h3 a").attr("rel", 'all');
				}
				
				else {
					
					console.log( 'two' );
					
					$(".workItem").find("h3 a").attr("rel", selector);
									}
				
				$container.isotope({ filter: "."+selector });
				  
				$(".isotope-hidden").find("h3 a").attr("rel", "empty");
	
		      return false;
			  
		    });
		    
		    
		      // switches selected class on buttons
		      $('#filterContainer').find('.option-set a').click(function(){
		        var $this = $(this);
		
		        // don't proceed if already selected
		        if ( !$this.hasClass('selected') ) {
		          $this.parents('.option-set').find('.selected').removeClass('selected');
		          $this.addClass('selected');
		        }
		
		      });
		
		
		    $(function(){
		
		      $container.isotope({
		      	// which thing do we want to apply this shiz too
		        itemSelector : '.workItem',
		        // which bit of fanciness to we want to apply to the shiz after filtering 
		        layoutMode : 'masonry'
		      });
		      
		    });
		    
		});
            
			        
        /* Work Filter drop down menu
		
        $(document).ready(function () {
			$('a.filter_dropdown').click(function () {
			$('ul.filter_work').fadeToggle(150);
		});
	});
        
        */
        

           
});
