			function cancel(e) {
			  if (e && e.preventDefault) {
			    e.preventDefault(); // DOM style
			   }
			  return false; // IE style
			}
			
			function makeSlide(image) {
				var html = '';
				html += '<a href="' + image.href + '">';
				html += '<img alt="' + image.alt + '" src="' + image.src + '">';
				html += '</a>';
				return html;
			}
			
			function switchSlides(images, index, direction) {
				var drawIndex = index;
				
				if (direction < 0) {
					if (index-1 < 0) {
						drawIndex = images.length-1;
					} else {
						drawIndex = index-1;
					}
										
					$('#slide_prev').animate({
						left: '8%'
					}, 500, 'swing', function() {
						$(this).attr('id', 'slide_center');
					});
				
					$('#slide_center').animate({
						left: '101%'
					}, 500, 'swing', function() {
						$(this).attr('id', 'slide_next');
					});
					
					$('#slide_next').animate({
						left: '150%'
					}, 500, 'swing', function() {
						$(this).empty().attr('id', 'slide_extra');
					});
					
					$('#slide_extra').html(makeSlide(images[drawIndex]))
													 .attr('id', 'slide_prev')
													 .css('left', '-150%')
													 .animate({ left: '-85%' }, 500, 'swing');
										
				} else {				
					if (index+1 > images.length-1) {
						drawIndex = 0;
					} else {
						drawIndex = index+1;
					}
					
					$('#slide_prev').animate({
						left: '-150%'
					}, 500, 'swing', function() {
						$(this).empty().attr('id', 'slide_extra');
					});
				
					$('#slide_center').animate({
						left: '-85%'
					}, 500, 'swing', function() {
						$(this).attr('id', 'slide_prev');
					});
					
					$('#slide_next').animate({
						left: '8%'
					}, 500, 'swing', function() {
						$(this).attr('id', 'slide_center')
					});
					
					$('#slide_extra').html(makeSlide(images[drawIndex]))
													 .attr('id', 'slide_next')
													 .css('left', '180%')
													 .animate({ left: '101%' }, 500, 'swing');
				}
			} 
		
			function loadSlides(images, index) {
				var length = images.length-1;
				if (index == 0) {
					$('#slide_prev').html(makeSlide(images[length]));
				} else {
					$('#slide_prev').html(makeSlide(images[index-1]));
				}
				
				$('#slide_center').html(makeSlide(images[index]));
				
				if (index == length) {
					$('#slide_next').html(makeSlide(images[0]));
				} else {
					$('#slide_next').html(makeSlide(images[index+1]));
				}
			}
			
			
			$('document').ready(function() {
				var topImage = false;
				var topImageWidth = $('.cropbox').css('left');
		  	var images = [];
		  	var index = 0;
				$.localScroll({
					duration: 500
				});				
				
				$('.cropbox').click(function() {
					if (!topImage) {
						$(this).animate({
							left: '10%'
						}, 500, function() {
							topImage = true;
						});
						$(this).siblings().animate({
							opacity: '0.2'
						}, 500);
					} else {
						$(this).animate({
							left: topImageWidth
						}, 500, function() {
							topImage = false;
						});
						$(this).siblings().animate({
							opacity: '1.0'
						}, 500);

					}
				});
				
			  $('#showcase > a img').each(function() {
			  	var image = new Object;
			  	image.alt = $(this).attr('alt');
			  	image.src = $(this).attr('src');
			  	image.href = $(this).parent().attr('href');
					images.push(image);
					
					$(this).hide();
				});
				
				$('#slide_prev').live('click', function(e) {
					cancel(e);
					if (index == 0) {
						index = images.length-1;
					} else {
						index--;
					}
					
					switchSlides(images, index, -1);
				});
				
				$('#slide_next').live('click', function(e) {
					cancel(e);
					if (index == images.length-1) {
						index = 0;
					} else {
						index++;
					}
					
					switchSlides(images, index, 1);
				});
				
				loadSlides(images, index);
			});
