﻿var movedownvar = objheight = moveupvar = 0;


function movedown(){
	
	if ( s_pos >=(objheight*(-1)+s_he)){
		$(".scrolltesto").animate({'top': s_pos -= speed}, 500); 
	}

}

function moveup(){
  if (s_pos < 0){
		$(".scrolltesto").animate({'top': s_pos += speed},500); 
  }	
}




jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){

	//scroll testo
	$(".scrolltesto").css('top', 0);
	$("#scrollcontainer").css('top', 0);
	
	s_pos = parseInt($(".scrolltesto").css("top"));
	//altezza cotnenitore
	s_he = parseInt($("#scrollcontainer").height());
	// Rileva la dimensione massima del box
	objheight = $(".scrolltesto").height();
	
	speed =/*parseInt($("#scrollcontainer").height()) +*/parseInt($("#scrollcontainer").css('line-height'))*4;


	//scroller articoli
	//Se esiste il sotto div con classe sub 
;
	if($("div.scrolltesto").children().length >0 && $("div.scrolltesto ul").attr('id') == "slide"){	

		$("#next").hide(); 
		$("#prev").hide();	
		
		$('#slide').wslide({
			width: 250,
			height: 244
		});
				

	
	//altrimenti è solo testo
	}else{			
	
		if(objheight <= parseInt($("#scrollcontainer").height())){			
			$("#next").hide();  $("#prev").hide();
		}			
		
		$("#next").click(function(){       // Caso Over Down
				movedown()
			},function(){
			clearTimeout(movedownvar);
		});
		
		$("#prev").click(function(){        // Caso Over Up
				moveup()
			},function(){
				clearTimeout(moveupvar);
		});	
	}

});


	
     
