// JavaScript Document

$(document).ready(function(){
	
	/*MAIN FEATURE CONTROLLER*/
	var slide = $('.featureSlide');
	var slideWidth = slide.width();
	var numSlides = slide.length;
	var containerWidth = slideWidth * numSlides;
	var currentPosition = 0;
	manageControls();
	$('#arrowLeft').hide();
	
	$('#slidesContainer').width(containerWidth);
	
	
		$('#arrowLeft').click(function(){
			if(currentPosition > 0){
			$('#slidesContainer').animate({'margin-left' : '+=730px'}, 500);
			currentPosition -=1;
			}
			manageControls();
		});
			
		$('#arrowRight').click(function(){
			if(currentPosition != numSlides-1){
			$('#slidesContainer').animate({'margin-left' : '-=730px'}, 500);
			currentPosition +=1;
			}
			manageControls();
			}
			);
		
	function manageControls(){
		if(currentPosition==0){
			$('#arrowLeft').fadeOut();
		}else{
			$('#arrowLeft').fadeIn();	
		}
	
		if(currentPosition > numSlides-2){
			$('#arrowRight').fadeOut();
			clearInterval(slideMover);
		}else{
			$('#arrowRight').fadeIn();
		}
	}
	
	function moveSlide(){
		$('#slidesContainer').animate({'margin-left' : '-=730px'}, 500);
		currentPosition +=1;
		manageControls();
	}
	
	var slideMover = setInterval(moveSlide,10000);
	/* END OF MAIN FEATURE CONTROLLER*/		
	var target;
	
		$('.moreInfo').hover (function(evt){
			target = $(this).attr('href');
			$(target)
			.show()
			.css('top', evt.pageY + 20)
			.css('left', evt.pageX + 10)
			.appendTo('body');
		
		}, function(){
			$('.infoBlurb').hide();
		});
		
		$('.moreInfo').mousemove (function(evt){
			$(target)
			.css('top', evt.pageY + 20)
			.css('left', evt.pageX + 10)
		
		});

});



