/*
	Funzionamento dello slideshow / non toccate queste righe se non conoscete javascript
*/
// Additional methods for Element added by SU, Couloir
Object.extend(Element, {
	getWidth: function(element) {
   	element = $(element);
   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   	element = $(element);
    	element.style.height = h +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});
// Rules
var myrules = {
	'#next' : function(element){
		element.onclick = function(){
			nextPhoto();
			}
	},
	'#slideshow' : function(element){
		element.onload = function(){
			new Effect.Appear(this,{duration: 1});
//			setTimeout(nextPhoto,ssSpeed*1000);
		}
	}
};
var idPhoto = -1;
var arrayPhoto = new Array();
//=============================================
/*
	Parametri slideshow / da modificare
*/ // pausa tra una foto e l'altra, in secondi
var ssSpeed = 8;
var imgPath = "../img/"

// percorsi delle foto, relativi al file slideshow_js.html
//arrayPhoto[0] = './images/slideshow/00.jpg';
//arrayPhoto[1] = './images/slideshow/01.jpg';
//arrayPhoto[2] = './images/slideshow/02.jpg';
//arrayPhoto[3] = './images/slideshow/03.jpg';
//=============================================
/*
	Funzionamento dello slideshow / non toccate queste righe se non conoscete javascript
*/
function nextPhoto (){
	var ss = $('slideshow');
	new Effect.Fade(ss,{duration: 1});
	setTimeout(loadPhoto,1000);
	
}
function loadPhoto (){
	var ss = $('slideshow');
	if (idPhoto < arrayPhoto.length-1){
		idPhoto = idPhoto+1;
		Element.setSrc(ss,imgPath + arrayPhoto[idPhoto]);
	} else {
		idPhoto = 0;
		Element.setSrc(ss,imgPath + arrayPhoto[idPhoto]);
	}
}
