

	//	$Id : radios.js 1.0 20/03/2007 by the Kankrelune 	//
	//-----------------------------------------------------------------------------//
	//			     Tiny Radio Manager				//
	//				by The Kankrelune			//
	//			Copyright SCFactory © 2005			//
	//			<http://www.webfaktory.info/>		//
	//			<contact@webfaktory.info>			//
	//-----------------------------------------------------------------------------//
	//	This program is free software; you can redistribute it	//
	//		and/or modify it under the terms of the		//
	//		GNU General Public License as published by	//
	//			the Free Software Foundation.			//
	//										//
	//	either version 2 of the License, or (at your option)	//
	//  				any later version.				//
	//										//
	//	You may not change or alter any portion of this		//
	//	comment or credits  of supporting developers from	//
	//	this source code or any supporting source code		//
	//	which is considered copyrighted (c) material of		//
	//		the original comment or credit authors.		//
	//										//
	//	This program is distributed in the hope that it will be	//
	//	useful, but WITHOUT ANY WARRANTY, without		//
	//	even the implied warranty of MERCHANTABILITY	//
	//	or FITNESS FOR A PARTICULAR PURPOSE.		//
	//										//
	//	See the GNU General Public License for more details.	//
	//										//
	//  		You should have received a copy of the GNU	//
	//	General Public License along with this program;		//
	//										//
	//		if not, write to :						//
	//			Free Software Foundation, Inc.		//
	//			59 Temple Place, Suite 330			//
	//			Boston, MA  02111-1307 USA			//
	//-----------------------------------------------------------------------------//



var userBrowser = {

	navName: navigator.appName.toLowerCase(),
	userAgent: navigator.userAgent.toLowerCase(),
	
	version: {
				int: parseInt(navigator.appVersion),
				float: parseFloat(navigator.appVersion)
			},
	
	isDom: 				function() { return (document.getElementById); },
	isDall: 			function() { return (document.all); },
	isDlayers: 			function() { return (document.layers); },
	isIe: 				function() { return (this.userAgent.indexOf("msie") != -1); },
	isIeSup:			function() { return (this.isIe() && (this.version.int >= 4)); },
	isNtscp:			function() { return (this.navName.indexOf('netscape') != -1); },
	isNtscp4:			function() { return (this.isNtscp() && (this.version.int == 4)); },
	isMac:				function() { return (this.userAgent.indexOf("mac") != -1); },
	isGecko:			function() { return (this.userAgent.indexOf("gecko") != -1); },
	isFirefox:			function() { return (this.userAgent.indexOf("firefox") != -1); },
	isKonqueror:		function() { return (this.userAgent.indexOf("konqueror") > -1); },
	isOpera: 			function() { return (window.opera); },
	isOpera5:			function() { return (this.userAgent.indexOf("opera 5") > -1 || this.userAgent.indexOf("opera/5") > -1 || this.userAgent.indexOf("opera 6") > -1 || this.userAgent.indexOf("opera/6") > -1); },
	revision:			function() { return (this.isGecko()) ? parseFloat(this.userAgent.split("rv:")[1]) : 0; },
	firefoxVersion:		function() { return (this.isFirefox()) ? this.userAgent.substring(this.userAgent.indexOf("firefox")).split("/")[1] : 0;},
	firefoxExtraHeight:	function() { return (this.isFirefox()) ? ((parseFloat(this.firefoxVersion()) >= 0.1) ? 16 : 0) : 0; }
};

/********************  Misc utilities functions ********************/

if(!document.getElementById)
{
	Object.extend(window.document, {
		getElementById: function(id) 
		{
			if(document.all) 
			{
				if (typeof document.all[id] == "object")
					return document.all[id];
						else 
							return void(0);
			}
			else if(document.layers) 
			{
				if (typeof document[id] == "object")
					return document[id];
						else 
							return void(0);
			}
			else return void(0);
		}
	});
}

