$(document).ready(function(){
	
	// Activate supersleight so that transparent pngs show as transparent pngs in IE6
	$('body').supersleight();
	
	$('.gallery_link').lightBox();
	
	$('#masthead_right').cycle({
		fx: 'fade',
		speedIn: 3000,
		speedOut: 3000
	});
	
	$('.btn_calendar').live('click', function() {
		
		var calendar_id = $(this).attr('rel');
		
		$.post("scripts/php/btn_calendar.php", { calendar_id: calendar_id }, function(data) {
			$('#calendar_mini').html(data);
		});
		
	});

	
	/*
	// Activate supersleight so that transparent pngs show as transparent pngs in IE6
	$('body').supersleight();
	
	// Hide the "previous" recipe arrow
	$('#recipe_arrow_previous_btn').hide();
	
	// Work out the height of the text box
	var text_height = $('#scroll_text').height();
	
	// If the text boxes height is greater than 337...
	if (text_height > 337) {
		// Make the up and down arrows visible
		$('#scroll_buttons').show();
		// Move the text to the right to make way for the up and down buttons
		$('#scroll_container').css('margin-left', '20px');
	}
	
	// If the contact form button is clickes
	$('#btn_contact').live('click', function() {
		// Submit the form to a php script
		$.post("scripts/php/btn_contact.php", $('#frm_contact').serialize(), function(data) {
			// If an error is returned...
			if (data.error != "") {
				// Display the error
				$('#contact_feedback').html(data.error);
			}
			// If a success message is returned...
			else if (data.success != "") {
				// Inform the user that the message has been submitted successfully
				$('#contact_feedback').html(data.success);
			}
		}, "json");
		
	});
	
	// If one of the two recipe navigation arrows are clicked on...
	$('.recipe_arrow').live('click', function() {

		// Assign the requested recipe id to a variable
		var recipe_id = $(this).attr('rel');
		
		// Submit the recipe id to a php script
		$.post("scripts/php/btn_recipes.php", { "recipe_id": recipe_id }, function(data) {
			
			// Output the recipe details in the relevant containers
			$('#recipe_name').html("<h3>"+data.recipe_name+"</h3>");
			$('#recipe_desc').html(data.recipe_desc);
			$('#recipe_ing').html(data.recipe_ing);
			
			// If the value of the previous recipe id is empty...
			if (data.recipe_id_previous == "") {
				// Hide the previous recipe button as the user can't go back any further
				$('#recipe_arrow_previous_btn').hide();				
			}
			else {
				// Show the previous recipe button
				$('#recipe_arrow_previous_btn').show();
				// Set the value of the previous recipe buttpn
				$('#recipe_arrow_previous').attr("rel", data.recipe_id_previous);
			}
			
			// If the value of the next recipe id is empty...
			if (data.recipe_id_next == "") {
				// Hide the next recipe button as the user can't go on any further
				$('#recipe_arrow_next_btn').hide();				
			}
			else {
				// Show the next recipe button
				$('#recipe_arrow_next_btn').show();
				// Set the value of the next recipe buttpn
				$('#recipe_arrow_next').attr("rel", data.recipe_id_next);
			}
			
			// Need to reinstantiate the sifr as it gets lost when jQuery updates the HTML page as it does above
			sIFR.replace(bl_home, {
				selector: 'h3',
				css: '.sIFR-root { color:#FFFFFF; font-size:30px; margin:0px; padding:0px; }'
				,wmode: 'transparent'
			});
			sIFR.replace(bl_home, {
				selector: 'h4',
				css: '.sIFR-root { color:#000000; font-size:25px; margin:0px; padding:0px; }'
				,wmode: 'transparent'
			});
			
		}, "json");
	});
	
	// When a new quantity is selected from the drop-down-menu on the products page...
	$("#select_product_quantity").change(function() {
		/// Update tbe quantity value in the form that gets submitted to PayPal
		$('#quantity').val($(this).val());
	});
	
	// When a main navigation link is hoverd over...
	$('#navigation ul li').hover(function(){
		// If the rolled over link is the "products" link
		if ($(this).attr('id') == "nav_products") {
			// Show the products drop-down-menu
			$('#product_drop_down').show();
		}
		else {
			// Hide the products drop-down-menu
			$('#product_drop_down').hide();
		}
	});
	
	// If the products drop-down-menu is hovered over
	$("#product_drop_down").hover(function(){
		// Ensure the products drop-down-menu is visible
		$('#product_drop_down').show();	
	});
	
	// If the "main" div  is hovered over...
	$("#main").hover(function(){
		// Hide the products drop-down-menu as the user is no longer hovered over it
		$('#product_drop_down').hide();	
	});
	*/
	
});
