// scrollbar
var IE = document.all?true:false
if ( !IE ) {
    
    document.captureEvents (Event.MOUSEMOVE);
        
}


document.onmousemove = handleScroll;


var ym;
var ypScrolling = false;
var minY = 0;
var maxY = 110;
var currentScroll;
var targetHeight;
var viewboxHeight = 95;
var elementBoxHeight = 50;

function getBoxHeight () {
   
    //alert ( document.getElementById ( "scroll0Content" ).style.height );
			
}

function getTargetHeight () {

    var scrollBoxObj = document.getElementById ( "scrollContent" );
    var innerDivs = scrollBoxObj.getElementsByTagName("DIV");
    return innerDivs.length * elementBoxHeight;
}

function startScrolling (e) {
    
    ypScrolling = true;
    currentScroll = parseInt ( document.getElementById ("ScrollerGem").style.top );


    

    ym = ( !IE ) ? e.pageY : ( event.clientY + document.body.scrollTop );
    targetHeight = getTargetHeight();

}

function stopScrolling(e) { 
 
    ypScrolling = false;

}

function handleScroll (e) {
    
    if ( ypScrolling ) {
       
        var scrollObj = document.getElementById ("ScrollerGem");
        
        var yDiff;
        var cY = ( !IE ) ? e.pageY : ( event.clientY + document.body.scrollTop );
        yDiff = cY - ym;
        
      
        var newTop = currentScroll + yDiff;
        if ( newTop <= minY ) newTop = minY;
        else if ( newTop >= maxY ) newTop = maxY;
        
        scrollObj.style.top = newTop + "px";
        
        
        var percDiff = ( newTop - minY ) / ( maxY - minY );
        var newContentTop = -1 * percDiff * ( targetHeight - viewboxHeight );
        document.getElementById ( "scrollContent" ).style.top = newContentTop + "px";
        
    }    
}