Object.extend(String.prototype, {	

	dirname: function(str)
	{
		var pos = this.lastIndexOf('/');
		
		if(!pos)
			return this;
		
		return this.substr(0,pos);
	},
	
	trim:  function(str) 
	{
		var escapedString = unescape(this);
		return escapedString.replace(/(^\s*)|(\s*$)/g, "");
	},
	
	ucFirst: function() 
	{ 
		return this.substr(0,1).toUpperCase() + this.substr(1,this.length); 
	},
	
	htmlspecialchars: function()
	{
		var escapedString = this.replace(/"/g, '&quot;'); 
		escapedString = escapedString.replace(/'/g, '&#039;');escapedString = escapedString.replace(/&/g, '&amp;');
		escapedString = escapedString.replace(/</g, '&lt;'); escapedString = escapedString.replace(/>/g, '&gt;');
		
		return escapedString;
	},
	
	html_specialchars_decode: function()
	{
		var escapedString = this.replace(/&quot;/g, '"'); 
		escapedString = escapedString.replace(/&#039;/g, "'");escapedString = escapedString.replace(/&amp;/g, '&');
		escapedString = escapedString.replace(/&lt;/g, '<'); escapedString = escapedString.replace(/&gt;/g, '>');
		
		return escapedString;
	},
	
	url_encode: function()
	{
		return escape(this);
	},
	
	url_decode: function()
	{
		return unescape(this.replace(/\+/g," "));
	},
	
	nl2br: function() 
	{ 
		return this.replace(/\n/g, '<br />'); 
	}	

});

Object.extend(Array.prototype, {	

	empty: function()
	{
		var a = [];
		
		return (this == a);
	}
});

function getCookie(name)
{
	var cookie_name = name + "=";
	var cookie_length = document.cookie.length;
	var cookie_begin = 0;
	
	while (cookie_begin < cookie_length)
	{
		value_begin = cookie_begin + cookie_name.length;
		
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
		{
			var value_end = document.cookie.indexOf (";", value_begin);
			
			if (value_end == -1)
				value_end = cookie_length;
			
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		
		cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
		
		if (cookie_begin == 0)
			break;
	}
	
	return false;
}

function setCookie(name, value, expires, path, domain, secure)
{
	var currentDate = new Date();
	
	if (!expires)
		expires = currentDate;
			else
				expires = new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDay(),(currentDate.getMinutes()+expires)); 
	
	var cookieVars = name + "=" + escape(value) + ";expires=" + expires.toGMTString();
	
	if(path)
		cookieVars += ";path="+path;
	
	if(domain)
		cookieVars += ";domain="+domain;
	
	if(secure)
		cookieVars += ";secure";
	
	document.cookie = cookieVars;
}

function deleteCookie(name) 
{
	document.cookie = name+"= ;expires=Wed, 31 Dec 1980 0:0:0 UTC"
}

/********************  Radio Cat Utilities class ********************/

var radioPlayerCat = Class.create();

radioPlayerCat.prototype = {
	
	name: '',
	id: 0,
	_radios: [],
	_count: 0,
	
	initialize: function(name, id) 
	{
		this.name = name;
		this.id = id;
		this._radios = [];
		this._count = 0;
	},
	
	addRadio: function(name, url)
	{
		this._radios[this._count] = new radioPlayerRadio(name, url, this._count++, this.id);
	},
	
	getRadioById: function(id)
	{
		if(!this._radios[id])
			return false;
		
		return this._radios[id];
	},
	
	getRadioByName: function(name)
	{
		name = name.toLowerCase();
		
		for(var i=0;i<this._radios.length;i++)
		{
			if(this._radios[i].name.toLowerCase() == name)
				return this._radios[i];
		}
		
		return false;
	},
	
	haveRadio: function()
	{
		return (!this._radios.empty());
	},
	
	count: function()
	{
		return this._count-1;
	}
};


/********************  Radio Utilities class ********************/

var radioPlayerRadio = Class.create();

radioPlayerRadio.prototype = {
	
	name: '',
	url: '',
	type: '',
	cat: 0,
	id: 0,
	path: "0-0",
	
	initialize: function( name, url, id, cid) 
	{
		this.name = name;
		this.url = url;
		this.type = '?';
		this._setType();
		this.cat = cid;
		this.id = id;
		this.path = this.cat+"-"+this.id;
	},
	
	_setType: function()
	{
		var pos = this.url.lastIndexOf('.');
		
		if(pos != -1)
		{
			this.type = this.url.substr(pos+1,this.url.length).toLowerCase();
			
			//if(this.url.lastIndexOf('ogg') != -1) // .ogg.m3u fix
			//	this.type = 'ogg';
		}
	},
	
	mainUrl: function()
	{
		var first = this.url;
		var current = this.url;
		var last = this.url;
		var i=0;
		
		while(true)
		{
			last = current;
			i++;
			current = current.dirname();
			
			if(current == 'http:/' || current == 'http:')
				return last;
					else if(i++ > 10)
						return first;
		}
	}
};

/********************  RadioPlayer Utilities class ********************/

	/***************************/
	/**** Plugin detector Class ****/
	/***************************/

var pluginDetector = Class.create();

pluginDetector.prototype = {
	
	initialize: function()
	{
		this.detectableWithVB = (userBrowser.isIe() && (userBrowser.userAgent.indexOf('win') != -1));
	},
	
	searchPlugin: function(plugin)
	{
		switch(plugin)
		{
			case "real":		return this.detectReal(); break;
			case "flash":		return this.detectFlash(); break;
			case "quicktime":	return this.detectQuickTime(); break;
			case "windows":		return this.detectWindowsMedia(); break;
			default:			return false; break;
		}
	},

	detectPlugin: function() 
	{
		var daPlugins = this.detectPlugin.arguments;
		var pluginFound = false;
		
		if (navigator.plugins && navigator.plugins.length > 0) 
		{
			var pluginsArrayLength = navigator.plugins.length;
			for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; ++pluginsArrayCounter ) 
			{
				var numFound = 0;
				for(namesCounter=0; namesCounter < daPlugins.length; ++namesCounter) 
				{
					if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) 
						numFound++;
				}
				
				if(numFound == daPlugins.length) 
				{
					pluginFound = true;
					break;
				}
			}
		}
		return pluginFound;
	}, 

	detectFlash: function() 
	{
		var pluginFound = this.detectPlugin('Shockwave','Flash'); 
		
		if(!pluginFound && this.detectableWithVB)
			pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
		
		return pluginFound;
	},

	detectQuickTime: function() 
	{
		var pluginFound = this.detectPlugin('QuickTime');
		
		if(!pluginFound && this.detectableWithVB)
			pluginFound = detectQuickTimeActiveXControl();
		
		return pluginFound;
	},

	detectReal: function() 
	{
		var pluginFound = this.detectPlugin('RealPlayer');
		
		if(!pluginFound && this.detectableWithVB) 
			pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
							detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
							detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
		
		return pluginFound;
	},

	detectWindowsMedia: function() 
	{
		var pluginFound = this.detectPlugin('Windows Media');
		
		if(!pluginFound && this.detectableWithVB)
			pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
		
		return pluginFound;
	}
};

	/***************************/
	/**** Objects Writer Class ****/
	/***************************/

var objectWriter = Class.create();

objectWriter.prototype = {

	initialize: function(contenerId)
	{
		this.contenerId = contenerId;
		this.pluginDetector = new pluginDetector();
		
		if(contenerId)
		{
			var newDiv = document.createElement("div");
			newDiv.setAttribute("style", "text-align:center; margin:auto; padding-bottom:10px;");
			newDiv.innerHTML = '<h1>Vous écoutez "<span id="radioPlayerCurrentRadio"></span>"...</h1>';
			
			if(userBrowser.isIe())
				newDiv.innerHTML += '<br />';
			
			$(this.contenerId).appendChild(newDiv);
			
			newDiv = document.createElement("div");
			newDiv.id = "radioPlayerContener";
			newDiv.setAttribute("style", "text-align:center; margin:auto; padding-bottom:10px;");
			$(this.contenerId).appendChild(newDiv);
			$(this.contenerId).appendChild(document.createElement("br"));
		}
	},
	
	resetContener: function()
	{
		$("radioPlayerContener").innerHTML = "";
	},
	
	writeContents: function(contents)
	{
		$("radioPlayerContener").innerHTML += contents+"\n";
	},
	
	setInnerAttributs: function() 
	{
		try 
		{
			var All = $("radioPlayerContener").getElementsByTagName("*");
			for (var i=0; i<All.length; i++) 
			{
				All[i].id = All[i].getAttribute("id")
				All[i].name = All[i].getAttribute("name")
				All[i].className = All[i].getAttribute("class")
			}
		} 
		catch (ex) { }
	},
	
	writeFor: function(url,type,path)
	{
		var plugin;
		type = type.toLowerCase();
		
		switch(type)
		{
			/*case "pls":
				plugin = "quicktime";
			break;*/
			
			case "mp3":
				plugin = "flash";
			break;
			
			case "ram":
			case "rpm":
			//case "ogg":
			case "pls":
				plugin = "real";
			break;
			
			default:
				plugin = "windows";
			break;
			
		}
		//alert(type);
		
		var player = (this.pluginDetector.searchPlugin(plugin)) ? plugin : false;
		
		if(!player && type == "pls")
		{
			plugin = "quicktime";
			player = (this.pluginDetector.searchPlugin(plugin)) ? plugin : false;
		}
		
		switch(player)
		{
			case "flash":		this.writeForFlash(url); break;
			case "real":		this.writeForRealPlayer(url); break;
			case "windows":		this.writeForWindowsMedia(url); break;
			case "quicktime":	this.writeForQuicktime(url); break;
			default:			this.writeError(plugin); break;
		}
	},
	
	writeForWindowsMedia: function(url) 
	{
		this.resetContener();
		
		if(!userBrowser.isIe())
		{	
			this.writeContents('<object id="objectPlayer" width="400" height="70" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-mplayer2">');
			this.writeContents('	<param name="filename" value="'+url+'" />');
			this.writeContents('	<param name="autostart" value="true" />');
			this.writeContents('	<param name="showcontrols" value="true" />');
			this.writeContents('	<param name="showstatusbar" value="true" />');
			this.writeContents('	<param name="uimode" value="full" />');
			this.writeContents('	<param name="enablecontextmenu" value="true" />');
			this.writeContents('	<param name="stretchtofit" value="true" />');
			this.writeContents('	<embed id="embedPlayer" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" src="'+url+'" width="400" height="70" autostart="true" showcontrols="true" showstatusbar="true" />');
			this.writeContents('</object>');
		}
		else this.writeContents('<embed id="embedPlayer" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" src="'+url+'" width="400" height="70" autostart="1" showcontrols="1" showstatusbar="1" />');
	},

	writeForFlash: function(url,type,path) 
	{
		this.resetContener();
		var anticache = new String(Math.random()*10);
		anticache = anticache.substr(anticache.indexOf(".")+1,anticache.length);
		
		if(!userBrowser.isIe())
		{
			this.writeContents('<object width="200" height="20" id="player" type="application/x-shockwave-flash" data="flash/dewplayer.swf?son=sons/'+url+'&amp;autostart=1&amp;autoreplay=0&amp;bgcolor=f8c018">');
			this.writeContents('	<param name="movie" value="contents/player.swf?anticache='+anticache+'&son='+url.url_encode()+'&autostart=1&showtime=1&bgcolor=FFFFFF" />');
			this.writeContents('	<param name="allowScriptAccess" value="never">');
			this.writeContents('	<param name="quality" value="high" />');
			this.writeContents('	<param name="allowScriptAccess" value="never" />');
			this.writeContents('	<param name="wmode" value="transparent" />');
			this.writeContents('	<param name="menu" value="false" />');
			this.writeContents('	<embed src="contents/player.swf?anticache='+anticache+'&son='+url.url_encode()+'&autostart=1&showtime=1&bgcolor=FFFFFF" quality="high" width="200" height="20" name="player" id="player" allowScriptAccess="never" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			this.writeContents('</object>');
		}
		else this.writeContents('<embed src="contents/player.swf?anticache='+anticache+'&son='+url.url_encode()+'&autostart=1&showtime=1&bgcolor=FFFFFF" quality="high" width="200" height="20" name="player" id="player" allowScriptAccess="never" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	},

	writeForRealPlayer: function(url) 
	{
		this.resetContener();
		
		if(!userBrowser.isIe())
		{
			this.writeContents('<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height="50" width="300">');
			this.writeContents('	<param name="console" value="Clip1" />');
			this.writeContents('	<param name="volume" value="100%" />');
			this.writeContents('	<param name="src" value="'+url+'" />');
			this.writeContents('	<param name="wmode" value="transparent" />');
			this.writeContents('	<param name="allowScriptAccess" value="never" />');
			this.writeContents('	<param name="autostart" value="true" />');
			this.writeContents('	<embed src="'+url+'" type="audio/x-pn-realaudio-plugin" console="Clip1" height="50px" width="300px" autostart="true" />');
			this.writeContents('</object>');
		}
		else this.writeContents('<embed src="'+url+'" type="audio/x-pn-realaudio-plugin" console="Clip1" height="50px" width="300px" autostart="1" />');
	},

	writeForQuicktime: function(url) 
	{
		this.resetContener();
		
		if(!userBrowser.isIe())
		{
			this.writeContents('<object id="player" width="200" height="50" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715">');
			this.writeContents('	<param name="type" value="audio/x-scpls" />');
			this.writeContents('	<param name="filename" value="'+url+'" />');
			this.writeContents('	<param name="allowScriptAccess" value="never" />');
			this.writeContents('	<param name="controller" value="true" />');
			this.writeContents('	<param name="autoplay" value="true" />');
			this.writeContents('	<embed type="audio/mpeg" src="'+url+'" autoplay="true" controller="true" height="50" width="200" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" pluginspace="http://www.apple.com/quicktime/download/" />');
			this.writeContents('</object>');
		}
		else this.writeContents('	<embed type="audio/mpeg" src="'+url+'" autoplay="1" controller="1" height="50" width="200" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" pluginspace="http://www.apple.com/quicktime/download/" />');
	},
	
	writeError: function(plugin)
	{
		this.resetContener();
		this.writeContents('<div class="errorMsg">Désolé le plugin "'+plugin.ucFirst()+' Media Player"<br />n\'est pas installé sur votre ordinateur...'); 
		this.writeContents('<br />'); 
		this.writeContents('ou bien votre navigateur ne le supporte pas...');
		this.writeContents('<br />');
		this.writeContents('Veuillez changer de radio... .. .<\/div>');
	}
};
	
	/***************************/
	/*** Radio Player Main Class ***/
	/***************************/

	
	
var radioPlayer = {

	init: function(contenerId) 
	{
		this.contenerId = contenerId;
		this._radioList = [];
		this._count = 0;
		this.current = null;
		this.objectWriter = new objectWriter(contenerId);
	},
	
	start: function(current)
	{
		var cRS = getCookie("radioPlayerSelected");
		
		if(cRS)
			current = cRS
		
		this.getList(current);
		this.change(current);
	},
	
	resetCats: function()
	{
		this._radioList = [];
		this._count = 0;
	},
	
	getCount: function()
	{
		return this._radioList.lenght;
	},
	
	getCatById: function(id)
	{
		if(!this._radioList[id])
			return false;
		
		return this._radioList[id];
	},
	
	getCatByName: function(name)
	{
		name = name.toLowerCase();
		
		for(var i=0;i<this._radioList.length;i++)
		{
			if(this._radioList[i].name.toLowerCase() == name)
				return this._radioList[i];
		}
		
		return false;
	},
	
	newCat: function(name)
	{
		newCat = new radioPlayerCat(name);
		newCat.id = this._count++;
		
		return newCat;
	},
	
	addCat: function(cat)
	{
		this._radioList[cat.id] = cat;
	},
	
	getByPath: function(xPath)
	{
		if(xPath == '#')
			return false;
		
		if(xPath[xPath.length-1] == '#')
			xPath = xPath.substr(0,xPath.length-1);
		
		xPath = xPath.split("-");
		
		if(!xPath[1])
			return false;
		
		var cat = xPath[0];
		var radio = xPath[1];
		
		if(!this._radioList[cat])
			return false;
		
		return this._radioList[cat].getRadioById(radio);
	},
	
	getSelected: function()
	{
		if(this.current)
		{
			if($("radioPlayerCatSelectorOpt"+this.current.cat))
			{	
				$("radioPlayerCatSelectorOpt"+this.current.cat).selected = true;
				
				this.updateRadioList(this.current.cat);
				
				if($("radioPlayerRadioSelectorOpt"+this.current.id))
					$("radioPlayerRadioSelectorOpt"+this.current.id).selected = true;
						else
							$("radioPlayerRadioSelectorOpt#").selected = true;
			}	
			else 
			{
				$('radioPlayerCatSelector').options.length = 0;
				$('radioPlayerCatSelector').options[$('radioPlayerCatSelector').options.length] = new Option("Choissisez Une Catégorie","#");;
			}
		}
	},
	
	change: function(xPath)
	{
		var radio = this.getByPath(xPath);
		
		if(!radio)
			return false;
		
		setCookie("radioPlayerSelected", xPath, 3600);
		this.current = radio;
		this.writePlayer(radio.url,radio.type,radio.path);
		
		$("radioPlayerCurrentRadio").innerHTML = '<a href="'+radio.mainUrl()+'" title="'+radio.name+'">'+radio.name+'</a>';
		
		this.getSelected();
	},
	
	writePlayer: function(url,type,path)
	{
		this.objectWriter.writeFor(url,type,path);
		this.objectWriter.setInnerAttributs();
	},
	
	nextCat: function()
	{
		/*if(!this.current)
			return false;
		*/
		if(this._radioList[(this.current.cat+1)])
			this.change((this.current.cat+1)+"-0");
				else
					this.change("0-0");
	},
	
	lastCat: function()
	{
		/*if(!this.current)
			return false;
		*/
		if(this._radioList[(this.current.cat-1)])
			this.change((this.current.cat-1)+"-0");
				else
					this.change((this._radioList.length-1)+"-0");
	},
	
	nextRadio: function()
	{
		/*if(!this.current)
			return false;
		*/
		if(this._radioList[this.current.cat].getRadioById(this.current.id+1))
			this.change(this.current.cat+"-"+(this.current.id+1));
				else
					this.change(this.current.cat+"-0");
	},
	
	lastRadio: function()
	{
		/*if(!this.current)
			return false;
		*/
		if(this._radioList[this.current.cat].getRadioById(this.current.id-1))
			this.change(this.current.cat+"-"+(this.current.id-1));
				else
					this.change(this.current.cat+"-"+this._radioList[this.current.cat].count());
	},
	
	getList: function(current)
	{
		var radio = this.getByPath(current);
		
		if(!radio)
			radio = new radioPlayerRadio('','',false,false);
		
		this.current = radio;
		
		var newDiv = document.createElement("div");
		newDiv.setAttribute("style", "text-align: center; margin: auto;");
		
		var lastCat = document.createElement("input");
		lastCat.setAttribute("type", "button");
		lastCat.setAttribute("id", "radioPlayerLastCat");
		lastCat.value = "<<";
		newDiv.appendChild(lastCat);
		newDiv.innerHTML += " ";
		
		var lastRadio = document.createElement("input");
		lastRadio.setAttribute("type", "button");
		lastRadio.value = "<";
		lastRadio.setAttribute("id", "radioPlayerLastRadio");
		newDiv.appendChild(lastRadio);
		newDiv.innerHTML += " ";
		
		var select = document.createElement("select");
		select.setAttribute("name", "radioPlayerCatSelector");
		select.setAttribute("id", "radioPlayerCatSelector");
		select.setAttribute("size", "1");
		
		var option = document.createElement("option");
		option.setAttribute("value", "#");
		option.innerHTML = "Choissisez Une Catégorie";
		select.appendChild(option);
		
		var i = -1;
		
		while(false !== (cat = this.getCatById(++i)))
		{
			option = document.createElement("option");
			option.setAttribute("value", i);
			option.setAttribute("id", "radioPlayerCatSelectorOpt"+cat.id);
			option.innerHTML = cat.name;
			
			if(cat.id == this.current.cat)
				option.setAttribute("selected", "selected");
			
			select.appendChild(option);
		}
		
		newDiv.appendChild(select);
		newDiv.innerHTML += " ";
		
		var select = document.createElement("select");
		select.setAttribute("name", "radioPlayerRadioSelector");
		select.setAttribute("id", "radioPlayerRadioSelector");
		select.setAttribute("size", "1");
		newDiv.appendChild(select);
		newDiv.innerHTML += " ";
		
		var nextRadio = document.createElement("input");
		nextRadio.setAttribute("type", "button");
		nextRadio.setAttribute("id", "radioPlayerNextRadio");
		nextRadio.value = ">";
		newDiv.appendChild(nextRadio);
		newDiv.innerHTML += " ";
		
		var nextCat = document.createElement("input");
		nextCat.setAttribute("type", "button");
		nextCat.setAttribute("id", "radioPlayerNextCat");
		nextCat.value = ">>";
		newDiv.appendChild(nextCat);
		
		$(this.contenerId).appendChild(newDiv);
		
		Event.observe("radioPlayerLastCat",			"click",	radioPlayerGetLastCat);
		Event.observe("radioPlayerLastRadio",		"click",	radioPlayerGetLastRadio);
		Event.observe("radioPlayerCatSelector",		"change",	radioPlayerGetCurrentCat);
		Event.observe("radioPlayerRadioSelector",	"change",	radioPlayerGetCurrentRadio);
		Event.observe("radioPlayerNextRadio",		"click",	radioPlayerGetNextRadio);
		Event.observe("radioPlayerNextCat",			"click",	radioPlayerGetNextCat);
		
		this.updateRadioList(this.current.cat);
		this.getSelected();
	},
	
	updateRadioList: function(cat)
	{
		$('radioPlayerRadioSelector').options.length = 0;
		var o = new Option("---------------------------------","#");
		o.id = "radioPlayerRadioSelectorOpt#";
		$('radioPlayerRadioSelector').options[$('radioPlayerRadioSelector').options.length] = o;
		cat = this.getCatById(cat);
		
		if(cat)
		{
			var i = -1;
			var radio;
			
			while(false != (radio = cat.getRadioById(++i)))
			{	
				o = new Option(radio.name,radio.path);
				o.id = "radioPlayerRadioSelectorOpt"+radio.id;
				
				$('radioPlayerRadioSelector').options[$('radioPlayerRadioSelector').options.length] = o;
			}
		}
	},
	
	getHelpPage: function(url)
	{ 
		var hauteur = 550;
		var largeur = 550;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		var helpMsgPopup = window.open(url,"helpMsgPopup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no");
		
		if(helpMsgPopup.focus)
			helpMsgPopup.focus();
				else if(helpMsgPopup.window.focus)
					helpMsgPopup.window.focus();
	},
	
	getCreditsPage: function(url)
	{ 
		var hauteur = 250;
		var largeur = 500;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		var helpMsgPopup = window.open(url,"creditsMsgPopup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no");
		
		if(helpMsgPopup.focus)
			helpMsgPopup.focus();
				else if(helpMsgPopup.window.focus)
					helpMsgPopup.window.focus();
	},
	
	getAddPage: function(url)
	{ 
		var hauteur = 290;
		var largeur = 550;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		var helpMsgPopup = window.open(url,"addPopup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no");
		
		if(helpMsgPopup.focus)
			helpMsgPopup.focus();
				else if(helpMsgPopup.window.focus)
					helpMsgPopup.window.focus();
	},
	
	getAdminPage: function(url)
	{ 
		var hauteur = 500;
		var largeur = 700;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		var helpMsgPopup = window.open(url,"adminPopup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
		
		if(helpMsgPopup.focus)
			helpMsgPopup.focus();
				else if(helpMsgPopup.window.focus)
					helpMsgPopup.window.focus();
	}
};

function radioPlayerGetLastRadio()		{ radioPlayer.lastRadio(); }
function radioPlayerGetNextRadio()		{ radioPlayer.nextRadio(); }
function radioPlayerGetLastCat()		{ radioPlayer.lastCat(); }
function radioPlayerGetNextCat()		{ radioPlayer.nextCat(); }
function radioPlayerGetCurrentCat()		{ radioPlayer.updateRadioList($F("radioPlayerCatSelector")); }
function radioPlayerGetCurrentRadio()	{ radioPlayer.change($F("radioPlayerRadioSelector")); }

