
//////////////////////////////////////////
//  Delay Plugin
/////////////////////////////////////////
(function($){
	$.fn.delay = function(time, callback){
		jQuery.fx.step.delay = function(){};
		return this.animate({delay:1}, time, callback);
	}
})(jQuery);
//////////////////////////////////////////
//  Absolute Center Alignment
/////////////////////////////////////////
(function($){
	$.fn.absoluteCenter = function(){
		this.each(function(){
			
			var $this = $(this);
			
			var $parent = $this.parent();
			var $top = ( $parent.height() - $this.height() ) / 2;
			var $left = ( $parent.width() - $this.width() ) / 2;
			
			$this.css({'marginTop' : $top, 'marginLeft' : $left}); 

		});
		return this; 
	}
})(jQuery);

(function($){
	$.fn.hzCenter = function(){
		this.each(function(){
			
			var $this = $(this);
			
			var $parent = $this.parent();
			var $left = ( $parent.width() - $this.width() ) / 2;
			
			$this.css({'marginLeft' : $left}); 

		});
		return this; 
	}
})(jQuery);
//////////////////////////////////////////
//  Thumbnail Hover Effects
/////////////////////////////////////////
(function($){
	$.fn.subtleFade = function(){
		this.css({'opacity' : .80 });
		this.each(function(){
			var $this = $(this);
			$this.hover(function(){
				$this.stop().animate({'opacity': 1});
			}, function(){
				$this.stop().animate({'opacity': .85});
			});
		});
		return this; 
	}
})(jQuery);
//////////////////////////////////////////
//  Navigation Highlighter
/////////////////////////////////////////
(function($){
	$.fn.selectNav = function() {
		this.bind('click', function() {

			var $this = $(this);
			
			var $navWrap = $this.parent('ul');
			var $item = 'a';

			$this.parents($navWrap)
			.find($item)
			.removeClass('selected')
			.end()
			.end()
			.addClass('selected');
		});
		return this;
	}
})(jQuery);
//////////////////////////////////////////
//  Accordion Navigation
/////////////////////////////////////////
(function($){
	$.fn.slideNav = function() {
		var $closeHeight = this.height();
		this.parent().css({'height': $closeHeight + 3}).addClass('slide');
		this.siblings().css({'opacity' : 0});
		this.bind('click', function() {
			
			var $this = $(this);
			
			var $pages = $this.siblings('ol.pages').height();
			var $pager = 70
			
			var $openHeight = $pages + $pager
			
			if ($this.parent('li').hasClass('open')){ 
				$this.parent()
				.removeClass('open')
				.animate({'height' : $closeHeight}, 500, 'easeOutCirc')
				.find('ol.pages').animate({'opacity' : 0}, 400);
			}
			else {
				$this.parent()
				.addClass('open')
				.animate({'height' : $openHeight}, 800, 'easeInQuint')
				.find('ol.pages').animate({'opacity' : 1}, 250);
				$this.parent()
				.siblings().removeClass('open')
				.animate({'height' : $closeHeight}, 700, 'easeOutCirc')
				.find('ol.pages').animate({'opacity' : 0}, 600);
			}

		});
		return this; // chain ganger
	}
})(jQuery);
