/* 	GLOBAL VARIABLES 
	REQUIRES JQUERY TOOLS
*/


    var carousel;
	var slides;
	var slidewidth = 400;
	var timer = null;
	var sleep;
	var items;
	var initialized = false;
	var current_slide = 0;
	var move;
	var direction;
	var duration = 1000;
	var iid;
	var thumbs;
	var thumb;
	var animate = true;
	var current_index;
	var easing = "easeOutQuint";
	var slide;


function newsSlider() {
	
	carousel	= $('.nc');
	slides		= $('.nc_slides');
	slide		= $('.nc_slide');
	slidewidth	= 400;
   	sleep		= 5000;
    items 		= (slide.length)
	thumbs 		= $('.nc_thumbs');
	thumb 		= $('.nc_thumb');
	timer		= $('.nc_timer');
	current_slide = 0; 
	
	thumb.hover(function(){
		current_index = $(this).attr('rel');
		$('.nc_thumb_bg').stop();
		animate = false;
		stop_timer();
		move_slide($(this).attr('rel'));
	});
	init_carousel();
}
 
function move_slide(index) {
	current_slide = index;
	activate_thumb(index);
	slides.stop().animate(
		{ left: -(index*slidewidth) }, 
		duration,
		easing,
		function(){
			if(animate){
				animate_timer();
			}
		}
	);
}

function init_carousel() {
	$('.nc_text').css('opacity','0.8');

	if(animate) animate_timer();
}


function animate_timer(){
		current_slide +=1;
		if (current_slide >= items){
			current_slide = 0;
		}	
		timer.css('width','400px');
		timer.animate({width:'0px'},  sleep,function(){move_slide(current_slide)});
}

function activate_thumb(t){ }

function stop_timer(){
	timer.stop();
	timer.css('display','none');
}
	
	 
