<!--
/*!
 **************************************************
 * Copyright 2010 - Danny Carmical
 * http://luckykind.com
 **************************************************/

/*** Home Page Slider ***/

var $j = jQuery.noConflict();

$j(document).ready(function() {
	var sliderText = $j('#slider-text ul li div');
	var featured = $j('#slider-featured ul');
	var nav = $j('#slider-nav ul li a');
	var arrow = $j('#slider-nav-arrow');
	var border = $j('#slider-nav-border');
	var arrowPos = 40;
	var borderPos = 0;
	var featuredPos = 0;
	var currentText = 0;
	var currentNav = 1;
	var whichNav = 1;
	var scroll = true;
	var autoSlide;
	
	$j('#featured1 img').addClass('current-nav-border');
	$j(sliderText[currentText]).show();
	
	nav.bind('click', function(){
		clearInterval(autoSlide);
		scroll = false;
		whichNav = +$j(this).attr('id').substring(8,9);
		slideNext();			
		return false;
	});

	function slideNext(){
		$j(sliderText[currentText]).fadeOut(500);
		border.fadeOut(500);
		if(scroll) {
			if(whichNav < 3) {
				whichNav++;
			} else {
				whichNav = 1;
			}
		}
		
		if(whichNav > currentNav) {
			borderPos += 120 * (whichNav - currentNav);
			arrowPos += 120 * (whichNav - currentNav);
			featuredPos -= 365 * (whichNav - currentNav);
			arrow.stop().animate({
				top : arrowPos
			}, 500, function() {
				featured.stop().animate({
					top : featuredPos
				}, 500);
				border.stop().css('top', borderPos).fadeIn(500);				
			});			
			currentNav = whichNav;
			currentText = currentNav - 1;
			$j(sliderText[currentText]).fadeIn(500);
		}

		if(whichNav < currentNav) {
			borderPos -= 120 * (currentNav - whichNav);
			arrowPos -= 120 * (currentNav - whichNav);
			featuredPos += 365 * (currentNav - whichNav);
			arrow.stop().animate({
				top : arrowPos
			}, 500, function() {
				featured.stop().animate({
					top : featuredPos
				}, 500);
				border.stop().css('top', borderPos).fadeIn(500);				
			});
			currentNav = whichNav;
			currentText = currentNav - 1;
			$j(sliderText[currentText]).fadeIn(500);
		}
		
	}
	
	$j(function() {
			autoSlide = setInterval(slideNext, 5000);		
	});
});
/*** End Home Page Slider ***/

-->	
