var mt=0;
var position=0;
function scrollShopSlip(dir,overRide){
clearTimeout('tDown'); 
clearTimeout('tUp');
//having these above commands seems to help prevent jittering if the down and up arrows are pressed too quickly after one another.
if(overRide){position=overRide;}
//the 'overRide' variable is used for the auto-scrolling that happens on sample pages that feature samples in the bottom two quarters of the sample slip.

  if (dir==1 && position==0){
  if(mt>-430){
    document.getElementById("scrollButtonDown").style.marginLeft = '0px';
    document.getElementById("shopIconSlip").style.marginTop = mt+'px';
	mt=mt*1.09-1;
	if(mt<-431){mt=-430;document.getElementById("shopIconSlip").style.marginTop = mt+'px';}//This line deals with the gap resulting from the multiplication of mt, and ensures that the sampleIconSlip gets positioned just right.
	tUp=setTimeout("scrollShopSlip(1)",10);
	}else{document.getElementById("scrollButtonDown").style.marginLeft = '5px'; position=1; setPositionBox(2); stScrlBtnOpcty('normal'); stScrlBtnOpcty('noDown');return null;}
  }
  
  if (dir==0 && position==1){
  if(mt<1){
    document.getElementById("scrollButtonUp").style.marginLeft = '0px';
    document.getElementById("shopIconSlip").style.marginTop = mt+'px';
	mt=mt*0.95+1;
	if(mt>1){mt=0;document.getElementById("shopIconSlip").style.marginTop = mt+'px';}
	tDown=setTimeout("scrollShopSlip(0)",10);
	}else{document.getElementById("scrollButtonUp").style.marginLeft = '5px'; position=0; setPositionBox(1); stScrlBtnOpcty('normal'); stScrlBtnOpcty('noUp');return null;}
  }
}

function setPositionBox(position){
for (i=1; i<5; i++){
  var brdrclr = (i==position) ? 'white' : 'rgb(230,230,230)';
  var bgndclr = (i==position) ? 'silver' : 'rgb(250,250,250)';
  document.getElementById("positionBox"+i).style.backgroundColor = bgndclr;
  document.getElementById("positionBox"+i).style.borderColor = brdrclr;
  }
}

function stScrlBtnOpcty(state){
//alert('called');
if (state == 'noUp'){
    document.getElementById("scrollButtonUp").style.filter = "alpha(opacity=50)";
	document.getElementById("scrollButtonUp").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	document.getElementById("scrollButtonUp").style.MozOpacity = "50%";
	document.getElementById("scrollButtonUp").style.KhtmlOpacity = "0.5";
	document.getElementById("scrollButtonUp").style.opacity = "0.5";
	document.getElementById("scrollButtonUp").style.cursor='none';
	}
if (state == 'noDown'){
    document.getElementById("scrollButtonDown").style.filter = "alpha(opacity=50)";
	document.getElementById("scrollButtonDown").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	document.getElementById("scrollButtonDown").style.MozOpacity = "50%";
	document.getElementById("scrollButtonDown").style.KhtmlOpacity = "0.5";
	document.getElementById("scrollButtonDown").style.opacity = "0.5";
	document.getElementById("scrollButtonDown").style.cursor='none';
	}
if (state == 'normal'){
    document.getElementById("scrollButtonUp").style.filter = "alpha(opacity=100)";
	document.getElementById("scrollButtonUp").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
	document.getElementById("scrollButtonUp").style.MozOpacity = "100%";
	document.getElementById("scrollButtonUp").style.KhtmlOpacity = "1.0";
	document.getElementById("scrollButtonUp").style.opacity = "1.0";
    document.getElementById("scrollButtonDown").style.filter = "alpha(opacity=100)";
	document.getElementById("scrollButtonDown").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
	document.getElementById("scrollButtonDown").style.MozOpacity = "100%";
	document.getElementById("scrollButtonDown").style.KhtmlOpacity = "1.0";
	document.getElementById("scrollButtonDown").style.opacity = "1.0";
	document.getElementById("scrollButtonUp").style.cursor='pointer';
	document.getElementById("scrollButtonDown").style.cursor='pointer';
	}
}

