var startnum;
var pos; // initial position
var thumbnum; // number of projects
var pos2;
var runit;
var dir;
var target;
var next;
var topend;
var thumbid = startnum;
var bottomend;
var loaded = false;
var currentimage;
var directory;

function setStartVals(pnum, start, slider, src, dir) {
	thumbnum = pnum;
	startnum = start;
	thumbid = startnum;
  	pos = 0 - (92 * (startnum - 1));
	target = slider;
	next = false;
	topend = 0;
	bottomend = 0 - (92 * (thumbnum - 4));
	loaded = true;
	box = document.getElementById(target);
	box.style.top = pos + 'px';
	box.style.height = 92 * thumbnum;
	box.style.display = 'block';
	currentimage = src;
	directory = dir;
}

function setPhoto(src) {
	currentimage = src;
	document.getElementById('mainphoto').src = directory + '/med/' + src;	
	document.getElementById('mainphoto').alt = src;	
	document.getElementById('mainphoto').title = src;	
}
function displaySuper() {
	document.getElementById('superbox').style.display='block';
	document.getElementById('superimage').src=directory + '/lrg/' + currentimage;
	document.getElementById('superimage').alt=currentimage;
}
function hideSuper() {
	document.getElementById('superbox').style.display='none';
}
function startMove(arg1) {
  if (!runit && !next && loaded) {
	  setVals(arg1);
  }	
}

function setVals(arg1) {	
  if (arg1 != 'stop') {
	  runit = true; 
	  dir = arg1;		
	  if (dir == 'down') {
		  pos2 = pos - 92;
	  } else {
		  pos2 = pos + 92;	
	  }	
	  next = true;	
	  shiftView();
  } else {	
	  next = false;			
  }
}

function shiftView() { 
  if (dir == 'down' && pos2 >= bottomend) {
	document.getElementById('uparrow').style.backgroundImage = "url(images/uparrow.gif)";
	if (pos > pos2) {	
		pos -= 8;		
		box.style.top = pos + 'px';	
	} else {	
		box.style.top = pos2 + 'px';	
		pos = pos2;	
		runit = false;
	}	
  } else if (dir == 'down' && pos2 < bottomend) {
	runit = false;
	next = false;
	document.getElementById('downarrow').style.backgroundImage = "url(images/bottomend.gif)";
  } 
  if (dir == 'up' && pos2 <= topend) {
	document.getElementById('downarrow').style.backgroundImage = "url(images/downarrow.gif)";
	if (pos < pos2) {	
		pos += 8;				
		box.style.top = pos + 'px';			
	} else {		
		box.style.top = pos2 + 'px';		
		pos = pos2;			
		runit = false;				
	}		
  } else if (dir == 'up' && pos2 > topend) {
	runit = false;
	next = false;
	document.getElementById('uparrow').style.backgroundImage = "url(images/topend.gif)";
  }
  if (runit) {		
	  setTimeout("shiftView();", 20);		
  } else if (next) {		
	  setVals(dir);		
  } else {
	thumbid = Math.abs((pos + 2)/92) + 1;
  }
}