jQuery(document).ready(function(){
	var kyleFletcher = {
		portfolioNavAjax: function() {
			jQuery('li.cat-item a, a#category-select').bind('click', function(e) {
				e.preventDefault();
				jQuery("#project-content").html("");
				jQuery.ajax({ 
					url: jQuery(this).attr('href'), 
					context: jQuery("#project-content"),
					dataType: "html",
					dataFilter: function(data) {
						var data = jQuery(data).find("#posts_by_category");
						return data;
					},
					beforeSend: function() {
						jQuery(this).css('background','transparent url("http://localhost/kylefletcher/wp-content/themes/kylefletcher/images/ajax-loader.gif") no-repeat center');
					},
					success: function(data) {
						jQuery(this).css('background','none');
						jQuery(this).html();
						jQuery(this).html(data);
						jQuery('.details h4').hide();
					} 
				});
			});
		},
		
		catMenuDropdown: function() {
			jQuery('li.categories').hover(function () {
		    	jQuery('ul', this).stop(true, true).delay(200).slideDown(200);
				jQuery(this).addClass('hover');
		  	}, function () {
		    	jQuery('ul', this).stop(true, true).slideUp(200);
				jQuery(this).removeClass('hover');
			});
			
			jQuery('li.cat-item').hover(function() {
				jQuery(this).addClass('hover');
			}, function() {
				jQuery(this).removeClass('hover');
			});
		},
		
		hoverHandler: function(el) {
			jQuery(el).hover(
			  function (el) {
			    jQuery(this).stop().addClass('hover').animate({'backgroundColor' : '#5FE3FF'}, 300);
			  },
			  function (el) {
			    jQuery(this).stop().removeClass('hover').animate({'backgroundColor' : '#FFFEE9'}, 300);
			  }
			);
		},
		
		gunSound: function() {
			var soundDiv = jQuery('#sound');
			var gunShot = soundDiv.find('audio')[0];

		    jQuery('#logo').hover(function(){
		       gunShot.play();
		    }, function(){
		       gunShot.stop();
		    });
		},
		
		portfolioHover: function() {
			jQuery('.details').live('mouseover mouseout', function(event) {
				if (event.type == 'mouseover') {
					jQuery(this).stop().animate({
						top: "-30px"
						}, {duration:300});
				} else {
					jQuery(this).stop().animate({
						top: "0px"
						}, {duration:300});	
				}
			});
		},
		
		portfolioLinkHandler: function() {
			jQuery('.details').live('click', function() {
				var href = jQuery(this).prev('a').attr('href');
				window.location = href;
			});
		}	
	}
	kyleFletcher.portfolioLinkHandler();
	kyleFletcher.portfolioHover();
	kyleFletcher.portfolioNavAjax();
	kyleFletcher.catMenuDropdown();
	kyleFletcher.gunSound();
	kyleFletcher.hoverHandler('#delicious ul li');
	kyleFletcher.hoverHandler('#contact-info li p');
	kyleFletcher.hoverHandler('.client-experience li');
	kyleFletcher.hoverHandler('.dream-clients li');
	

});
