
jQuery(document).ready(function(){  
   			
   			//Document's ready. Let's Do This.
   			
   			//Homepage Slider Animation
	    		var curr = 1;
	    		var numThumbs = $(".post-thumbnail").size(); // How many thumbs?
	    		var tL = numThumbs +1 // Add one for "go back" panel
	    		
	    		function scrollRight() {
		    		$("a .next").click(function () {
		      		// If the current panel is less than the total panels, do your thing
		      		if (curr < tL ) {	
		      		  curr ++;
		      		$("#home .post").animate({
		      			left: "-=990"
		      		}, 300)
		      		return false;

		      		 }
		      		
		      		// Fade next arrows upon reaching the end 
		      		if (curr == tL) {
		      		$("img.next").fadeOut();
	   				} 
		   			
		   			})
	   			}
	   			
	   			// If there's more than 1 panel, let's run the function
	   			if (tL > 1 ) {
	   				scrollRight();
	   			}
	   			
   			//Homepage Arrow Fade
	    		$(".post-thumbnail a .next").fadeTo(200, .2);
	    		$("#footer .back-up").fadeTo(200, .2);
	    		$("#home .post").hover(
	    		function () {
	      		$(this).find("img.next").fadeTo(200, 1);
	      		},
	      		function () {
	      			$(this).find("img.next").fadeTo(200, .2);
	   			});
   			//Homepage Slide Startover
	   			$(".start-over").click(function () {
	   			$("img.next").fadeIn();
	   			curr = 1;
	      		$("#home .post").animate({
	      			left: "0"
	      		}, 300)
	      		return false;
	   			});	   			
   			//Go Back Up
	   			$("#footer .back-up").hover(
	    		function () {
	      		$(this).fadeTo(150, 1);
	      		},
	      		function () {
	      			$(this).fadeTo(250, .2);
	   			});
	   			//The Click, Nice & Smooth
	   			$(".back-up a").click(function () {
				var anchor = $(this).attr("href");
				$("html, body").animate({scrollTop: $("#wrapper").offset().top }, 200, "swing")
				return false;
				});
   			
   			//Open That Contact Form - Talk to Us!
	   			$("#contact").hide();
	   			$(".contact-button, a.con-tog").click(function () {
	   			$("#contact").slideToggle()
				return false;
	   			});
	   			$("a.contact-close").click(function () {
	   			$("#contact").slideUp()
	   			return false;
	   			});
   			
   			//Contact Close Button
   			$("a.contact-close span").hide();
   			$("a.contact-close").hover(function () {
   			$("a.contact-close span").fadeIn(200);
   			});
   			$("p.allowed-tags").hide();

   			//The Sharing Bar - (Sharing is Caring)
	    		$("li.share, .close-sb").click(
	    		function () {
	   				$("li.share-bar").slideToggle("fast")
	   				return false;
	      		},
	      		function () {
	   				$("li.share-bar").slideToggle("fast")
	   				return false;
	   			});
	   			
   			//Comment Form
   				//  $("#commentform").hide();
	    		//  $("a.add").click(
	    		//  function () {
	   			//  	$("#commentform").slideToggle("fast")
	   			//  	return false;
	      		//  },
	      		//  function () {
	   			//  	$("#commentform").slideToggle("fast")
	   			//  	return false;
	   			//  });			
   			
   			//Work Thumb Hover
   			$(".fav-thumb h3").hide();
   			$("div.fav-thumb").hover(function () {
	      		$(this).find("img").animate({
	      			bottom: "-50px",
	      			opacity: 1
	      		}, 200);
	      		$(this).find("h3").fadeIn(150);
	      		},function(){
	      		$(this).find("img").animate({
	      			bottom: "0px",
	      			opacity: 1	      			
	      		}, 200);
	      		$(this).find("h3").fadeOut(150);
      		}); 			
   		
   		//Work Filtering
   		
   		$(function() {

			var newSelection = "";
			
				$("#work-filter a").click(function(){
			
				    $(".fav-thumb").fadeTo(100, 0.5);
			
					$("#work-filter a").removeClass("current");
					$(this).addClass("current");
			
					newSelection = $(this).attr("rel");
			
					$(".fav-thumb").not("."+newSelection).hide();
					$("."+newSelection).show();
					
					//Let em know something happened			
				    $(".fav-thumb").fadeTo(200, 1)
				    return false;
			
				});
			
			});

   		//Single Project Arrow Fade
		$("li.panel a .next").fadeTo(0, .2);
		$("li.panel").hover(
		function () {
  		$(this).find("img.next").fadeTo(200, 1);
  		},
  		function () {
  			$(this).find("img.next").fadeTo(200, .2);
			});
	

		//Project Slider Animation
				var curr = 1;
	    		var numPanels = $("li.panel").size(); //Total Panels
	    		var tP = numPanels -1; // -1 to compensate
	    		
	    		function slidePanel() {
		    		$("li.panel a .next").click(function () {
		      		
		      		// if the total panels is less than the current, then do your thing.
		      		if (curr < tP ) {	
		      		curr ++;
		      		$("li.panel").animate({
		      			left: "-=740"
		      		}, 300)
		   			return false;
 
		      		}
		      		
					// Fade next arrows upon reaching the end  
		      		if (curr == tP) {
		      		$("img.next").fadeOut();
	   				} 
		   			
		   			})
	   			}
	   			
	   			// If there's more than 1 panel, let's run the function
	   			if (tP > 1 ) {
	   				slidePanel();
	   			}
		
		//Project Slide Startover
	   			$(".start-over").click(function () {
	      		$("#work-det li.panel").animate({
	      			left: "0"
	      		}, 300)
	      		return false;
	   			});
		
		//Hide all imgs with title of thumb
		$("img.attachment-full[title='thumb']").parent("li").hide();
	
		//Search box text clear
	  	$('#s').one("focus", function() {
		  $(this).val("");
			});
		
		//Somewhat of a Keyboard Nav - Thanks, @rem
		$(document.documentElement).keyup(function (event) {
		    var direction = null;
			
		    if (event.keyCode == 37) {
		      // slide back left
		      	if (curr > 1) {
		     	$("#home .post").animate({
	      			left: "+=330"
	      		}, 250);
	      		curr --;
		    	}
				
		    } 
		    if (event.keyCode == 39) {
		      // slide right 1 panel
		      	$("#useyerarrows").fadeOut();		      	
		     	if (curr < tP || curr < tL) {
		     	$("#home .post").animate({
	      			left: "-=330"
	      		}, 250);
	      		curr ++;
		    	}
		    }
		
		    
		  });
		  
		  //Equalize Archive Sidebar Height			
			// get height of the post section
			var getHeight = $(".all-posts").height();
			//compensate for offset
			var newHeight = getHeight + 149;
			//set the new height
			$('#sidebar').css('height', newHeight);


		// All done, shawty.
			
});// JavaScript Document
