	var number_of_images = 0;
	var current_image = 1;
	var current_margin = 0;
	var slide_amount = 688; // Pixels	
	
	$(document).ready( function() {	
		
	
		// Count number of images
		$("#slider").find ("SLIDER_ITEM").each (
							function (i) {
						
								number_of_images = number_of_images + 1;
							
							});
							

		// Set slider counts
		document.getElementById ( 'slideshow_text' ).innerHTML = 'SLIDESHOW 1 OF ' + number_of_images;

		// Work out slider width
		var slider_width = slide_amount * number_of_images;
			slider_width = slider_width + 50;
			

		// Set slider width
		$("#slider").css ({width:slider_width + "px"});
		//$("#slider2").css ({width:slider_width + "px"});

		// If left is clicked
		// hide the current image
		// show the next
		$("#left").click ( 
						function() {
								
								if ( image_showing == false ) {

								if ( current_image < number_of_images ) {
									// Custom animation on the current image to send left
									var new_margin = current_margin - slide_amount;
							
									// Reset current margin							
									current_margin = new_margin;

									$("#slider").animate ({
												marginLeft: new_margin + "px"
												}, 1000);
												
									/*$("#slider2").animate ({
												marginLeft: new_margin + "px"
												}, 1000 );*/
												
									// Increase current image counter
									current_image = current_image + 1;
									
									// Update slide display
									document.getElementById ( 'slideshow_text' ).innerHTML = 'SLIDESHOW ' + current_image + ' OF ' + number_of_images;
									
								
								} else {
									
									// Full slide back
									var new_margin = ( current_margin + slider_width ) - ( slide_amount + 50 );

									// Reset current margin							
									current_margin = new_margin;

									$("#slider").animate ({
												marginLeft: new_margin + "px"
														  }, 1000, 'easeOutElastic' );
								
									current_image = 1;
									
									// Update slide display
									document.getElementById ( 'slideshow_text' ).innerHTML = 'SLIDESHOW ' + current_image + ' OF ' + number_of_images;
									
									
								}
								
								}
								
							});
							
		$("#right").click (
						function() {
						
								if ( image_showing == false ) {
									
								if ( current_image > 1 ) {
								
									var new_margin = current_margin + slide_amount;
							
									// Reset current margin
									current_margin = new_margin;
							
									$("#slider").animate ({
												marginLeft: new_margin + "px"
												}, 1000 );
												
									/*$("#slider2").animate ({
												marginLeft: new_margin + "px"
												}, 1000 );*/
									
									// Decrease current image count
									current_image = current_image - 1;
									
									// Update slide display
									document.getElementById ( 'slideshow_text' ).innerHTML = 'SLIDESHOW ' + current_image + ' OF ' + number_of_images;
									
									
								}
								
								}
															
							});									
							
							
	});                               
