/* Enter any custom js calls here */

$(document).ready(function() {
    //Mouseover effect on work hero images
	$('a.hero').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 1);
	  $(this).hover(function () {
	    $span.stop().fadeTo(350, 0); //speed of effect, opacity 
	  }, function () {
	    $span.stop().fadeTo(350, 1); //speed of effect, opacity 
	  });
	});
		
	$('.menu li ul li a').click(function() {

		//remove 'active' class from all links, then add it to the current one
        $('.menu li ul li a').removeClass('active');
		$(this).addClass('active');
		
		//Set var to check rel of items
		thisItem 	= $(this).attr('rel');
		
		//If the item is not all, show only the selected ones
		if(thisItem != "all") {
		    //show selected
			$('#work a[rel='+thisItem+']').stop().animate({'height' : '426px', 'marginTop' : '10px', 'marginBottom' : '10px'}, function() { //first change size
			     $(this).animate({'opacity':1,'filter':''}); //then fade in
			 });
			//hide non-selected													
			$('#work a[rel!='+thisItem+']').stop().animate({'opacity':0,'filter':''}, function() { //first fade out
			     $(this).animate({'height' : 0, 'marginTop' : 0, 'marginBottom' : 0}); //then change size
			 });
            $('html, body').stop().animate({scrollTop: '0px'}, 1000); //scroll to top
            	
		} else {
			//show all
			$('#work a').stop().animate({'height' : '426px', 'marginTop' : '10px', 'marginBottom' : '10px'}, function() {
			     $(this).animate({'opacity':1,'filter':''});
             });
             $('html, body').stop().animate({scrollTop: '0px'}, 1000); //scroll to top
		}
		
		return false;
	})
});
