var speed = 10;
var moveupvar, movedownvar;
var moveupvar1, movedownvar1;
var moveupvar2, movedownvar2;
var crossobj = document.getElementById("scroll-content");
var contentheight = crossobj.offsetHeight;
var scrollableheight = crossobj.parentNode.offsetHeight;
var showOrHideArrows = false;
var scrollrangetop = 0;
var scrollrangebottom = scrollableheight - contentheight;

window.onload = function ()
{
	contentheight = crossobj.offsetHeight;
	scrollableheight = crossobj.parentNode.offsetHeight;
	scrollrangetop = 0;
	scrollrangebottom = scrollableheight - contentheight;
}

function init_scroller()
{
    clearTimeout(moveupvar);
    clearTimeout(movedownvar);
	contentheight = crossobj.offsetHeight;
	scrollableheight = crossobj.parentNode.offsetHeight;
	scrollrangetop = 0;
	scrollrangebottom = scrollableheight - contentheight;
	
}

function scrollgettop()
{
	return parseInt(crossobj.style.top);
}

function movedown()
{
	//alert("up" + crossobj.style.top);
	if (scrollgettop() >= scrollrangebottom){
		crossobj.style.top = scrollgettop() - speed + "px";
		movedownvar = setTimeout(movedown, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u').style.display = 'block';
			document.getElementById('scroll-arrows_v').style.display = 'none';
		}
	
	}
	
}

function movedown1()
{
	//alert("up" + crossobj.style.top);
	if (scrollgettop() >= scrollrangebottom){
		crossobj.style.top = scrollgettop() - speed + "px";
		movedownvar1 = setTimeout(movedown1, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u1').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u1').style.display = 'block';
			document.getElementById('scroll-arrows_v1').style.display = 'none';
		}
	
	}
	
}

function movedown2()
{
	//alert("up" + crossobj.style.top);
	if (scrollgettop() >= scrollrangebottom){
		crossobj.style.top = scrollgettop() - speed + "px";
		movedownvar2 = setTimeout(movedown2, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u2').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u2').style.display = 'block';
			document.getElementById('scroll-arrows_v2').style.display = 'none';
		}
	
	}
	
}

function moveup()
{
	//alert("down" + crossobj.style.top);
	if (scrollgettop() < scrollrangetop){
		crossobj.style.top = scrollgettop() + speed + "px";
		moveupvar = setTimeout(moveup, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_v').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u').style.display = 'none';
			document.getElementById('scroll-arrows_v').style.display = 'block';
		}
	
	}
}

function moveup1()
{
	//alert("down" + crossobj.style.top);
	if (scrollgettop() < scrollrangetop){
		crossobj.style.top = scrollgettop() + speed + "px";
		moveupvar1 = setTimeout(moveup1, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_v1').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u1').style.display = 'none';
			document.getElementById('scroll-arrows_v1').style.display = 'block';
		}
	
	}
}

function moveup2()
{
	//alert("down" + crossobj.style.top);
	if (scrollgettop() < scrollrangetop){
		crossobj.style.top = scrollgettop() + speed + "px";
		moveupvar2 = setTimeout(moveup2, 40);
		
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_v2').style.display = 'block';
		}
		
	}else{
	
		if(showOrHideArrows == true){
			document.getElementById('scroll-arrows_u2').style.display = 'none';
			document.getElementById('scroll-arrows_v2').style.display = 'block';
		}
	
	}
}

function getcontent_height()
{
	contentheight = crossobj.offsetHeight;
}
function moveTop()
{
	//crossobj.style.top = 0;
}
function moveBottom()
{
	//crossobj.style.top = scrollrangebottom + "px";
}


function vCustomScroller( p_sElementId )
{
	
	var temp = document.getElementById( p_sElementId );
	if(temp){
		//alert( p_sElementId );
		crossobj = temp;
		
		if ((p_sElementId == 'custom_scroll') || (p_sElementId == 'custom_scrollS') || (p_sElementId == 'custom_scrollD')) {
			showOrHideArrows = true;
		}else{
			showOrHideArrows = false;
		}
		
	}else{
		showOrHideArrows = false;
		crossobj = document.getElementById("scroll-content");
	}
	
	init_scroller();
}
