// JavaScript Document

// Random image
var theImages = new Array() 

theImages[0] = 'img/foto/foto01.jpg'
theImages[1] = 'img/foto/foto02.jpg'
theImages[2] = 'img/foto/foto03.jpg'
theImages[3] = 'img/foto/foto04.jpg'
theImages[4] = 'img/foto/foto05.jpg'
theImages[5] = 'img/foto/foto06.jpg'
theImages[6] = 'img/foto/foto07.jpg'
theImages[7] = 'img/foto/foto08.jpg'
theImages[8] = 'img/foto/foto09.jpg'
theImages[9] = 'img/foto/foto10.jpg'
theImages[10] = 'img/foto/foto11.jpg'
theImages[11] = 'img/foto/foto12.jpg'
theImages[12] = 'img/foto/foto13.jpg'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" class="foto">');
}

// Open Close div
var currentShownDivID = null;
function showDiv(id) {
	if(currentShownDivID == id)	{
		return;
	}
	
	if(currentShownDivID != null) 	{
		var oldElement = document.getElementById(currentShownDivID);
		oldElement.style.display = "none";
	}
	currentShownDivID = id;
	
    newElement = document.getElementById(id);
	newElement.style.display = 'block';
	
	return;
}