// JavaScript Document
$(document).ready(function() {
						   
	var leftVal = 0;
	var numItems = $('.slideitem').size() - 4;//4 visible at all times 
	var moves = 0;
	
	$('#slidenav').css("height","400px");
	$('body').css("background-image","none");
	
	$('#slideleft').click(function(event) {
		 if ( moves > 0 ) {
			leftVal += 210;
			moves--;
			if ( moves == 0 ) { this.src = this.src.replace("_on","_off"); }
		 }
		 
		$('#slider').animate( 
			{ left: leftVal, easing: 'jswing' }	
		);
		
		var src = $('#slideright').attr("src").replace("_off","_on");
		$('#slideright').attr("src", src);
	});
	
	$('#slideright').click(function(event) {
		if ( moves < numItems ) {
			leftVal -= 210;
			moves++;
			if ( moves == numItems ) { this.src = this.src.replace("_on","_off"); }
		}
		$('#slider').animate(
			{ left: leftVal, easing: 'jswing' }
		);
		var src = $('#slideleft').attr("src").replace("_off","_on");
		$('#slideleft').attr("src", src);
		
	});
	
	$('#maincontenthome').click(function(event) {
		$(".fullInfo").fadeOut("slow");
	});
	
	$('.fullInfo').hide();
	
	$(".slideitem").hover(
		function() {
	  		$(this).find(".slideitemimg").css({backgroundPosition: '0px 0px'});
		},
	 	function() {
	  		$(this).find(".slideitemimg").css({backgroundPosition: '-100px 0px'});
	 	}
	);
	
	$('.slideitem').click(function(event) {
		$(".fullInfo").fadeOut("slow");
		index = $(".slideitem").index(this);
		
		$(this).next().css( "left", (index*210)+10 ).css( "top", "-150px").fadeIn("slow");
		return false;
	});
 
});
