// JavaScript Document
	//<![CDATA[
	jQuery.noConflict();
     
     // Put all your code in your document ready area
     jQuery(document).ready(function($){
 
			$(".rollover").css({'opacity':'0'});
			
		/*	jQuery("a[rel^='lightbox']").prettyPhoto({
				animationSpeed: 'normal',
				padding: 20,
				opacity: 0.55,
				showTitle: true,
				allowresize: true,
				counter_separator_label: '/',
				theme: 'light_square'
			}); */
			
			// set the scroll axes
			$.scrollTo.defaults.axis = 'xy';
			// define the gallery array object
			var $gallery = $('#gallery');
			// initilize the gallery to the far left
			$($gallery).scrollTo( 0 );
			$.scrollTo(0);
			// zero out the counter
			var counter = 0;
			// the total number of images
			var totalElements = $("#gallery .elements li").length;			
			// how wide is each image?
			elWidth = 281;
			// how many images advance with each click?
			advance = 3;
			// how many panels are there?
			panels = Math.ceil(totalElements / advance);
			//set current panel to 1
			panel = 1;
			// determine how many items are in the last panel (accounts for a remainder)
			lastPanel = advance - ((panels * advance) - totalElements);
			// initially, the previous link is greyed out
			$("#galleryNavigation li.prev a").addClass('inactive');	
			// if there are only three elements total, we don't need to worry about scrolling
			if (totalElements == 3) {
				$("#galleryNavigation li.next a").addClass('inactive');
			}
			
			
			
			// ****
			var progressIndicatorMultiplier = Math.ceil(728/panels);
			var progress = (progressIndicatorMultiplier * panel);
			$("#progress").css({'width':progress});
			var sliderWidth = (panels * progressIndicatorMultiplier);
			$("#slider").css({'width':sliderWidth});
			// ****
			
			// activate the slider on click
			$('#galleryNavigation li a').click(function(){
				var totalWidth = totalElements * elWidth;
				$("#gallery .elements").css({'width':totalWidth});
				// are we advancing the slider?
				if ($(this).attr('title') == 'Prev') {
					panel--;
					if (panel > 0)
					{
						// change the counter
						counter = counter - advance;
						if (panel == 1) {
							$("#galleryNavigation li.prev a").addClass('inactive');	
						}
						else if (panel > 1) {
							$("#galleryNavigation li.next a").removeClass('inactive');	
						}
						if (panel == panels)
						{
							// change this if we're on the last panel
							totalPanelsToMove = lastPanel;
						}
						else
						{
							totalPanelsToMove = advance;
						}
						$gallery.stop().scrollTo( 'li:eq('+counter+')', (elWidth*advance), {easing:'easeInOutCubic'} );
						$("#progress").animate({ 
							width: (progressIndicatorMultiplier * panel)
						}, (elWidth*advance));

					}
				} else {
					panel++;
					if (panel <= panels)
					{
						// change the counter
						counter = counter + advance;
						if (panel == panels)
						{
							$("#galleryNavigation li.next a").addClass('inactive');
							// change this if we're on the last panel
							totalPanelsToMove = lastPanel;
						}
						else
						{
							$("#galleryNavigation li.prev a").removeClass('inactive');	
							$("#galleryNavigation li.prev a").addClass('active');	
							totalPanelsToMove = advance;
						}
						$gallery.stop().scrollTo( 'li:eq('+counter+')', (elWidth*advance), {easing:'easeInOutCubic'} );
						$("#progress").animate({ 
							width: (progressIndicatorMultiplier * panel)
						}, (elWidth*advance));
					}
				}
				
				
			});
			// show the rollover state for the gallery images
			$('#gallery li a').hover(
				function() {
					$(this).find('.rollover').fadeTo(500, 0.60);
				},
				function() {
					$(this).find('.rollover').fadeTo(500, 0.00);
				}
			);

		});
		
	//]]>
