
function EspacePub(id,liste) {
	
	this.id = id;
	this.liste = liste;
	this.contenaire = $(id);
	this.index = -1;
	this.next();
}


function EspacePub_getNbPub()
{
	return this.liste.length;
}

function EspacePub_next()
{
	this.index++;
	this.index = (this.index == this.liste.length)?0:this.index;
	if(this.liste.length > 1)this.contenaire.update(this.liste[this.index].contenu);
	this.notifServeur(this.liste[this.index].libele)
	this.wait();
}

function EspacePub_wait()
{
	setTimeout(this.next.bind(this),this.liste[this.index].duree*1000);
}



function EspacePub_notifServeur(libele)
{
	// ANALYTICS
	
	pageTracker._trackPageview("Pub_Affichage_"+libele);
	
}

EspacePub.prototype.next = EspacePub_next;
EspacePub.prototype.wait = EspacePub_wait;
EspacePub.prototype.notifServeur = EspacePub_notifServeur;
EspacePub.prototype.getNbPub = EspacePub_getNbPub;
