// (jQuery)
$(document).ready(function(){

	// Bind facebox links
	$('a[rel*=facebox]').facebox() 

	// Alternative product photos (jQuery)
	$(".altPhoto").click(function() {

		// Set new image src
		var altImageSrc = $(this).attr("href");

		// Call function to replace image
		altImage(altImageSrc);

		return false;	
	});
	
	// Function: Show alternative product image
	function altImage(src) {

		// Remove the current image
		$('#productImage').fadeOut('fast', function () {
			// Load new image
			var img = new Image();
			$(img).load(function () {
				// Manipulate SRC to display image at size 2
				var newsrc = src.substring(0, src.length - 1) + '2';
				
				$('#productImage').attr("src", newsrc);
				$('#productImageLink').attr("href", src);								  
				$('#productImage').fadeIn();
			}).attr({
				src: src
			});
		});
	 }
	 
		

	// Subscription form - Check it exists first
		if ( $("#frmSubscribeToList").length > 0 ) { 
	
			// Hide subscription response 
			$('#subscribeResponse').hide();
			
			// bind form using ajaxForm 
			$('#frmSubscribeToList').ajaxForm({ 
				// target identifies the element(s) to update with the server response 
				target: '#subscribeResponse', 
		
				beforeSubmit: function() {
					// Hide subscription response 
					$('#subscribeResponse').hide();
				},
					
				// success identifies the function to invoke when the server response 
				// has been received; here we apply a fade-in effect to the new content 
				success: function() { 
					// Show response
					$('#subscribeResponse').fadeIn('slow'); 
				}
			}); 
		}
	

});


