
function ScrollController( source )
{

    system.addEventListener("onloadSystem", activate);    

    function activate()
    {
        try
        {
            window.addEventListener( "keydown", pageScroll, true );
  //          source.addEventListener( "mousewheel", mouseScrollDOM, true );
        }
        catch( e )
        {
            document.body.attachEvent( "onkeydown", pageScrollIE );
//            document.body.attachEvent( "onmousewheel", mouseScrollIE );
        }
    }
    
    function test( event )
    {
        alert("testing mode:" + event);
    }
    
    function pageScrollIE()
    {
        pageScroll( event );
    }
    
    function pageScroll( event )
    {
        if ( (event.keyCode == 33)||(event.keyCode == 34) )
        {
            var obj = {};
            system.dispatchEvent("ongetConsoleSize", obj);
            var screenLines = obj.screenLines - 2;
        }
        if ( event.keyCode == 33 )
        {
            system.dispatchEvent("onScrollUp", screenLines );
        }
        if ( event.keyCode == 34 )
        {
            system.dispatchEvent("onScrollDown", screenLines );
        }
    }
                    
    function mouseScrollIE()
    {
        mouseScroll( -event.wheelDelta );
    }
    
    function mouseScrollDOM( event )
    {
        mouseScroll( event.wheelDelta );
    }

    function mouseScroll( delta )
    {
        if ( delta > 0 )
            system.dispatchEvent("onScrollDown", 3 );
        else
            system.dispatchEvent("onScrollUp", 3 );
    }
    
}  
