/************************************************/
/* Bouncy Radio Center - Javascript				*/
/* -------------------------------------------- */
/* radio.ajax.js -  AJAX Functions			 	*/
/* (c) BouncyServers.co.uk 2010					*/
/* -------------------------------------------- */
/* Author: Anthony Kinson						*/
/************************************************/
var _radio = window.IPBoard;

_radio.prototype.bouncyradiocenter = {

//-------------
// getHistory |
//----------------------------------------------
// fetchs the song history, count set by server
//----------------------------------------------
getHistory: function(e)
{
	Event.stop(e);
	var url = ipb.vars['base_url'] + "app=radio&module=ajax&section=coreAjax&get=history&md5check=" + ipb.vars['secure_hash'];
	new ipb.Popup( 'SongHistory', 
				   {
				   		type: 'pane',
						modal: true,
						w: '600px',
						h: '450px',
						ajaxURL: url,
						hideAtStart: false,
						close: 'a[rel="close"]'
					}
				  );							
},
//--------------
// getListeners |
//---------------------------------------
// Changes the status of the emails flag
//---------------------------------------
getListeners: function(e)
{
	Event.stop(e);
	var url = ipb.vars['base_url'] + "app=radio&module=ajax&section=coreAjax&get=listeners&md5check=" + ipb.vars['secure_hash'];
	new ipb.Popup( 'ListenerInfo', 
				   {
				   		type: 'pane',
						modal: true,
						w: '600px',
						h: '450px',
						ajaxURL: url,
						hideAtStart: false,
						close: 'a[rel="close"]'
					}
				  );							
},
//-------------------
// getListenersChart |
//--------------------------------
// Shows bar chart of radio usage
//--------------------------------
getListenersChart: function(e)
{
	Event.stop(e);
	new ipb.Popup( 'ListenerInfo', 
					{
						type: 'pane',
						modal: true,
						w: '450px',
						h: '450px',
						initial: $('BRC__LCHART_CONTAINER').innerHTML,
						hideAtStart: false,
						close: 'a[rel="close"]'
					}
				);						
},
//--------------
// getHitsChart |
//--------------------------------
// Shows pie chart of radio usage
//--------------------------------
getHitsChart: function(e)
{
	Event.stop(e);
	new ipb.Popup( 'HitsInfo', 
					{
						type: 'pane',
						modal: true,
						w: '450px',
						h: '450px',
						initial: $('BRC__HCHART_CONTAINER').innerHTML,
						hideAtStart: false,
						close: 'a[rel="close"]'
					}
				);						
},
//------------------
// StatsUpdatePanel |
//------------------------------------
// updates a specific statistic inline
//------------------------------------
statsUpdatePanel: function(e, id)
{
	Event.stop(e);
	var container = "BRC__" + id;
	var url = ipb.vars['base_url'] + "app=radio&module=ajax&section=coreAjax&get=" + id + "&md5check=" + ipb.vars['secure_hash'];
	new Ajax.PeriodicalUpdater(
		$(container),
		url,
		{
			method: 'get',
			evalScripts: true,
			frequency: 30,
			decay: 2
		}
		);
		new Effect.Pulsate( $( container ), { pulses: 3 } );				
},
//------------------
// StatsUpdateBar |
//------------------------------------
// updates a specific statistic inline
//------------------------------------
statsUpdateBar: function(e, id)
{
	Event.stop(e);
	var container = "GBAR__" + id;
	var url = ipb.vars['base_url'] + "app=radio&module=ajax&section=coreAjax&get=" + id + "&md5check=" + ipb.vars['secure_hash'];
	new Ajax.PeriodicalUpdater(
		$(container),
		url,
		{
			method: 'get',
			evalScripts: true,
			frequency: 30,
			decay: 2
		}
		);
		new Effect.Pulsate( $( container ), { pulses: 3 } );				
},
//--------------------
// StatsUpdateSidebar |
//------------------------------------
// updates a specific statistic inline
//------------------------------------
statsUpdateSidebar: function(e, id)
{
	Event.stop(e);
	var container = "SIDEBAR__" + id;
	var url = ipb.vars['base_url'] + "app=radio&module=ajax&section=coreAjax&get=" + id + "&md5check=" + ipb.vars['secure_hash'];
	new Ajax.PeriodicalUpdater(
		$(container),
		url,
		{
			method: 'get',
			evalScripts: true,
			frequency: 30,
			decay: 2
		}
		);
		new Effect.Pulsate( $( container ), { pulses: 6 } );				
}
}
