// JavaScript Document

$(document).ready(function() {

	 $('.goto_1').click(function() { 
		 $('#hero_slider').cycle(0); 
		 return false; 
	});
	
	$('.goto_2').click(function() { 
		 $('#hero_slider').cycle(1); 
		 return false; 
	});
	
	$('.goto_3').click(function() { 
		 $('#hero_slider').cycle(2); 
		 return false; 
	});
	
	$('.goto_4').click(function() { 
		 $('#hero_slider').cycle(3); 
		 return false; 
	});
	
	$('.goto_5').click(function() { 
		 $('#hero_slider').cycle(4); 
		 return false; 
	});
	
	$('.goto_6').click(function() { 
		 $('#hero_slider').cycle(5); 
		 return false; 
	});
	
	$('.goto_7').click(function() { 
		 $('#hero_slider').cycle(6); 
		 return false; 
	});
	
	$('.goto_8').click(function() { 
		 $('#hero_slider').cycle(7); 
		 return false; 
	});
	
	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
		
		$('#dotnavlist li .active').removeClass('active');
		$('#dotnavlist li:nth-child(' + ( index+1 ) + ') a').addClass('active');
		
		$('#dotnavlist')[index == 1 ? $('#dotnavlist').addClass('light') : $('#dotnavlist').removeClass('light')];
	}
	
	$('#hero_slider').cycle({
		fx:     'fade',
		speed:	'fast',
		prev: 	'.prev',
		next: 	'.next',
		timeout:	6000,
		after:	onAfter,
		pager:	'#dotnavlist',
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#" class="goto_' + slide + '"></a></li>';
		}
	});
	
	$('#dotnavlist li:first-child a').addClass('active');
	
	$('.arrow').fadeOut();
	$("#hero_box").mouseenter(function () {
		$('.arrow').show();
	});
	$("#hero_box").mouseleave(function () {
		$('.arrow').hide();
	});
	
});
