


var arWidths = [];
    arWidths[1] = 32*165;
    arWidths[2] = 30*165;
    arWidths[3] = 8*165;
    arWidths[4] = 11*165;
    arWidths[5] = 5*165;



var arScrollDivs = [];

var arTimeouts = [];

var arCurrentLeft = [];
   
   
var arIsRunning = [];
    arIsRunning[1] = false;
    arIsRunning[2] = false;
    arIsRunning[3] = false;
    arIsRunning[4] = false;
    arIsRunning[5] = false;
    
var arStop = [];
    arStop[1] = false;
    arStop[2] = false;
    arStop[3] = false;
    arStop[4] = false;
    arStop[5] = false;
    
function ShuffleTheDeck()
{
    var intTmp;
    intTmp = 30 - (165 * Math.floor(Math.random()*32));
    document.getElementById("model_thumbnails_container1").style.left= intTmp  + "px";
    arCurrentLeft[1] = intTmp;
     
    intTmp = 30 - (165 * Math.floor(Math.random()*30));
    document.getElementById("model_thumbnails_container2").style.left= intTmp  + "px";
    arCurrentLeft[2] = intTmp;
    
    intTmp = 30 - (165 * Math.floor(Math.random()*8));
    document.getElementById("model_thumbnails_container3").style.left= intTmp  + "px";
    arCurrentLeft[3] = intTmp;
    
    intTmp = 30 - (165 * Math.floor(Math.random()*11));
    document.getElementById("model_thumbnails_container4").style.left= intTmp  + "px";
    arCurrentLeft[4] = intTmp;
    
    intTmp = 30 - (165 * Math.floor(Math.random()*5));
    document.getElementById("model_thumbnails_container5").style.left= intTmp  + "px";
    arCurrentLeft[5] = intTmp;
 
}



function ScrollThree(dir, n)
{

    if (arIsRunning[n] == false)
    {
        arIsRunning[n] = true;
        arScrollDivs[n] = document.getElementById("model_thumbnails_container" + n);
        if  (dir == "left")  ScrollThreeLeft(n,495,15,2); 
        if  (dir == "right") ScrollThreeRight(n,495,15,2)
        /* derde parameter moet deler van 495 zijn! */  
        
    }
}


function ScrollThreeRight(n,pix,increment,timeout)
{
       
    
    mypix = pix - increment;


    if (arCurrentLeft[n] <= -(arWidths[n]))
	  {
	     arCurrentLeft[n]=0;
	  } else {
	     arCurrentLeft[n] -= increment;
	  }

    arScrollDivs[n].style.left  = arCurrentLeft[n] + "px";
    
    
    if (mypix < 100)
    {
         arStop[n] = true;
    }
    
    if (arStop[n] == true)
    {
   
        if ((arCurrentLeft[n]-30) % 165 != 0)
        {
            arTimeouts[n] = setTimeout("ScrollThreeRight("+ n +","+ mypix +","+ increment +")",timeout);
        } 
        else
        {    
           arStop[n] = false;
           if (arTimeouts[n]) clearTimeout(arTimeouts[n]);
           arIsRunning[n] = false;
        }
    }
    else
    {
        arTimeouts[n] = setTimeout("ScrollThreeRight("+ n +","+ mypix +","+ increment +")",timeout);
    }
    
}

var firsttime = true

function ScrollThreeLeft(n,pix,increment,timeout)
{
    
    mypix = pix - increment;


    if (arCurrentLeft[n]>= 30)
	{
	arCurrentLeft[n] = 30-(arWidths[n]);
	} else {
	arCurrentLeft[n] += increment;
	}


    arScrollDivs[n].style.left  = arCurrentLeft[n]+ "px";
    
    
    if (mypix < 100)
    { 

        arStop[n] = true;
    }
    
    if (arStop[n] == true)
    {
   
        if ((arCurrentLeft[n]-30) % 165 != 0)
        {
            arTimeouts[n] = setTimeout("ScrollThreeLeft("+ n +","+ mypix +","+ increment +")",timeout);
       
        } 
        else
        {    
           arStop[n] = false;
           if (arTimeouts[n]) clearTimeout(arTimeouts[n]);
           arIsRunning[n] = false;
          
        }
    }
    else
    {
        arTimeouts[n] = setTimeout("ScrollThreeLeft("+ n +","+ mypix +","+ increment +")",timeout);
    }
    
}






/* oude code



function StartScroll(dir, n){
    if (arIsRunning[n] == false)
    {
        arIsRunning[n] = true;
        arScrollDivs[n] = document.getElementById("model_thumbnails_container" + n);
        if  (dir == "left")  ScrollLeft(n); 
        if  (dir == "right") ScrollRight(n); 
      
    }
}

function StopScroll(n){

    arStop[n] = true;

}


function ScrollRight(n)
{

    if (arCurrentLeft[n] <= -(arWidths[n]))
	{
	arCurrentLeft[n]=0;
	} else {
	arCurrentLeft[n] -= 3;
	}

    arScrollDivs[n].style.left  = arCurrentLeft[n] + "px";
    
    
    
    if (arStop[n] == true)
    {
   
        if ((arCurrentLeft[n]-30) % 165 != 0)
        {
            arTimeouts[n] = setTimeout("ScrollRight("+ n +")",30)
        } 
        else
        {    
           arStop[n] = false;
           if (arTimeouts[n]) clearTimeout(arTimeouts[n]);
           arIsRunning[n] = false;
        }
    }
    else
    {
        arTimeouts[n] = setTimeout("ScrollRight("+ n +")",5)
    }
}

function ScrollLeft(n)
{

    if (arCurrentLeft[n]>= 30)
	{
	arCurrentLeft[n] = 30-(arWidths[n]);
	} else {
	arCurrentLeft[n] += 3;
	}

    arScrollDivs[n].style.left  = arCurrentLeft[n]+ "px";

   
    
        if (arStop[n] == true)
    {
   
        if ((arCurrentLeft[n]-30) % 165 != 0)
        {
            arTimeouts[n] = setTimeout("ScrollLeft("+ n +")",30)
        } 
        else
        {    
           arStop[n] = false;
           if (arTimeouts[n]) clearTimeout(arTimeouts[n]);
           arIsRunning[n] = false;
          
        }
    }
    else
    {
        arTimeouts[n] = setTimeout("ScrollLeft("+ n +")",5)
    }
}
*/

