
	$(document).ready(function() {

	
		/*var listing = $("#listings").html();
		
		for(var i = 0; i < 5; i++) {
			$("#listings").append(listing);
		}*/
	
		// These are part of the CSS text gradient overlays
		
		var isIE = navigator.appVersion.indexOf("MSIE") != -1;
		
		if(!isIE) {
			$("#menu ul li a").prepend("<span></span>"); 
			$("h1").prepend("<span></span>"); 
		}
	
		/*$('#roundabout ul').roundabout({
			minOpacity: 0.90,
			minScale: 0.9
		});*/
		
		//$(".wrapAround img").wrap('<span></span>');
		
		
		var move = $(".wrapAround img").outerWidth(); // Distance (px) to move on each click (width of image + any borders/margins
		var speed = 300; // Speed of animation
		var showing = 3; // # of images that are shown at one time
		
		var moving = false 
	
		
		$(".vehicles").each(function(i,v) {
		
			var obj = this; // Hold current instance
			
			var middle = $(this).find(".middle"); // Container of images to work with
			var imgs = $("a", middle); // Array of the images we are working with
			var wrapAround = $(".wrapAround", middle); // Array of the images we are working with
			var total = imgs.size() - showing; // Total minus # showing tells us when to wrap around
			
			var current = 0;
						
			// Left Arrow Button			
			$(".left", obj).click(function() { 
						
			if(!moving) {
			
				moving = true;	
						
					wrapAround.prepend($("a", middle).eq(imgs.size() - 1).remove()).css("left", -move);	
					wrapAround.animate({ left: "+=" + move + "px" }, speed, function() { 
					
						moving = false; 
						
					
					});
				
			}
			
			}); 
		
			// Right Arrow Button
			$(".right", obj).click(function() {
			
			if(!moving) {
			
				moving = true;
			
					wrapAround.animate({ left: "-=" + move + "px" }, speed, function() { 
					
						moving = false; 
						wrapAround.append($("a", middle).eq(0).remove()).css("left", 0);
					
					
					});
				
			}
			
			});
		
		
		});
	});
