var counter = 0;
var imageIndex = 0;
var totalImages = 9;

function hideBlock() {
	document.getElementById('slideshowWrapper').style.visibility='hidden';
	document.getElementById('floatingImage').style.visibility='hidden';
	document.getElementById('content').style.visibility='visible';
	counter = 0;
}

function showPage(pageName) {
	currentLocation = window.location.toString();
	baseUrl = currentLocation.substring(0, currentLocation.lastIndexOf('/')+1);
	newLocation = baseUrl + pageName + '/';	
	window.location = pageName;
}

function showBlock(tmpImageIndex) {
	document.getElementById('slideshowWrapper').style.visibility='visible';
	document.getElementById('content').style.visibility='hidden';
	
	myImg = document.getElementById('floatingImage');
	myImg.style.visibility='visible';

	// this is a workaround for a MSIE/Windows
	// caching problem where it displays
	// the previous image before drawing the next one
	myImg.src = "../nav/background.png";

	imageIndex = tmpImageIndex;
	currentImage = imageList[imageIndex];
	myImg.src =  currentImage[0] ;

	myImg.width = currentImage[1];
	myImg.height = currentImage[2];
	
	leftOffset = -((Math.round(currentImage[1]/2)) + 1);
	topOffset = -(Math.round(currentImage[2]/2));
	
	myImg.style.top = topOffset + 'px';
	myImg.style.marginLeft = leftOffset + 'px';
	
}

function nextBlock() {
	counter++;
	if (counter == 9) {
		hideBlock();	 
	} else {
		imageIndex = ++imageIndex % totalImages;
		showBlock(imageIndex);
	}
}

function prevBlock() {
	counter--;
	if (counter == -9) {
		hideBlock();	 
	} else {
		if (imageIndex == 0) {
			imageIndex = totalImages - 1;
		} else {
			imageIndex--;
		}
	
		showBlock(imageIndex);
	}
}