function SlideShow(slideList, image, url, theme, artiste, date, speed, name, pagination) {
	
	this.slideList = slideList;
	this.image = findObj(image);
	this.url = findObj(url);
	this.theme = findObj(theme);
	this.artiste = findObj(artiste);
	this.date = findObj(date);
	this.speed = speed;
	this.name = name;
	this.current = this.slideList.length - 1;
	this.timer = 0;
	this.pagination = findObj(pagination);
	
	for (var i = 0; i < slideList.length; i++) {
		this.pagination.innerHTML += '<a href="javascript:' + name + '.setPage(' + i + ')"><img id="paginationItem' + i + '" style="margin-right:5px;" src="medias/images/pagination_carousel_off.png"></a>';
	}
}

SlideShow.prototype.play = SlideShow_play;
SlideShow.prototype.setPage = SlideShow_setPage;

function SlideShow_play() {
	
	with(this) {
		
		if(current++ == slideList.length-1)
			current = 0;
		
		for(var i = 0; i < slideList.length; i++) {
			
			var paginationItem = findObj("paginationItem" + i);
			
			if(i == current) {
				
				paginationItem.src = "medias/images/pagination_carousel_on.png";
			}else {
				
				paginationItem.src = "medias/images/pagination_carousel_off.png";
			}
		}
		
		switchImage(image, slideList[current]);
		url.href = slideList[current].url;
		theme.innerHTML = slideList[current].theme;
		artiste.innerHTML = slideList[current].name;
		date.innerHTML = slideList[current].date;
		
		clearTimeout(timer);
		
		timer = setTimeout(name + '.play();', speed);
	}
}

function SlideShow_setPage(pPage) {
	
	with (this) {
		if(pPage < slideList.length) {
			
			current = pPage;
			
			for(var i = 0; i < slideList.length; i++) {
				
				var paginationItem = findObj("paginationItem" + i);
				
				if(i == current) {
					
					paginationItem.src = "medias/images/pagination_carousel_on.png";
				}else {
					
					paginationItem.src = "medias/images/pagination_carousel_off.png";
				}
			}
			
			switchImage(image, slideList[current]);
			url.href = slideList[current].url;
			theme.innerHTML = slideList[current].theme;
			artiste.innerHTML = slideList[current].name;
			date.innerHTML = slideList[current].date;
			
			clearTimeout(timer);
			timer = setTimeout(name + '.play();', speed);
		}
	}
}

function switchImage(image, imgData) {
	
	if (imgData) {
		image.src = imgData.path;
	}
}

function findObj(theObj, theDoc) {
	
	var p, i, foundObj;
	if(!theDoc)
		theDoc = document;
	
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) {
		
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
 	
	if(!(foundObj = theDoc[theObj]) && theDoc.all)
		foundObj = theDoc.all[theObj];
	
	for (i=0; !foundObj && theDoc.forms && i < theDoc.forms.length; i++) {
		foundObj = theDoc.forms[i][theObj];
	}
	
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
		foundObj = findObj(theObj,theDoc.layers[i].document);
	
	if(!foundObj && document.getElementById)
		foundObj = document.getElementById(theObj);

  return foundObj;
}

