/* number of pages IMPORTANT MUST MATCH number of cells in table, also determines the hiding of the navigation buttons */
var numberofpages = 6 

function pausecomp(Amount) { 

d = new Date() //today's date
while (1)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > Amount ) {break;}
}
}

function slidedata(strdirection) {

  prevbutton.style.visibility = 'hidden';
  nextbutton.style.visibility = 'hidden';
  
  var currentpos = cellsdiv.scrollLeft

	/* how long to pause between each movement try 10 for starters */ 
	var pausefor = 10

	/* width of each cell MUST MATCH setting in style */
	var scrollsize = 740

	/* how many scrooling steps for the ean to slow down the scroll */
	var landing = 1
	
	/* size of each scrolling step */
	var step = scrollsize/20
	
  if (strdirection == "left") {
	  for(i=currentpos; i>=currentpos-scrollsize; i=i - step) {
		
		triggerpoint = eval(currentpos-scrollsize+(step*landing))

		if (i < triggerpoint) {
		  
			for(x=cellsdiv.scrollLeft; x>=currentpos-scrollsize; x=x - 1) {
    			pausefor = pausefor + 1
					if(pausefor>20) { pausefor = 20 }
					pausecomp(pausefor);
			    cellsdiv.scrollLeft = x;
				 showval.value = cellsdiv.scrollLeft
			}		
		}
		
		delaytime.value = pausefor
			
	  pausecomp(pausefor);
    cellsdiv.scrollLeft = i;
		showval.value = cellsdiv.scrollLeft
    }
		nextbutton.style.visibility = 'visible';
		if (cellsdiv.scrollLeft != 0) {prevbutton.style.visibility = 'visible';}

	}

  if (strdirection == "right") {
		for(i=currentpos; i<=currentpos+scrollsize; i=i + step) {
		
		triggerpoint = eval((currentpos+scrollsize)-(step*landing))
		
		if (i > triggerpoint) {
		
		  for(x=cellsdiv.scrollLeft; x<=currentpos+scrollsize; x=x + 1) {
    			pausefor = pausefor + 1
					if(pausefor>20) { pausefor = 2 }
					pausecomp(pausefor);
			    cellsdiv.scrollLeft = x;
				 showval.value = cellsdiv.scrollLeft
			}		
		}

		delaytime.value = pausefor
	  pausecomp(pausefor);
    cellsdiv.scrollLeft = i;
		showval.value = cellsdiv.scrollLeft
    }
		prevbutton.style.visibility = 'visible';
	  if (cellsdiv.scrollLeft != numberofpages*scrollsize) {nextbutton.style.visibility = 'visible';}
	}
}

function jumptopage(intwhichpage) {

  prevbutton.style.visibility = 'hidden';
  nextbutton.style.visibility = 'hidden';

  var currentpos = cellsdiv.scrollLeft

	/* how long to pause between each movement try 10 for starters */ 
	var pausefor = 10

	/* width of each cell MUST MATCH setting in style */
	var scrollsize = 740

	/* how many scrolling steps for the end to slow down the scroll */
	var landing = 1
	
	/* size of each scrolling step */
	var step = scrollsize/20
	
	if (currentpos < intwhichpage*scrollsize) {
	  strdirection = "right";
	}	
	
	if (currentpos >= intwhichpage*scrollsize) {
 	  strdirection = "left";
	}	

	if (strdirection == "left") {

		triggerpoint = eval((intwhichpage*scrollsize)-scrollsize+(step*landing))
	
		for(i=currentpos; i>=(intwhichpage*scrollsize)-scrollsize; i=i - step) {
		
		if (i < triggerpoint) {
		  for(x=cellsdiv.scrollLeft; x>=(intwhichpage*scrollsize)-scrollsize; x=x - 1) {
    			pausefor = pausefor + 1
					if(pausefor>20) { pausefor = 2 }
					pausecomp(pausefor);
			    cellsdiv.scrollLeft = x;
 				 showval.value = cellsdiv.scrollLeft
			}		
		}

		delaytime.value = pausefor
	  pausecomp(pausefor);
    cellsdiv.scrollLeft = i;
		showval.value = cellsdiv.scrollLeft
    }
		prevbutton.style.visibility = 'visible';
	  if (cellsdiv.scrollLeft != numberofpages*scrollsize) {nextbutton.style.visibility = 'visible';}
		}
	
	
	if (strdirection == "right") {
	
      triggerpoint = eval((intwhichpage*scrollsize)-scrollsize-(step*landing))
		
		for(i=currentpos; i<=(intwhichpage*scrollsize)-scrollsize; i=i + step) {

		if (i > triggerpoint) {

		  for(x=cellsdiv.scrollLeft; x<=(intwhichpage*scrollsize)-scrollsize; x=x + 1) {
    			pausefor = pausefor + 1
					if(pausefor>20) { pausefor = 2 }
					pausecomp(pausefor);
			    cellsdiv.scrollLeft = x;
				 showval.value = cellsdiv.scrollLeft
			}		
		}

		delaytime.value = pausefor
	  pausecomp(pausefor);
    cellsdiv.scrollLeft = i;
		showval.value = cellsdiv.scrollLeft
    }
		prevbutton.style.visibility = 'visible';
	  if (cellsdiv.scrollLeft != numberofpages*scrollsize) {nextbutton.style.visibility = 'visible';}
		}
		
		
}
