Simple JS photo or document gallery player

Simple JS photo or document gallery player

Using the simple next and previous javascript code, you can create a fast, simple and stylish photo galley just by changing or adding your desire of CSS code.

<script type="text/javascript">
    var counter = 1;
    function loopPic()
    {
        if (counter ++ >= n){
            if(counter < 0){counter = n;}
        }
        var file='folder/fileName' + counter + 'fileExtenssion';
        document.getElementById('demo').src= file ;
        t=setTimeout('loopPic()',5000);
    }
    
    function startLoop(){ var a = loopPic(); return a;}
    function stopLoop(){clearTimeout(t);}
    function nextPic(){ if (counter ++ >=n){
    counter = 0; }
        var file='folder/fileName' + counter + 'fileExtenssion';
        document.getElementById('demo').src= file ;
    }
    function prvPic(){ if (counter-- <= n){
        if(counter < 0){counter = n;} }
        var file='folder/fileName' + counter + 'fileExtenssion';
        document.getElementById('demo').src= file ;
    } 
</script>