// ============================================== //

		// EASING FUNCTIONS //

// ============================================== //

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
});


(function($){
		  
		  
	$.fn.preloadImages = function() {
		for(var i = 0; i<arguments.length; i++){
			$("<img>").attr("src", arguments[i]);
		};
	};
		
	// ============================================== //
	
			// FOOTER ROLLOVER //
	
	// ============================================== //	
	
	$.fn.setFooter = function(options) {
		var target = this.find('a');
		//
		$(target).hover(function () {
    		$(this).stop().animate({'marginTop':20},200,'easeOutQuad');
 		}, function () {
    		$(this).stop().animate({'marginTop':50},300,'easeOutQuad');	
  		});
	};
	
	// ============================================== //
	
			// SET HOME HOVER //
	
	// ============================================== //	
	
	$.fn.setHomeHover = function(options) {
		var target = this;
		//
		var this_class =$(target).attr('class');
		$(target).removeClass(this_class);
		//
		var new_class = this_class+"a";
		$(target).addClass(new_class);
		//
		var new_class_b = this_class+"_over";
		var prev_html = '<div id="home_recipe_over" class="'+new_class_b+'"><\/div>';
		$(target).before(prev_html);
		//
		$('#home_recipe_over').animate({'opacity':0},0.01).css({display:'block'}).hover(function () {
			$(this).stop().animate({'opacity':1},200);
 		}, function () {
    		$(this).stop().animate({'opacity':0},200);	
  		});
		
	};
	
	$.fn.setImageGallery = function(options) {
		//var tempArray = new Array();
		//
		var target = this;
		//
		target.find('li a').each(function(i){
			//tempArray.push($(this).attr('href'));
			$(this).preloadImages($(this).attr('href'));
			if(i!=0){
				$(this).find('img').animate({'opacity':.6},0.01);
			}
			$(this).click(function(){
				target.find('li a').each(function(i){
					$(this).find('img').animate({'opacity':.6},0.01);						  
				});
				$(this).find('img').animate({'opacity':1},0.01);		
				$('#main_image').attr('src', $(this).attr('href'));
				return false;
			});
		});
		//	
	};
	
	
	
})(jQuery);
//
$(document).ready(function(){
	$('#footer').setFooter();
	//
	if ($('#home_recipe').length) {
		$('#home_recipe').setHomeHover()
	};
	//
	if ($('div.column_right ul li').length) {
		$('div.column_right ul').setImageGallery()
	};
	
	
});
