
function PSInformerOnairInline (container)
{
	this.__construct = function (container)
	{
		this.container = (typeof container == 'object') ? container : document.getElementById(container);
		if (navigator.userAgent.search(/MSIE/) == -1)
		{
			this.Deploy();
		}
	}
	
	this.BuildGUI = function ()
	{
		this.container.className = 'puresound_onair';
		
		this.gui = {};
		
		// title
		this.gui.title_a = document.createElement('a');
		this.gui.title_a.setAttribute('href','http://puresound.fm/');
		this.gui.title_a.setAttribute('target','_blank');
		this.gui.title_a.className = 'title';
		this.gui.title_a.appendChild(document.createTextNode(''));
		this.container.appendChild(this.gui.title_a);
		
		// tune in
		this.gui.tune_in = document.createElement('span');
		this.gui.tune_in.className = 'tune_in';
		this.gui.tune_in.appendChild(document.createTextNode('tune in:'));
		this.container.appendChild(this.gui.tune_in);
		
		// mp3/256
		this.gui.mp3_a = document.createElement('a');
		this.gui.mp3_a.setAttribute('href','http://puresound.fm/listen_mp3.m3u');
		//this.gui.mp3_a.setAttribute('target','_blank');
		this.gui.mp3_a.className = 'playlist_link playlist_mp3';
		this.gui.mp3_a.appendChild(document.createTextNode('mp3/256'));
		this.container.appendChild(this.gui.mp3_a);
		
		// mp4/128
		this.gui.mp4_a = document.createElement('a');
		this.gui.mp4_a.setAttribute('href','http://puresound.fm/listen_aacplus.pls');
		//this.gui.mp4_a.setAttribute('target','_blank');
		this.gui.mp4_a.className = 'playlist_link playlist_mp4';
		this.gui.mp4_a.appendChild(document.createTextNode('mp4/128'));
		this.container.appendChild(this.gui.mp4_a);
	}
	
	this.Deploy = function ()
	{
		this.InitAPI();
		this.LoadPlaylist();
		this.BuildGUI();
	}
	
	this.InitAPI = function ()
	{
		if (typeof window.puresound == 'undefined')
		{
			window.puresound = {};
			window.puresound.objects = [];
		}
		this.id = window.puresound.objects.push(this)-1;
	}
	
	this.LoadPlaylist = function ()
	{
		var s = document.createElement('script');
		s.callback = new Function('','window.puresound.objects['+this.id+'].Update();');
		s.src = 'http://static.puresound.fm/resources/js/export/playlist.js?rand='+Math.round((new Date()).getTime()/1000/(60*10));
		if (s.addEventListener)
		{
			s.addEventListener('load',function () { this.callback(); },false);
		}
		else if (s.attachEvent)
		{
			s.attachEvent('onreadystatechange',function () { if (this.readyState == 'complete') this.callback(); });
		}
		document.body.appendChild(s);
	}
	
	this.Update = function ()
	{
		var now = window.puresound.playlist[0];
		this.gui.title_a.innerHTML = now.artist+' - '+now.title.replace(/\s*\((replay|\d+\-\d+\-\d+)\)\s*$/i,'');
	}
	
	this.__construct(container);
}
