/*
 * created by Ocen 
 * swift the element to a position
 * income: to: up or down, elm: index int of element
 * outcome: listing position change, content of element
 */
var marginList		= 25; //margin the list begins
var activeElement = 0; //the element to begin
	
function swiftNews(to,elm){

		var endPos 	= (marginList*parseInt($('.newslist li').size()-1))-marginList;
		var doSlide 	= true;
		
		if(to=='up')	{ 
			var addPos = '+=25';
			activeElement = activeElement-1;
			if($('.newslist').css('margin-top').replace(/[^0-9-]/g, '') >= marginList){
				$('.newslist').clearQueue();
				doSlide = false;
			}
		}	else	{ 
			var addPos = '-=25';
			activeElement = activeElement+1;
			if($('.newslist').css('margin-top').replace(/[^0-9-]/g, '') >= endPos){
				$('.newslist').clearQueue();
				doSlide = false;
				
			}
		}
		
		if(elm){
			addPos = marginList	-(parseInt(elm)*25)+"px";
			activeElement = parseInt(elm);			
		}
	

		$('.newslist a').removeClass('active');
		$('#'+activeElement+' a').addClass('active');
		
		$('.newsHolder > div').hide();
		$('#news_'+activeElement).slideDown(100);
		
		if(doSlide == true){
			$('.newslist').animate({
				marginTop: addPos
			},100,function(){
				if(	$('.newslist').css('margin-top').replace(/[^0-9\-]/g, '') == marginList ){ $('.newsUp').hide() } else { $('.newsUp').css('display','block'); }
				if(	$('.newslist').css('margin-top').replace(/[^0-9]/g, '') == endPos ){ $('.newsDown').hide() } else { $('.newsDown').css('display','block'); }
			});		
		}
		
}

