﻿        
    var speed , FG, FG, MyMar;
    
    window.onload = function(){
        speed   = 3;
        FG      = document.getElementById('div_Videos');
        FG1     = document.getElementById('div_Show');
        document.getElementById("bt_VideoL").onmouseover = function(){ Move(1,1);};
        document.getElementById("bt_VideoL").onmouseout = function(){ Move(0,1);}; 
        document.getElementById("bt_VideoR").onmouseover = function(){ Move(1,2);};
        document.getElementById("bt_VideoR").onmouseout = function(){ Move(0,2);};  
    }
    
    // nAction=1: start moving, nAction<>1: end moving
    // nDirection=1: left moving, nDirection=2: right moving
    function Move(nAction, nDirection)
    {
        if (nAction==1)
        {
            switch (nDirection)
            {
                case 1:
                    MyMar = setInterval(MoveLeft,1);
                    break;
                case 2:
                    MyMar = setInterval(MoveRight,1);
                    break;
            }
        }else{
            clearInterval(MyMar);
        }
    }

    function MoveLeft()
    {
        if (FG.scrollLeft>0)
        {
            FG.scrollLeft-=speed;
        }else{
            Move(0,1);
        }
    }
    
    function MoveRight()
    {
        if (FG.scrollLeft<(FG1.offsetWidth-FG.offsetWidth) && (FG1.offsetWidth>FG.offsetWidth) )
        {
            FG.scrollLeft+=speed;
        }else{
            Move(0,1);
        }
    }

