var diff,topAngle, img = "";

$(document).ready(function() {
	cambiaDiv(5);
} );

function cambiaDiv(id)
{
	$(".menuDiv").removeClass("nmHover");
	$("#a"+id).addClass("nmHover");
	$(".paragrafo").hide();
	$("#para"+id).show();
	if(id==99 || id==5){
		$('#scrollContainer').hide();
		$('#imgloop').hide();
	}
	else
		$('#scrollContainer').show();
	
	if($("#imgObj"))
	{
		if(id == "1")
			$("#imgObj").attr("src", "/images/doctor.jpg");
		if(id == "2")
			$("#imgObj").attr("src", "/images/1.png");
		if(id == "3")
			$("#imgObj").attr("src", "/images/2.png");
	}
	
	impostaScroll();
}

function impostaScroll()
{
	diff=$("#scrollContainer").attr("offsetHeight") - $('#scroller').attr("offsetHeight");
	if(diff<0){
		topAngle=$('#scroller').attr("offsetTop");
		$("#jScrollArrowDown").show();
		$("#jScrollArrowDown").mouseover(function(){scrollDown(4);});
		$("#jScrollArrowDown").mouseout(function(){ $('#scroller').stop()});
		$("#jScrollArrowUp").show();
		$("#jScrollArrowUp").mouseover(function(){ scrollUp(4); });
		$("#jScrollArrowUp").mouseout(function(){ $('#scroller').stop()});
		$('#scroller').animate({top:(0)},100);
	}
	else{
		$("#jScrollArrowDown").hide();
		$("#jScrollArrowUp").hide();
	}
	
}


function scrollUp(speed){
	
	currPos=$('#scroller').attr("offsetTop");
	scrollSpeed=(topAngle-currPos)/50*2000/speed;
	$('#scroller').animate({top:(0)}, scrollSpeed,'linear' );
}

function scrollDown(speed){
	currPos=$('#scroller').attr("offsetTop");
	scrollSpeed=(diff-currPos)/50*2000/speed;
	$('#scroller').animate({top:(diff)}, -scrollSpeed,'linear' );
	
}
