   var max = 39; //Max. Photos stored in folder img/referenties
    var cur=-1;
    var photos=new Array();
    for(i=1; i<=max; i++)
        {
            photos[i]=new Image();
            photos[i].src="img/referenties/" + i + ".jpg";
        }
    photos=shuffle(photos);
    var timeout;
    var timeout2;
    function rotate()
    {
        cur++;
        if(cur>photos.length-1)
        {
            cur=0;
        }
        document.imgReferenties.src=photos[cur].src;
        timeout=setTimeout("rotate()",2000);

    }
    function previousNextPhoto(op)
    {
        clearTimeout(timeout);
        clearTimeout(timeout2);
        cur=cur+op;
        if(cur<0)
            {
                cur=photos.length-1;
            }
         if(cur>photos.length-1)
            {
                cur=0;
            }

        document.imgReferenties.src=photos[cur].src;
        timeout2=setTimeout("rotate()",3000);

    }


