//
//  PlayList Manager JS
//  author: Jordan Samouh
//  company: Brainsonic
//  version: 0.1
//  date :   2008/02/08
var playList = null;

var PlayList = function(url_site, onMediaRefresh){

	this.tabMedia = new Array();
	this.indiceTab = 0;
	this.activePlayList = 1;
	this.url = url_site;
	this.onMediaRefresh = typeof onMediaRefresh == 'function' ? onMediaRefresh 
			 												   : function(mediaId){};
}

PlayList.prototype = {
	addInPlayList : function(idMedia){
		this.tabMedia.push(idMedia);
	},
	
	loadPlayList : function(){
		if ((this.activePlayList == 0) || (this.tabMedia.length == 0)) return;
		if (this.indiceTab == this.tabMedia.length) 
		{
			this.indiceTab = 0;
		}
		var objMedia = this.tabMedia[this.indiceTab++];
		this.refreshZone(objMedia, true);
	},

	refreshZone : function (mediaId, active)
	{
		if (active == 'undefined' || !active)
			playList.activePlayList = 0;
		
		// refresh Zone for the media (See player.js)
		this.onMediaRefresh(mediaId);
	}
}
