var scrol = {};

scrol.timer = null;
// Scroll down function
scrol.down = function(speed)	{
	if(parseInt($("#content").css('top')) < 0)	{
		t = (parseInt($("#content").css('top')) + speed)+'px';
		$("#content").css({ 'top': t });
		scrol.timer = window.setTimeout(function()	{
			scrol.down(speed)
		}, 30);
	}			
}
// Scroll up function
scrol.up = function(speed)	{
	if(parseInt($("#content").css('top')) > -(scrol.diff))	{
		t = (parseInt($("#content").css('top')) - speed)+'px';
		$("#content").css({ 'top': t });
		scrol.timer = window.setTimeout(function()	{
			scrol.up(speed)
		}, 30);
	}			
}
// Scroll stop
scrol.stp = function(speed)	{
	window.clearTimeout(scrol.timer);
}
// Initiating
scrol.init = function()  {
  scrol.diff = $("#content").height() - $("#scroll").height(); // Scrolling area
  //alert(scrol.diff);
  if(scrol.diff < 0)  {
    $(".down-arrow a").hide();
    $(".up-arrow a").hide();
  } else {

    $(".down-arrow a").show();
    $(".up-arrow a").show();

  	$(".down-arrow a").mouseover(function()	{
  		scrol.up(5);
  	}).mouseout(function()	{
  		scrol.stp();
  	});
  
  	$(".up-arrow a").mouseover(function()	{
  		scrol.down(5);
  	}).mouseout(function()	{
  		scrol.stp();
  	});          
  }
}

// Initialize
$(document).ready(function()	{

  // initiating
  scrol.init();

});
