jQuery(function() {
	jQuery("#sidebar").toggle();
	jQuery("#booking-button-img").hover(function() {
		jQuery(this).attr("src", jQuery(this).attr("src").substr(0, jQuery(this).attr("src").length-4)+"-hover.jpg");
	}, function() {
		jQuery(this).attr("src", jQuery(this).attr("src").substr(0, jQuery(this).attr("src").length-10)+".jpg");
	});
	jQuery("#sidebar ul").liScroll({ travelocity: 0.10 });
	jQuery("#nav-list li").hover(function(){
	jQuery(this).find(".off").hide();
	jQuery(this).find(".slider-button").show();
	jQuery(this).find(".middle").stop().animate({ width:'50px' },"slow");
	}, function(){ jQuery(this).find(".middle").stop().animate({ width:'2px', queue: 'false' },"slow", function() {
			var parent = jQuery(this).parent()
			parent.find(".slider-button").hide(); 
			parent.find(".off").show(); 
		});
	});
	
	function rotate_images() { 
		if(jQuery(".underlay").attr("src") == jQuery("#gallery-images img:last").attr('src')) {
			jQuery(".underlay").attr("src", jQuery("#gallery-images img:first").attr('src'));
		} else {
			// Too complex for one line, I'm a bad programmer!
			jQuery(".underlay").attr("src", jQuery("#gallery-images img[src*="+jQuery('.underlay').attr('src')+"]").next().attr('src'));
		}
	}
	
	function start_rotator(){
		var images = jQuery("#gallery-images img");
		if(images.length > 1) {
			window.setInterval(function() { rotate_images(); }, 5000);
		}
	}
	start_rotator();
});
