// newsRotator
// Gökhan TENİM
var currentNew = 0;
var totalNews;
var height;
var theight=72;
var newsRotatorNews;
var newsRotatorArrow;
var newInterval;
var nrtbc='#A00';//thumb border color
$(function(){
	height = parseInt($('.newsRotator').css('height'));
	newsRotatorNews = $('.newsRotatorNews');
	totalNews = $('.newsRotatorThumb').length;
	newsRotatorArrow = $('.newsRotatorArrow');
	$('.newsRotatorNew:eq(0)').show();
	$('.newsRotatorThumb:eq(0)').css('border-color',nrtbc);
	$('.newsRotatorThumb').each(function(index,val){
		$(this).mouseover(function(){
			if(currentNew != index)	
			{
				currentNew = index;
				//newsRotatorNews.stop();
				//newsRotatorNews.animate({marginTop:'-'+(height*index)+'px'},400);
				
				//newsRotatorNews.stop();
				//newsRotatorNews.animate({'scrollTop':(height*index)},400);
				$('.newsRotatorNew:visible').fadeOut('fast',function(){
					$('.newsRotatorNew:eq('+currentNew+')').fadeIn('fast');
				});
				//$('.newsRotatorNew:eq('+index+')').fadeIn();
				
				arrowGo();
				$(this).css('border-color',nrtbc);
				$('.newsRotatorThumb').not(this).css('border-color','');
				
				
			}
		});
	});
	newInterval = setInterval('nextNew()',6000);
	$('.newsRotator').mouseover(function(){
		clearInterval(newInterval);
	});
	$('.newsRotator').mouseout(function(){
		newInterval = setInterval('nextNew()',6000);
	});
});

function nextNew()
{
	currentNew++;
	if(currentNew>=totalNews)
	{
		currentNew=0;
	}
	//newsRotatorNews.stop();
	//newsRotatorNews.animate({marginTop:'-'+(height*currentNew)+'px'},400);
	
	$('.newsRotatorNew:visible').fadeOut('fast',function(){
					$('.newsRotatorNew:eq('+currentNew+')').fadeIn('fast');
				});
	
	//newsRotatorNews.stop();
	//newsRotatorNews.animate({'scrollTop':(height*currentNew)},400);
	
	$('.newsRotatorThumb:eq('+currentNew+')').css('border-color',nrtbc);
	arrowGo();
	$('.newsRotatorThumb').not('.newsRotatorThumb:eq('+currentNew+')').css('border-color','');
}
function arrowGo()
{
	newsRotatorArrow.stop();
	newsRotatorArrow.animate({marginTop:(theight*currentNew)+'px'},200);
}
