/**
 * @author Nico
 */
var _id='';
var _pas=1;

var textHeight=0;
var containerHeight=0;
var noScroll=false;
var scrollHover=false;

var timerID = 0;

function initSroll()
{
	textHeight = parseInt(document.getElementById('listImgMini').offsetHeight,10);	
	containerHeight = parseInt(document.getElementById('divList').offsetHeight,10);
	if(textHeight<containerHeight) 
	{
		textHeight=containerHeight;
		noScroll=true;
		//document.getElementById('up').style.display='none';
		//document.getElementById('down').style.display='none';
	}	
}

function scrollDown(id,pas)
{
	if(id==null) id=_id;
	if(pas==null) pas=_pas;
		
	var obj = document.getElementById(id);
	var top = obj.style.top;
	top = top.substring(0,top.length-2);
	top = parseInt(top,10);
	
	if(top)
	{		
		if(top > (containerHeight-textHeight))
		{
			top-=pas;
			obj.style.top = top+"px";
		}
		else
		{
			obj.style.top = "-"+(containerHeight-textHeight)+"px";
		}
	}
	else if(!noScroll)
		obj.style.top = "-"+pas+"px";
		
	if(timerID) {
      	clearTimeout(timerID);
      	timerID  = setTimeout("scrollDown()", 10);
   	}		
}
function scrollUp(id,pas)
{
	if(id==null) id=_id;
	if(pas==null) pas=_pas;
	
	var obj = document.getElementById(id);
	var top = obj.style.top;
	top = top.substring(0,top.length-2);
	top = parseInt(top,10);
	if(top)
	{
		if(top < 0)
		{
			top = parseInt(top)+pas;
			top = (top>0)?0:top;
			obj.style.top = top+"px";
		}
	}
	
	if(timerID) {
      	clearTimeout(timerID);
      	timerID  = setTimeout("scrollUp()", 10);
   	}	
}

function scrollDownOnMouseOver(id,pas) {
   _id=id;
   _pas=pas;
   timerID  = setTimeout("scrollDown()", 10);
}

function scrollDownOnMouseOverOut() {
	if(timerID) {
      	clearTimeout(timerID);
      	timerID  = 0;
   	}
}

function scrollUpOnMouseOver(id,pas) {
   _id=id;
   _pas=pas;
   timerID  = setTimeout("scrollUp()", 10);
}

function scrollUpOnMouseOverOut() {
	if(timerID) {
      	clearTimeout(timerID);
      	timerID  = 0;
   	}
}

addToStart(initSroll);

