function fixBoxSize() {
	containerHeight = $('bigImgContainer').getHeight();
	$('bigImgContainer').setStyle({
  		height: containerHeight+"px"
  	});
}

function setBoxSize() {
	containerHeight = $('bigImage').getHeight();
	$('bigImgContainer').setStyle({
  		height: containerHeight+"px"
  	});
}

function updateBigImage(inID) {
	if (inID == 0 && hasMovieVar == 1) {	
		showVideo();
	} else {
		$('bigVideoContainer').hide();
		fadeDuration = 0.2;
		appearDuration = 0.7;
		imageDir='files/big/';
		imageName = imageList[inID]+'.jpg';
		
		$('bigImage').fade({ duration: fadeDuration, afterFinish: function(){  
	       $('bigImage').src = imageDir+imageName; 
	       $('bigImage').appear({duration: appearDuration, afterFinish: function(){
	       		setBoxSize();
	       	}
	       });  		       
	     } 
		}); 
	   	fixBoxSize();
   	}
   	imageListIndex = inID;
}

function showVideo() {
	$('bigImage').hide();
	$('bigVideoContainer').appear();
	$('bigImgContainer').setStyle({
  		height: "0"
  	});
}

function prevImage() {
	if(imageListIndex == 0) {
		imageListIndex = imageList.length-1; }
	else {
		imageListIndex--; }
	updateBigImage(imageListIndex);
}

function nextImage() {
	if(imageListIndex == imageList.length-1) {
		imageListIndex = 0; }
	else {
		imageListIndex++; }
	updateBigImage(imageListIndex);
}


