$(document).ready( function() {
	// hide all slides except the first one initially
	$("#lto .lto:eq(0)").addClass("showLto");
	$("#lto .lto:gt(0)").addClass("hideLto");
	
	// create the slide nav based on the number of slides
	var numberOfLtos = $("#lto .lto").length;
	var navNumber = 1;
	for ( i=0; i<numberOfLtos; i++ ) {
		$("#ltoNav").append("<a href='"+i+"'>"+(i+1)+"</a>");
	}
	
	// show the slides as the nav is clicked
	$("#ltoNav a").click( function() {
		$("#ltoNav a").removeClass("selected");
		var target = Number($(this).text()) - 1;
		$("#lto .showLto").toggleClass("showLto").fadeOut( function() {
			$("#lto .lto:eq("+target+")").fadeIn().toggleClass("showLto");
		});
		$(this).toggleClass("selected");
		return false;
	});
	
	// rotate the slides
	var rotateInterval = 3000;
	var currentLto = 1;
	
	function showLtos() {
		$("#lto").everyTime(rotateInterval,"rotateLto", function() {
			$("#ltoNav a:eq("+currentLto+")").click();
			currentLto = ( currentLto < numberOfLtos - 1 ) ? currentLto+1 : 0;
		});
	}
	
	showLtos();
	
	// stop the rotation on mouseover
	$("#lto").mouseover( function() {
		$("#lto").stopTime("rotateLto");
	}).mouseout( function() {
		showLtos();
	});
	
	// highlight the first slide nav item initially
	$("#ltoNav a:eq(0)").addClass("selected");
});