$( function() {
	$( '.category' ).click( function() {
		$( this ).toggleClass( 'active' )
		$( this ).siblings( '.dropdown' ).toggle();
		$( this ).find( '.indicator' ).toggleClass( 'indicator-active' );
		return false;
	} );
	$( '#dock > li' ).stop().css('opacity', 0.5);
	$( '#dock > li' ).hover( function() {
			$( '.latest' ).stop().fadeOut( 'fast' );
			$( this ).stop().children( 'span' ).fadeIn( 200 );
			$( this ).stop().css('opacity', 1);
				}).bind( "mouseleave", function() {	
			$( this ).stop().css('opacity', 0.5);	
			$( this ).stop().children( 'span' ).fadeOut( 200 );
		} );
		$( '#dock' ).bind( "mouseleave", function() {
			$( '.latest' ).stop().fadeIn( 500 );
		} );

/* jQuery Water Hover Button - by Demian Luis Villanueva - Inspiration: http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/ - Inspiration: http://www.elegantthemes.com/preview/ePhoto/ */			
	$('.logo_slide').hover(function(){
	$(".background_slider", this).stop().animate({top:'-299px'},{queue:false,duration:350});
		}, function() {
		$(".background_slider", this).stop().animate({top:'0px'},{queue:false,duration:200});
	});
	
/* tabbed content by GayaDesign.com - http://www.gayadesign.com/diy/animated-tabbed-content-with-jquery */
var TabbedContent = {
	init: function() {	
		$(".tab_item").mouseover(function() {
		
			var background = $(this).parent().find(".moving_bg");
			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});
			
			TabbedContent.slideContent($(this));
			
		});
	},
	
	slideContent: function(obj) {
		
		var margin = $(obj).parent().parent().find(".slide_content").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
		
		$(obj).parent().parent().find(".tabslider").stop().animate({
			marginLeft: margin + "px"
		}, {
			duration: 300
		});
	}
}
		TabbedContent.init();

/* Fading on hover */	

	$('.fadethis').append('<span class="hover"></span>').each(function () {
		 var $span = $('> span.hover', this).css('opacity', 0);
			$(this).hover(function () {
			$span.stop().fadeTo(300, 1);
		}, function () {
			 $span.stop().fadeTo(300, 0);
		});
	});

			
/* Sliding Boxes and Captions with jQuery - http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/ */	

	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'100px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:300});
	});
	
	
/*  jQuery Inline Form Labels * http://trevordavis.net/blog/tutorial/jquery-inline-form-labels */

	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('').addClass('focused');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');	
			}
		});
	});
	$('textarea[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('').addClass('focused');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');	
			}
		});
	});	

/*  Diming List - http://stackoverflow.com/questions/760280/jquery-fading-dimming-other-list-elements-when-one-is-hovered-over-im-90-there */

	  var $ul = $("ul#post_container")

	  $ul.hover(function(){
	    $("li", $ul).stop().fadeTo("fast", 0.5)

	    $("li", $ul).hover(function(){
	        $(this).stop().fadeTo("fast", 1.0)
	    },function(){
	        $(this).stop().fadeTo("fast", 0.5)
	    })
	  },function(){
	    $("li", $ul).stop().fadeTo(500, 1)
	  })
	  

/*  Simple Tabs w/ CSS & jQuery - http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery */	  
	//When page loads...
	$(".sidebar_tab_content").hide(); //Hide all content
	$("ul.sidebar_tabs li:first").addClass("active_tab").show(); //Activate first tab
	$(".sidebar_tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.sidebar_tabs li").click(function() {

		$("ul.sidebar_tabs li").removeClass("active_tab"); //Remove any "active" class
		$(this).addClass("active_tab"); //Add "active" class to selected tab
		$(".sidebar_tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});



});	