var divHeight = 300;
var globalDivHeight = 0;
var globalDivScrollTop = 0;

function initScrollDivNews(idDiv)
{
	var idImgHaut = idDiv + "ImgHaut";
	var idImgBas = idDiv + "ImgBas";
	var currentDivHeight = document.getElementById(idDiv).offsetHeight;
	var scrollHeight = document.getElementById(idDiv).scrollHeight;
	
	//alert(currentDivHeight + " vs. " + scrollHeight);
	//alert(document.getElementById(idImgHaut).style.diplay);
	document.getElementById(idImgHaut).style.visibility = "hidden";
	
	if(currentDivHeight < scrollHeight)
	{
		document.getElementById(idImgBas).style.visibility = "visible";
	}
}
//divScrollImgHaut
//divScrollImgHaut

function scrollDivNews(way,idDiv)
{
	var currentDivHeight = document.getElementById(idDiv).offsetHeight;
	var currentDivScrollTop = document.getElementById(idDiv).scrollTop;
	var deplY = (currentDivHeight - currentDivScrollTop) - divHeight;
	var calc = (currentDivHeight - currentDivScrollTop);
	var nvoScrTop = currentDivScrollTop;

	if(way == "top")
	{
		//$(".block").animate({"scrollTop": "-=150px"}, "slow",function(){scrollDivNewsComplete(idDiv);});
		nvoScrTop -= 150;
		scrollDivNewsComplete2(idDiv,nvoScrTop);
		$(".block").animate({"scrollTop": "-=150px"}, "slow");
	}
	else if(way == "bottom")
	{
		//$(".block").animate({"scrollTop": "+=150px"}, "slow",function(){scrollDivNewsComplete(idDiv);});
		nvoScrTop += 150;
		scrollDivNewsComplete2(idDiv,nvoScrTop);
		$(".block").animate({"scrollTop": "+=150px"}, "slow");
	}
}

function scrollDivNewsComplete2(idDiv,scrTop)
{
	var idImgHaut = idDiv + "ImgHaut";
	var idImgBas = idDiv + "ImgBas";
	var currentDivScrollTop = scrTop;

	var currentDivHeight = document.getElementById(idDiv).offsetHeight;
	var scrollHeight = document.getElementById(idDiv).scrollHeight;
	
	var calc = (scrollHeight - currentDivScrollTop);
	
	if(document.getElementById(idDiv).scrollTop > 1)
	{
		document.getElementById(idImgHaut).style.visibility = "visible";
	}
	else
	{
		document.getElementById(idImgHaut).style.visibility = "hidden";
	}
	
	if(calc > currentDivHeight)
	{
		document.getElementById(idImgBas).style.visibility = "visible";
	}
	else
	{
		document.getElementById(idImgBas).style.visibility = "hidden";
	}
}

function scrollDivNewsComplete(idDiv)
{
	var idImgHaut = idDiv + "ImgHaut";
	var idImgBas = idDiv + "ImgBas";
	var currentDivScrollTop = document.getElementById(idDiv).scrollTop;

	var currentDivHeight = document.getElementById(idDiv).offsetHeight;
	var scrollHeight = document.getElementById(idDiv).scrollHeight;
	
	var calc = (scrollHeight - currentDivScrollTop);
	
	if(document.getElementById(idDiv).scrollTop > 1)
	{
		document.getElementById(idImgHaut).style.visibility = "visible";
	}
	else
	{
		document.getElementById(idImgHaut).style.visibility = "hidden";
	}
	
	if(calc > currentDivHeight)
	{
		document.getElementById(idImgBas).style.visibility = "visible";
	}
	else
	{
		document.getElementById(idImgBas).style.visibility = "hidden";
	}
}
