// jQuery script to handle rider page
jQuery(document).ready(function($){

	// bind clicks on ads
	var bindProductImages = function() {
		$('.productImageThumb').each(

			// For each add button, bind the onclick behavior.
			function() {

				// Bind the onclick event 
				$(this).click(
					function() {

						var theId 		= $(this).attr('id'); // get ID of clicked element, eg: image_123
						var imageArray 	= theId.split('_');
						var imageId		= imageArray[1]; 
						
						$.ajax({
							type: 'POST',
							url: '/ajax/printProductImage.php',
							data: 'image_id=' + imageId,
							cache: false,
							success: function(html){
								$('#productLargeImage').hide().html(html).fadeIn('slow');
							}
						});
						
						return false; // return false so the link doesn't actually click anywhere			
					}
				);
			}
		);
	};
	
	// bind onclick
	bindProductImages();

});