var IE = document.all ? true : false;

var scrollAreaID;
var scrollPointID;


function ContentHeight()
{
 return $(scrollAreaID).offsetHeight;
}

function $(id)
{
  return document.getElementById(id);

}

if (!IE)
{
  document.captureEvents(Event.MOUSEMOVE);
}

function PreventDef(e)
{
    if (!IE && e.preventDefault)
       e.preventDefault();
}



var doScroll = false;

function StopScroll()
{
  doScroll=false;
  document.onmousedown = void(0);

  document.onmousemove = void(0);
  return true;
}


function EnableScroll(areaID, pointID)
{
  doScroll=true;
  document.onmousedown = PreventDef;
  document.onmousemove = Move;
  scrollAreaID = areaID;
  scrollPointID = pointID;
  //finding the centered div
  var areaParent = $(areaID).parentNode.parentNode.parentNode;
  if (areaParent && IE)
  {
	  //adding event handler for ie
	  areaParent.onselectstart = function(){return false;};
  }	  
  return true;
}

var tempX = 0;
var tempY = 0;

function Move(e)
{
  if (IE)
  { // grab the x-y pos.s if browser is IE
    var scrollLeft = document.documentElement.scrollLeft;
    tempX = 0;
    if (scrollLeft == 0)
      scrollLeft = document.body.scrollLeft;
    if (event)
    {
      tempX = event.clientX  + scrollLeft;
    }
    var scrollTop = document.documentElement.scrollTop;
    if (scrollTop == 0)
      scrollTop = document.body.scrollTop;

    tempY = event.clientY + scrollTop;
  }
  else
  {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}
  if (doScroll)
    MoveContents();
  return true;
}

function MoveContents()
{
  var y = Math.max(0, Math.min(tempY - 200, 135));
  $(scrollPointID).style.top = y + "px";
  var y2 = -y/135 * (ContentHeight() - 15);
  $(scrollAreaID).style.top = y2 + "px";
}


