var move = 0;
var time;
var theTime=20000;
var currentImage = 0;
var totalImages = 16;
var viewSize = 6;
var effectA = null;
var pxPs = 150;	
var moving = true;

function moveToLeft()
{	

	/*
	 *
	 * moveAmount = width of inner box - (width of outside box + abs[left value of inner box]) 
	 *
	 * duration: 
	 *   a) lets say 1 second per 200px 
	 *   b) therefore, duration = moveAmount/100 (float)
	 */ 

	var width = document.getElementById("imageBoxInside").style.width;
	width = width.replace("px", "");
	var left = document.getElementById("imageBoxInside").style.left;
	left = left.replace("px", "");
	var width2 = document.getElementById("imageBox").style.width;
	width2 = width2.replace("px", "");
	var moveAmount = width - (width2 - left);
	var child2 = width2-width;
	
	/*
	 *
	 * START HERE ON TUESDAY!!!!
	 *
	 */
	
	if(left <= width-width2)
  	{
  		moving = true;
  		effectA = new Effect.Move('imageBoxInside', { x: -moveAmount, y: 0, duration: (Math.abs(moveAmount)/pxPs), transition: Effect.Transitions.linear });
  		moving = false;
  		/*document.getElementById("leftM").style.cursor='pointer';
  		currentImage--;*/
  		
  		/*
  		if (currentImage == 0) {
  			document.getElementById("rightM").style.cursor='default';
  		}*/
  	}
  	
	document.getElementById("debug1").innerHTML = 'inner width: ' + width;
	document.getElementById("debug2").innerHTML = 'left: ' + left;
	document.getElementById("debug4").innerHTML = 'move time: ' + (moveAmount/pxPs);
	document.getElementById("debug3").innerHTML = 'move: ' + moveAmount;
	document.getElementById("debug5").innerHTML = 'diff: ' + child2;
}

function moveToRight(tot)
{
	var width = document.getElementById("imageBoxInside").style.width;
	width = width.replace("px", "");
	var child = document.getElementById("imageBoxInside").style.left;
	child = child.replace("px", "");
	document.getElementById("debug1").innerHTML = 'inner width: ' + width;
	document.getElementById("debug2").innerHTML = 'left: ' + child;

	var moveAmount = document.getElementById("imageBoxInside").style.left;
	moveAmount = moveAmount.replace("px", "");
	document.getElementById("debug3").innerHTML = 'move: ' + moveAmount;
	//if(currentImage < tot-viewSize)
  	//{
  		//document.getElementById("rightM").style.cursor='pointer';
		effectA = new Effect.Move('imageBoxInside', { x: -moveAmount, y: 0, duration: (Math.abs(moveAmount)/pxPs), transition: Effect.Transitions.sinoidal });
		/*currentImage++;*/
		
		/*if (currentImage == totalImages-viewSize) {
  			document.getElementById("leftM").style.cursor='default';
  		}*/
	//}
}

function stopMove() {
  //if (time) clearTimeout(time);
  if (effectA != null) {
  	effectA.cancel();
  	effectA = null;
  }
}

function showImage(dir, pad, imageName){
	document.getElementById("largePicture").src = imageName;
}

function swap(hide, show) {
	document.getElementById(hide).style.display='none';
	document.getElementById(show).style.display='block';
}


function showComment(whatNews) {
	new Effect.SlideDown(whatNews);
}

function hideComment(whatNews) {
	new Effect.SlideUp(whatNews);
}

function clearField(obj){
	if (obj.defaultValue==obj.value) obj.value = '';
}

function toggle(what) {
	if (document.getElementById(what).style.display=="none") {
		document.getElementById(what).style.display="block";
	} else {
		document.getElementById(what).style.display="none";
	}	
}
