jQuery(document).ready(function(){
	// change $ -> J to prevent confilcts with Picnik scripts
	//var J = jQuery.noConflict();
	
	// initilize drop down navigation using superfish plugin
	//$(".nav ul").superfish();
	
	//initialize login form toggle link
	if($(".nav_login")) {
		$(".nav_login").click(function () {
			$("#login_form_inner").toggle();
			$(this).toggleClass("active");
			return false;
		});
	}
	
	//add ajax form submission for ingredient form
	$("#form_ingredient_add").submit(function(){
		$.post("ajax_ingredient_add.cfm",{
			product_ID: $("#form_ingredient_add #product_ID").val(),
			ingredient: $("#ingredient").val(),
			price_extra: $("#price_extra").val(),
			ingredient_extra: $("#ingredient_extra").val()
		}, function(feedback) {
			$("#status_ingredients").replaceWith(feedback);
			// refresh ingredients list below form
			$("#ingredient_list").load("ajax_ingredients_list.cfm", {product_ID: $("#form_ingredient_add #product_ID").val()}, function() {
				if(typeof sIFR == "function") {
					sIFR.replaceElement("h2", named({sFlashSrc: "./sIFR/rockwell_extra_bold.swf", sColor: "#333"}));
					sIFR.replaceElement("h3", named({sFlashSrc: "./sIFR/rockwell_extra_bold.swf", sColor: "#333", sCase: "upper"}));
				};
			} );
		});
		return false;
     }); 
	
	//set onclick to product_name to show product_details
	$(".product_details").hide();
	$(".product_name").bind("click", function(e) {
		$(".product_details").hide();
		$(this).parent().next(".product_details").show("slow");
	});
	
	$(".date").datepicker({ 
		dateFormat: "yy-mm-dd",
		defaultDate: "-25y", 
		minDate: "-90y", 
    	maxDate: "-1d",
		showOn: "both", 
		buttonImage: "/images/icons/calendar.gif", 
		buttonImageOnly: true 
	});
	
});
