// JavaScript Document
	

	
	var Viewer = Class.create (
	{
		initialize: function (obj)
		{
						
			this.obj = obj;
			
			this.views = new Array ();
					
			this._images_index = 0;
			this._images = new Array();
			
			this._init();
		},
				
		_init: function()
		{
			_doc._init('links');
			_doc._init('social buttons');
			
			
			//this.obj.select ('.js_quick_love').each ( function (_n) { this._quick_love (_n) } );
			
			
			this.obj.select('.options .option a').each
			(
				function (n)
				{
					n.observe ('click', this._switch_objects.bind(this));
				},
				this
			);
			
			// images
			
			this._images_index = 0;
			
			if (this._images = this.obj.select('.images .image'))
			{
				if (this._images.length > 1) 
				{
					this._images.each
					(
						function (n)
						{
							n.observe ('click', this._switch_images.bind(this));
						},
						this
					);
				}
			}
			
			// videos
			
			this.obj.select('.videos .list .item .video_link').each
			(
				function (n)
				{
					n.observe ('click', this._switch_videos.bind(this));
				},
				this
			);
			
			// links
			
			
			this.obj.select('.links .link_object .title_wrap a').each
			(
				function (n)
				{
					n.observe ('click', 
						function (_e)
						{
							_e.stop();
							_o = _e.element();
							_class_tar = _o.id;
							_tar = $('link_object_view_' + _class_tar.gsub(/\D/, ''));
							_tar.up('.links').select ('.link_object_view').invoke ('hide');
							_tar.show();
						}
					);
				},
				this
			);
		},
		
		
		_increment_object_count: function (_tar, _value)
		{
			_value = _append_zero (_value);
			
			if (_tar.down('.object_counter')) { _tar.down('.object_counter').update(_value) }
		},
		
		_switch_images: function(_e)
		{	
			new Effect.BlindUp(this._images[this._images_index], { duration: 0.3, queue: { position: 'end', scope: 'up_image_slide', limit: 1 } });
			
			
			this._images_index++;
			
			if (this._images_index == this._images.length){
				this._images_index = 0;
			}
			
			new Effect.SlideDown(this._images[this._images_index], { duration: 0.5, queue: { position: 'end', scope: 'down_image_slide', limit: 1 } });
			
			this._increment_object_count(_e.element().up('.js_broadcast_stream_preview').down('.options .images_option'), this._images_index + 1);
		},
		
		_switch_videos: function (_e)
		{
			_e.stop();
			
			_tpl_youtube_string = '<iframe width="#{width}" height="#{height}" src="http://www.youtube.com/embed/#{id}?autohide=1&controls=1" frameborder="0" allowfullscreen></iframe>';
			_tpl_vimeo_string = '<iframe width="#{width}" height="#{height}"  src="http://player.vimeo.com/video/#{id}?title=0&amp;byline=0&amp;portrait=0" frameborder="0"></iframe>';
			
			var _vimeo_tpl = new Template(_tpl_vimeo_string);
			var _youtube_tpl = new Template(_tpl_youtube_string);
			
			_video_link = (_e.element().tagName == 'A') ? _e.element() : _e.element().up('a');
			_video_target = this.obj.down('.videos .video');
					
			_width = _video_target.down('iframe').width;

			switch(_width)
			{
				case '540':
						_height = _video_link.hasClassName('vimeo_video') ? 332 : 334;
					break;
				case '300':
						_height = 186;
					break;
				default:
						_height = (_width*6)/9;
					break;
			}
			
		
			_video_id = _video_link.hash.sub(/#/, '');
			
			_video_html = null;
			
			_tpl_show = { 
				id: _video_id,
				width: _width,
				height: _height
			};
			
			if (_video_link.hasClassName('youtube_video')){
				_video_html = _youtube_tpl.evaluate(_tpl_show);	
				
			} else if (_video_link.hasClassName('vimeo_video'))	{
				_video_html = _vimeo_tpl.evaluate(_tpl_show);
				
			} else {
				alert ('unsupport video type, not yet anyway');
			}
			
			_video_target.update(_video_html);	
		},
		
		_switch_objects: function (_e)
		{
			_e.stop();
			
			_n = (_e.element().down('img')) ? _e.element() : _e.element().up('a');
			// selected
			_n.up('.options').select('.option').each ( function (_no) { _no.removeClassName('selected');   } ); //
			_n.up('.option').addClassName('selected');
			
			var _tar_object_class_name = _n.hash.sub(/#/, '');
			var _tar_object = '.' + _tar_object_class_name;
			
			this.obj.select('.block_objects .block').each 
			(
				function(_o) 
				{ 
					if (_o.visible())
					{
						if (_o.hasClassName(_tar_object_class_name) == false) { _o.hide(); }
					}
				}
			);
			
			if (_tar_object)
			{
				if (this.obj.down(_tar_object).visible() == false ) {
					new Effect.Appear(this.obj.down(_tar_object), { duration: 1, queue: { position: 'end', scope: 'down_block_slide', limit: 1 } });
				}
			}
		},
		
		_quick_love: function (_e)
		{
			//alert (_n);
			_n = _e.element();
			//_n.removeClassName ('love_icon');
			_img = '<img src="/public/images/icons/spinner.gif" style="display: block; width: 12px; height: 12px; float: right; margin-right: 5px" />';
			
			_n.down('span').update (_img);
			
			
			_ajax = new Ajax.Request
			(
				_n.href + '.json', 
				{
					onSuccess: function (_t) 
					{
						if (_d = _t.responseText.evalJSON (true) ) 
						{
																	
							if ( _d.stream.loving )	{
								
								_total = _append_zero( _d.stream.loving.total );
								_total_update = ( _d.stream.loving.total > 0) ? '.' + _total : '&nbsp;' ;
								
								//_doc.sleep(10);
								
								_n.up(0).down('span').update( _total_update );
							}
						}
					},
				}
				
			);
			
		},
		
		_update: function (_html)
		{
			this.obj.update(_html);	
			this.obj.removeClassName('hide');
			
			this._init ();
							
			this.obj.select ('a.js_quick_love').each 
			(
				function (_n) { _n.observe ('click', function (e) { e.stop(); this._quick_love (e) 	}.bind(this) )	}, this
			)
		},
		
		_wait: function (waiting)
		{if  (waiting){
				this.obj.select('.block').invoke('hide');
				
				if (typeof this.obj.down('.options') != 'undefined'){
					this.obj.down('.options').hide();
				}
							
				this.obj.down('.waiting').show();
			} else {
				this.obj.down('.note').show();//('hide');
				this.obj.down('.waiting').hide();
				//this.obj.update('&nbsp;');
			}
		}
	});
	
	var Tweet = Class.create (
	{
		initialize: function (obj, preview)
		{
			this.obj = obj;
			this.preview = preview;
			this.fetch = false;
			
			this.url = this.obj.down('a.js_broadcast_stream_tweet').href + '/panel.file';

			// initialise links					
				_doc._init('links');
	
			this._init_actions();
		},
		
		_init_actions: function ()
		{
			
			this.obj.down('a.js_broadcast_stream_tweet').observe
			(
				'click', this._pull.bind(this)
			)
		},
		
		_pull: function (_e)
		{	
			_e.stop();	
				// set as seleted — remove the rest;
			// js_broadcast_stream_row
				this.obj.up('.js_broadcast_stream_timeline').select('.js_broadcast_stream_row').each ( function (r) { r.removeClassName ('selected') } );
				this.obj.addClassName('selected');
					
			this.preview._wait (true);
					
			if (this.fetch == false) 
			{			
				this.fetch = true;
				new Ajax.Request 
				(
					this.url, 
					{
						method: 'get',
						onSuccess: this._do.bind(this),
						onFailure: this._failed.bind(this),
						onComplete: this._done.bind(this)
					}
				);
			} else { 
				alert ('hold there partner, we still getting this ish');	
			}
		},
		
		_do: function (_data)
		{
			this.preview._update(_data.responseText);
		},
		
		_failed: function()
		{
			alert ('failed to get ish, sowwy.');
		},
		
		_done: function (_data)
		{			
			this.fetch = false;
			this.preview._wait (false);
		}
	});
	
	var Stream = Class.create (
	{
		initialize: function (obj, preview)
		{
			this.obj = obj;
			
			this.rows_total = 0;
			
			this.tweets = Array();
			
			this.preview = preview;
			
			this.timeline = this.obj.down('.js_broadcast_stream_timeline');
				this.rows =	this.timeline.select('.js_broadcast_stream_row');
				this.timeline.makePositioned();
				
			this.timeline_wrappper = this.obj.down('.tweet_list_wrapper');
				this.timeline_wrappper.makePositioned();
				
				this.timeline_wrappper_top = this.timeline_wrappper.positionedOffset().top;
			
			this.pagenate =	this.obj.down('.js_broadcast_stream_pagenate');
				this.pagenate.makePositioned();
			
			
			this.pulling = false; 
			
				
			this._init_scrolling ();
			this._init_tweets();
			
		},
		
		_scroll : function (_e)
		{	
			_e.stop();
			
			if (this.pulling == false)
			{		
				_dir = ( _e.element().up('li').hasClassName('down') ) ? -1 : 1; // up ? down
				
				_v = this.obj.down('.listing_wrap').getHeight();
				
				_h = this.timeline_wrappper.getHeight();					// + this.pagenate.getHeight() + 10;		// timeline height + the pagenation thing;
				_d = -1 * ( _h - _v ); 													// maximum height/distance to move;
				_ms = 75;																// speed of movement;
				_s = _dir * _ms;														// direction of movement;
				
				//alert(this.timeline_wrappper.getStyle('top') + ' <> ' + this.timeline_wrappper.positionedOffset().top);
				
				_cp =  this.timeline_wrappper.positionedOffset().top - this.timeline_wrappper_top;
				/*
						_cp = eval( this.timeline_wrappper.getStyle('top').sub('px', '') );
						alert (_cp2 + ' <> ' + _cp);
				*/
				_np = _cp + _s;
				
				
				if (_dir > 0) _t =  (_cp + _s > 0 ) ? 0 : 1;
				if (_dir < 0) {
					_t =  ( _d + _s < _np  ) ? 1 : 0 ;
				}
					
				if (_t){
					_ef = new Effect.Move(this.obj.down('.tweet_list_wrapper'), { x: 0, y: _s, mode: 'relative', duration: 0.15, queue: { position: 'end', scope: 'scroll_slide', limit: 1 } } );
				}
								
				if ( _np <= _d) if (this.pulling == false) { this._pull() };		
			}
		},
		
		_init_scrolling: function ()
		{
			this._scroll_moved = 0;
			
			this.obj.select ('a.js_broadcast_stream_traverse_point').each
			(
				function(_n, _i)
				{	
					_n.observe ('click', this._scroll.bind(this)); // dblclick
					// _n.observe ('dblclick', this._scroll_top_bottom.bind(this));
				},
				this
			);
		},
		
		_init_tweets: function ()
		{
						
			this.rows =	this.timeline.select('.js_broadcast_stream_row');
			
			this.rows.each
			(
				function(_n, i)
				{	
					if ( i >= this.rows_total) {
						this.tweets[i] = new Tweet(_n, this.preview );
						this.rows_total++;
					}
				},
				this			
			);
			
		},
		
		_pull: function ()
		{
			if ( this.pagenate.hasClassName ('end_of_file') ) { this.pagenate.hide(); this.pulling = false; return }
						
			if (this.pulling == false)
			{
				_url = this.pagenate.down('a').href + '.json';
				this.pagenate.down('a').addClassName ('spin');
				this.pagenate.down('a').update('&hellip;');
				
				this.pulling = true; 
				
				new Ajax.Request 
				(
					_url, 
					{
						method: 'get',
						onSuccess: this._do.bind(this),
						onFailure: this._failed.bind(this),
						onComplete: this._done.bind(this)
					}
				)
					
			} else {
				alert ('Still getting stuff');	
			}
		},
		
		_failed: function()
		{
			alert ('failed to get ish, sowwy.');
		},
		
		_done: function (_data)
		{			
			this.pagenate.down('.js_broadcast_stream_timeline_pagenate_point').removeClassName('spin');
			this.pagenate.down('.js_broadcast_stream_timeline_pagenate_point').update('MORE');
			
			this._init_tweets();
			
			this.pulling = false; 
		},
		
		_do: function (_transport)
		{
			_d = _transport.responseText.evalJSON(true)
			
			_tweet_tpl  = '<li class="js_broadcast_stream_row tweet clearfix">';
			_tweet_tpl += '		<dl class="persona clearfix">';
			_tweet_tpl += '			<dt class="avatar">';
			_tweet_tpl += '				<a href="http://twitter.com/#{from_user}"><img width="28px" height="28px" src="#{profile_image_url}" alt="#{from_user}" /></a>';
			_tweet_tpl += '			</dt>';
			_tweet_tpl += '			<dd class="alias">';
			_tweet_tpl += '				<a href="http://twitter.com/#{from_user}" class="link">#{from_user}</a>';
			_tweet_tpl += '				<a class="date" href="http://twitter.com/#{from_user}/status/#{id}" title="#{created_at}">#{created_human_time}</a>';
			_tweet_tpl += '			</dd>';
			_tweet_tpl += '		</dl>';
			_tweet_tpl += '		<div class="text">#{text}</div>';
			_tweet_tpl += '		<a class="js_broadcast_stream_tweet" href="/broadcast/stream/#{id}"><span class="point">EXPLORE</span></a>';
			_tweet_tpl += '	</li>';
						 
			_timeline_tweet_template = new Template(_tweet_tpl);
			_timeline_html = '';
			
			
			
			if (_d.tweets)
			{
				_d.tweets.each( function(t, i)
				{
					_tpl_show = {
						id: t.tweet_id,
						from_user: t.tweet.from_user,
						profile_image_url: t.tweet.profile_image_url,
						created_at: t.tweet.created_at,
						created_human_time: t.created_human_time,
						text: t.tweet.text
					};
					
					_item_html = _timeline_tweet_template.evaluate(_tpl_show);
					_timeline_html += _item_html;
					// http://bobobobo.wordpress.com/2008/05/22/the-stupidly-brief/ (howto learnt from here)
					
				});
				
					_page_number_html = '<li class="page_indicator clearfix"><span>{ '+ _append_zero ( _d.pagination.page ) + ' }</span></li>';
				_timeline_html = _page_number_html + _timeline_html;
				
				this.timeline.insert( {'bottom': _timeline_html });
			}
			
			if ( _d.pagination.page < _d.pagination.pages ){
				_next_page = eval( _d.pagination.page )  + 1;
				this.pagenate.down('a').href = '/broadcast/stream/page/' + _next_page;
			} else {
				this.pagenate.addClassName('end_of_file');
					
				_page_number_html = '<li class="page_indicator clearfix"><span>{ eof }</span></li>';
				this.timeline.insert( {'bottom': _page_number_html });
			}
		}
	});
			
	var BARS = Class.create (
	{		
		initialize: function (obj, preview)
		{
			this.obj = obj;
			this.preview = preview;
			this.player = null;
			this.data = null;
						
			this.play_panel = this.obj.down ('.js_broadcast_bar_view');
			this.play_list = this.obj.down ('.bars_list');
			
			this.play_list_index = 0;
			
			this.data_init == false;

			new Ajax.Request ( '/broadcast/bars.json', 
			{
				method: 'get',
				onSuccess: function (_t) 
				{ 
					this.data = _t.responseText.evalJSON (true); this.data_init = true 
					this.obj.select ('.bars_list .item .bar_link').each ( function (_b) { this.select_bar (_b) }, this );		
				}.bind(this),
			});
			
			// pagination		
				this.obj.select ('.bars_list .pagination .point a').each ( function (_a) { _a.observe ('click', function (_e) { this._scroll (_e) }.bind(this) )	}, this )			
			

		},
		
		_scroll: function (_e) 
		{ 
			_e.stop();
			
			_o = (_e.element().up('a')) ? _e.element().up('a') : _e.element();
			
			_dir = ( _o.up('li').hasClassName ('prev')) ? 1 : -1;
			
			
			
			_do_effect = false;
			
			if (_dir < 0 ) {
				if ( (this.play_list_index + 4) <= this.play_list.select ('.archive .item').length ) {  this.play_list_index +=2; _do_effect = true; }
			} else {
				if (this.play_list_index - 2 >= 0) { this.play_list_index -=2;  _do_effect = true; }
			}
			
			if (_do_effect) { this.play_list.select ('.archive .item').invoke('hide'); }
			
			//$('DBGx').update(this.play_list_index);
			
			for (_j = this.play_list_index; _j < this.play_list_index + 2; _j++) // show
			{
				if (this.play_list.select ('.archive .item')[_j]) 
				{
					_k = this.play_list.select ('.archive .item')[_j];
					if (_do_effect) {
						if (_dir < 0) {
							new Effect.BlindDown(_k, { duration: 0.2, queue: { position: 'start', scope: 'bars_play_list_', limit: 2 } });
						} else {
							new Effect.BlindDown(_k, { duration: 0.2, queue: { position: 'end', scope: 'bars_play_list_', limit: 2 } });
						}
					}
				}
			}
		},
		
		select_bar : function (_b)
		{		
			_b.observe 
			(
				'click', 
				function (_e) 
				{ 
					_e.stop();
					
					_index = _b.href.sub(/\D+/, '');
						// window.location = _b.href.replace(/bars\//, 'bars#');
					if ( this.data_init ) 
					{
						
						_title = this.data.bars.list[_index].title;
						
						this.play_panel.down ('.track .title').update (this.data.bars.list[_index].title.unescapeHTML());
						this.play_panel.down ('.track .date').update (this.data.bars.list[_index].human_time);
						this.play_panel.down ('.track .date').setStyle ({ textTransform: 'uppercase'})
						
						if (this.data.bars.list[_index].image) {
							this.play_panel.down ('.bar .bar_thumbnail').src = this.data.bars.list[_index].image;
						} else {
							this.play_panel.down ('.bar .bar_thumbnail').src = '/views/boom/images/ui/x/140.png';//this.data.bars.list[_index].image;
						}
						
						if (this.player) {
							this.player.api_load (this.data.bars.list[_index].url);
								
						} else {
							// alert ('player still loading');	
						}
						
						// social icons;
						_bar_url = 'http://' + window.location.host + '/broadcast/bars/' + this.data.bars.list[_index].bar_id;
						twitter_base_url = 'http://twitter.com/share?url=' + _bar_url;
							twitter_text = 'text=' + encodeURIComponent(this.data.bars.list[_index].title) + '&via=ttby';
							twitter_share_url = twitter_base_url + '&' + twitter_text;
							
						facecook_share_url = 'http://www.facebook.com/share.php?u=' + _bar_url;

						this.play_panel.down('.track .twitter_social_button_action').href = twitter_share_url;
						this.play_panel.down('.track .facebook_social_button_action').href = facecook_share_url;
					
					} else {
						alert ('sorry, still getting data');	
					}
				}.bind(this)	
			)
		}
		
	});
	
	var TV = Class.create (
	{
		initialize: function (obj, preview)
		{
			this.obj = obj;
			
			this.preview = preview;
			this.data = null;
			
			new Ajax.Request ( '/broadcast/tv.json', 
			{
				method: 'get',
				onSuccess: function (_t) 
				{ 
					this.data = _t.responseText.evalJSON (true); this.data_init = true 
					this.obj.select ('.video_list .item .video_link').each ( function (_v) { this._select_video (_v) }, this );		
				}.bind(this),
			});
		
			this.items = this.obj.select ('.video_list .item');																					// scrolling
			if (this.obj.down ('.archive')) this.obj.down ('.archive').makePositioned();
				this._scroll_moved = 0;
							
			this.obj.select ('.pagination .point a').each ( function (_p) { this.init_scrolling(_p) }, this );
		},
		
		_select_video : function (_v)
		{	
			_v.observe	( 
			'click', function (_e) 
			{
					_e.stop();
					
					//	window.location = _v.href.replace(/tv\//, 'tv#');
					_video_link = _e.element();
					_video_index = _v.href.sub(/\D+/, '');
					
					if (_video_link.up('.item').hasClassName('selected') == false )
					{
						_video_html = ' ';
						
						_video_link.up('.archive').down('.selected').removeClassName('selected');
						_video_link.up('.item').addClassName('selected');
											
						_tpl_show = { 
							width: this.preview.obj.down('.js_broadcast_video_view .video iframe').getWidth(), 
							height: this.preview.obj.down('.js_broadcast_video_view .video iframe').getHeight(), 
							id: this.data.videos.list[_video_index].video_id
						}
										
						if (_video_link.hasClassName('youtube_video')){
							_video_html = _generic_templates['video']['youtube']['tpl'].evaluate(_tpl_show);	
							
						} else if (_video_link.hasClassName('vimeo_video'))	{
							_video_html = _generic_templates['video']['vimeo']['tpl'].evaluate(_tpl_show);
						} else {
							alert ('unsupport video type, not yet anyway');
						}/*	*/
						
					//	alert (_video_html);
						this.preview.obj.down('.js_broadcast_video_view .video').update (_video_html);
						this.preview.obj.down('.js_broadcast_tv_video_label h2').update(this.data.videos.list[_video_index].title);
						this.preview.obj.down('.js_broadcast_tv_video_label span').update(this.data.videos.list[_video_index].human_time);	
						this.preview.obj.down('.js_broadcast_tv_video_label span').setStyle ({ textTransform: 'uppercase'});
						
					// social icons;
					_tv_url = 'http://' + window.location.host + '/broadcast/tv/' + this.data.videos.list[_video_index].tv_id;
						twitter_base_url = 'http://twitter.com/share?url=' + _tv_url ;
							twitter_text = 'text=' + encodeURIComponent(this.data.videos.list[_video_index].title) + '&via=ttby';
							twitter_share_url = twitter_base_url + '&' + twitter_text;
							
						facecook_share_url = 'http://www.facebook.com/share.php?u=' + _tv_url;

						this.preview.obj.down('.js_broadcast_tv_video_label .twitter_social_button_action').href = twitter_share_url;
						this.preview.obj.down('.js_broadcast_tv_video_label .facebook_social_button_action').href = facecook_share_url;
					}
					
				}.bind(this)
			);
		},
				
		_scroll : function (_wraper, _list, _mover, _dir, _s)
		{
			_v = _wraper.getHeight(); 								// viewer height
			_h = _list.getHeight()									// timeline height
			_d = -1 * ( _h - _v ) - 15; 							// maximum height/distance to move;
			_s = (_s) ? _dir * _s :  _dir * 100;
				
			if (_dir < 0 ) // up
			{
				_s = ( _mover + _s <= _d ) ? _d - _mover : _s; 		// check to see if the next move is going to move the bottom from the bottom;
				
			} else {
				if ( _mover == 0 ) {
					_s = 0;	
				} else if ( _mover < 0 ) {
					if ( _s + _mover > 0) _s = Math.abs ( _mover );
				}
			}
			
			
			new Effect.Move(_list, { x: 0, y: _s, mode: 'relative', duration: 0.1, queue: { position: 'end', scope: 'scroll_slide', limit: 1 } });
			_mover += _s;
			
			return _mover;
		},
		
		init_scrolling : function (_p)
		{						
			_p.observe
			(
				'click', 
				function (_e) 
				{
					_e.stop();
					_o = _e.element();
					_dir = ( _o.up('.point').hasClassName('next')) ? -1 : 1;//()
					
					this._scroll_moved = this._scroll(this.obj.down('.video_list'), this.obj.down('.archive'), this._scroll_moved, _dir, 85);
				}.bind (this)
			)
		}
	});
	
	var Broadcast = Class.create (
	{
		initialize : function (obj) 
		{
			this.obj = obj;
			this.ajax_active = false;
			
			if (this.obj.down('.js_broadcast_view'))
			{
				this._viewer = new Viewer(this.obj.down('.js_broadcast_view'));																		// viewer
				
				this._reload();	
				
				this.obj.select('.js_broadcast_panels .point a').each 																				// options
				( 
					function (_o) { 
						_o.observe('click', function (_e) { _e.stop(); this._update (_o) }.bind(this) );
					}, 
					this 
				);							
			}
		},
		
		_reload : function ()
		{
			this._viewer = new Viewer(this.obj.down('.js_broadcast_view'));	
			
			if (this.obj.down('.js_broadcast_stream_main')) { this._stream = new Stream (this.obj.down('.js_broadcast_stream_main'), this._viewer) } 	// twitter-stream
			if (this.obj.down('.js_broadcast_tv_main')) { this._tv = new TV (this.obj.down('.js_broadcast_tv_main'), this._viewer) } 					// tv		
			if (this.obj.down('.js_broadcast_bars_main')) 
			{ 			
				this._bars = new BARS (this.obj.down('.js_broadcast_bars_main'), this._viewer) 
					
				if ( typeof soundcloud == 'undefined' )
				{
					var script = document.createElement("script");
						script.type = "text/javascript";
						script.src = "/public/js/soundcloud/soundcloud.player.api.js";
						this.obj.appendChild(script);
						jQuery(document).bind('soundcloud:onPlayerReady', function(event, data) {
							this._bars.player = soundcloud.getPlayer('soundCloudPlayer');
						}.bind (this));
				}
				
				
			} 			// bars
		},
		
		_update : function (_o)
		{
			if (_o.up('.point').hasClassName('selected') == false )
			{
				_url = _o.href + '/panel.file';
				
				if (_p = _o.up ('.js_broadcast_panels').down ('.selected') )
				{
					_p.removeClassName('selected');					
				};
				
				_o.up('.point').addClassName('selected');
				
				this.obj.down('.js_broadcast_container').update('<div><span>&nbsp;</span></div>');// ('');
				this.obj.down('.js_broadcast_container').addClassName('js_broadcast_container_spin');
				
				
				
				if (this.ajax_active == false) {			
					
					this.ajax_active = true;
					
					new Ajax.Request 
					(
						_url, 
						{
							method: 'get',
							evalJS: true,
							onSuccess: function (_t) { this._do(_t, _o)	}.bind(this),
							onFailure: function () { alert ('sorry mate, this did not work out as planned')	},
							onComplete: this._done(this)
						}
					);
				} else { 
					alert ('hold there partner, we still getting this ish');	
				}
			}
		},
		
		_do : function (_d, _o)
		{
			//
			_html = _d.responseText;
			if (_o.up('.tv')) {	_html = '<div class="js_broadcast_tv_main broadcast_tv broadcast_tv_smaller clearfix">' + _html + '</div>';	}
			
			this.obj.down ('.js_broadcast_container').update (_html);
			
			this.obj.down('.js_broadcast_container').removeClassName('js_broadcast_container_spin');
			
			this._reload();
			
		},
		
		_done : function ()
		{
			this.ajax_active = false;
		}
			
	});
	

	function _apply_broadcast_actions ()
	{	
	
		// js_broadcast > js_broadcast_stream_main | js_broadcast_view > js_broadcast_stream_tweet
		
		var _broadcast;
		
		$$('.js_broadcast').each 
		(
			function (_n)
			{		
				 _broadcast = new Broadcast(_n);
			}
		);
		
	}
	
	_apply_action('_apply_broadcast_actions');
	
		
