﻿$(document).ready(function () {
	
	$('.print').click(function() {
			window.print();
			return false;
		});
	
	// Display On Sale Ingredients (add JS in Recipes_Ingredient_Add_B.inc)
	$('.IngredientOnSale').click( function() { 
			url = $(this).attr("href");
			number = $(this).attr("data");
			target = '#OnSale' + number;
			
			$(target).load(url).slideToggle("fast");
			return false;
	});
	
	// Action Buttons (Add to Cookbook, Rate & Review, Email Recipe)
	$('.ActionButton').click( function() { ActionButton(this); return false; });
	
	// Bottom Rate & Review Button
	$('#BottomRate').click( function() { ActionButton(this); });
	
	// Keeping the above DRY'ed up
	function ActionButton(element) {
		url = $(element).attr("url");
		if( ! url ){
			url = $(element).attr("href");
		}
		$('#ActionEntry').empty();
		$('#ActionEntry').load(url).slideDown("fast");
		url = '';
	}
	
	// Main Shopping List Add
	$('#ShoppingListForm').ajaxForm({target: '#ShoppingListActions'});
	
	
}); // document.ready

