/* STANDARD TEMPLATE */
/* Javascript Functions
----------------------------------------------------------------------------- */


	$(document).ready(function() { 

		if (!navigator.userAgent.match('MSIE 8')) {

			// HIDING CUFON TRANSITION
			$('h2, #page h3, #content h4, #page-index #sidebar h4, #page-update #sidebar h4, ul.tabs a, #page-audio.public ul.clips a:visible').css('visibility', 'hidden');	
		
			// Hide Misc Stuff
			$('#page-audio.public ul.clips').css('visibility','hidden');
			$('#page-videos.public ul.clips').css('visibility','hidden');
			
		}

		// Remove links from from public bio page images
		killPhotoLinks();
		
		$('#layout.home #content ul.actions a.browse').css('visibility', 'hidden');

	});



/* BEGIN: LOAD FUNCTION
----------------------------------------------------------------------------- */

	$(window).load(function() {


/* MESSAGE BOARD
----------------------------------------------------------------------------- */

		if (section == "messageboard") {
			
			navigation();
			Cufon.replace('#header h2 a');
			
		}
		

/* SITE-ONLY
----------------------------------------------------------------------------- */

	
		if (section != "messageboard" && section != "checkout" ) {


/* LOCAL FUNCTION CALLS
----------------------------------------------------------------------------- */

			navigation();
			login();
			if (page == "index" || page == "news" || section == "client") readmore();
			killTabs();
			tabs();
			truncate();
			comments();
			paging();
			Cufon.replace('h2');
        	Cufon.replace('#page h3');
          	Cufon.replace('#content h4, #page-index #sidebar h4, #page-update #sidebar h4');
       		Cufon.replace('ul.tabs a', { hover: true });
       		Cufon.replace('#page-audio.public ul.tabs a:visible', { hover: true });
       		Cufon.replace('#page-audio.public ul.clips a:visible', { hover: true });
       		Cufon.replace('#page-videos.public ul.clips a:visible', { hover: true });
			showCufon();
			eventListings();
			newsListings();
			audioListings();
			photoListings();
			videoListings();
			mailingList();
			
		
/* PLUGINS CALLS
----------------------------------------------------------------------------- */


/* Plugin: Clique Actions */
		
		
			try {
			$('input[type=submit]').cliqueActions();
			} catch (error) { alert('Error: Missing Clique Actions Plugin'); }
			
			if (section == "store") {

				
/* Plugin: Clique Forms */
			
		
				try {
				$('.widget-item.search input#query').cliqueForms({ placeholder: "Search Store" });
				$('.widget-item.search input#query').css('visibility', 'visible'); // Experiencing problems chaining this to previous function
				$('#mailing_list_entry_email').cliqueForms({ placeholder: "Enter Your Email Address" });
				$('#mailing_list_entry_mobile').cliqueForms({ placeholder: "Enter Your Mobile Number" });
				} catch (error) { alert('Error: Missing Clique Forms Plugin'); }
			
		
/* Plugin: Clique Item Widget */
			
				
				try {
				$('div.widget-item.display:not(.photos)').cliqueItemWidget({
				
					checkStock: true,
					pressure: true,
					
					previewPhotos: true, // Shows enlarged images when hovering thumbnails
					viewer: true,
					browser: 'thumbnails', // thumbnails / slideshow
					zoom: 'loupe' // loupe / none
					
				});
				$('.widget-item.browse.tooltip').cliqueItemWidget();
				$('.widget-item.filter').cliqueItemWidget();
				} catch (error) { alert('Error: Missing Clique Item Plugin'); }
				
		
/* Plugin: Clique Alert Widget */
			
				
				try {
				$('div.widget-alert.added').cliqueAlertWidget();
				} catch (error) { alert('Error: Missing Clique Item Plugin'); }

				
/* Plugin: Clique Uploader */
			
			
				try {
				$('#review').cliqueUploader();	
				} catch (error) { alert('Error: Missing Clique Uploader Plugin'); }
		
			}

		}


/* END: LOAD FUNCTION
----------------------------------------------------------------------------- */

	});
	

/* FUNCTION: SHOW CUFON
----------------------------------------------------------------------------- */


	function showCufon() {
		
		$('h2, #page h3, #content h4, #page-index #sidebar h4, #page-update #sidebar h4, ul.tabs a, #page-audio.public ul.tabs a, #page-audio.public ul.clips div > a').css('visibility', 'visible');
				
	}
	
	
/* FUNCTION: NAVIGATION DROP DOWN
----------------------------------------------------------------------------- */


	function navigation() {
	
		$('ul#navigation li:has(ul)').hover(function() {
	
			$(this).addClass('hover');
	
		}, function() {
	
			$(this).removeClass('hover');
	
		});
	
	}
	
	
/* FUNCTION: LOGIN
----------------------------------------------------------------------------- */

	function login() {
	
		if (page == "login") {
		
			// START PACKAGE TIER SLIDESHOW
			$('ul.tiers').before('<div id="paging">').cycle({
	
				fade: true,
				speed: 400,
				timeout: 9000,
				pager: '#paging',
				before: function() { if (window.console) console.log(this.src); }
	
			});
	
			// START UPSELL BENEFITS SLIDESHOW
			$('div#benefits ul').cycle({
	
				fade: true,
				speed: 400,
				timeout: 6000
	
			});
	
			// CUSTOM PAGING LINKS
			$('#paging a:nth-child(1)').livequery(function() { $(this).addClass('basic'); });
			$('#paging a:nth-child(1)').livequery(function() { $(this).text('Rob Thomas Fan Club'); });
			$('#paging a:nth-child(2)').livequery(function() { $(this).addClass('basic-discounted'); });
			$('#paging a:nth-child(2)').livequery(function() { $(this).text('Rob Thomas Fan Club Discounted'); });
			$('#paging a:nth-child(3)').livequery(function() { $(this).addClass('combo'); });
			$('#paging a:nth-child(3)').livequery(function() { $(this).text('Combo Rob Thomas + MB20 Fan Clubs'); });
			
		}
		
	}


/* FUNCTION: MOVE "READ MORE" LINK
----------------------------------------------------------------------------- */ 


	function readmore() {

		$('div.widget-editorial.browse ul.leads > li').each(function() {

			var link = $(this).find('a.display').attr('href');
			$(this).find('ul.actions').remove();

			if ( $(this).find('div.story > *:last-child').hasClass('lead') ) {

				// IF LAST CHILD IS P.LEAD
				$(this).find('div.story p.lead:last').append('&nbsp;&nbsp;<a class="readmore" href="' + link + '">Read More...</a>');

			} else {

				// IF LAST CHILD IS ANOTHER ELEMENT
				$(this).find('div.story > *:last-child').after('<br /><a class="readmore" href="' + link + '">Read More...</a>');

			}

		});

	}


/* FUNCTION: KILL TABS
----------------------------------------------------------------------------- */ 


	function killTabs() {

		// REMOVE EMPTY JAVASCRIPT TAB AND PANE
		$('div.tabbed').not(".static, .ajax").children('ul.tabs').children('li').each(function() {

			var pane = $(this).children('a').attr('href');

			if ( $(this).parent().parent().find(pane).children('*').length == 0 ) {

				$(this).remove();
				$(this).parent().parent().find(pane).remove();

			}

		});

		// REMOVE TABBED PANEL
		$('div.tabbed').not(".static, .ajax").children('ul.tabs').each(function() {

			if ($(this).children('li').length == 0) {

				$(this).parent().remove();

			}

		});

	}


/* FUNCTION: INITIALIZE TABS
----------------------------------------------------------------------------- */


	function tabs() {

		// FEATURES BOX TABS
		if (page == 'index') {

			$('div#features > ul.tabs').tabs({

				fxSlide: false,
	
				show: function() {

					// UPDATE CUFON COLORS
       				Cufon.replace('ul.tabs a', { hover: true });
       			
					// PHOTOS TAB
					if ($('#photos:visible').length > 0) {

						$('#video div.flash div').empty();
						$('#radio div.flash div').empty();

						photoSlideshow();

						$('div#features div.widget-photo.slideshow div a, a#photos_back, a#photos_next').hover(
		
							function() {

								$('a#photos_back').show();
								$('a#photos_next').show();

							},
							function() {

								$('a#photos_back').hide();
								$('a#photos_next').hide();

							}

						)

					} 

					// RADIO TAB
					else if ($('#radio:visible').length > 0) {

						$('#video div.flash div').empty();

						photoSlideshow();

						var radio_player = $('#radio div.flash div').attr('id');
						eval(radio_player)();

					}

					// VIDEO TAB
					else if ($('#video:visible').length > 0) {

						$('#radio div.flash div').empty();

						photoSlideshow();

						var video_player = $('#video div.flash div').attr('id');
						eval(video_player)();

					}

					else {

					}

				}

			});

		}

		// JAVASCRIPT TABS
		$('div.tabbed').not("#features, .ajax, .static").children('ul.tabs').tabs({

			fxSlide: false,

			click: function() {

			}, load: function() {

				truncate();
					
				// UPDATE CUFON COLORS
       			Cufon.replace('ul.tabs a', { hover: true });
       				
			}, show: function() {

				truncate();
				
				// UPDATE CUFON COLORS
				Cufon.replace('ul.tabs a', { hover: true });

			}


		});

		// AJAX TABS
		$('div.tabbed.ajax > ul.tabs').tabs({

			fxSlide: false,

			click: function() {

				loading('start');
       				
			}, load: function() {

				// UPDATE CUFON COLORS
       			Cufon.replace('ul.tabs a', { hover: true });
       			
				truncate();
				loading('stop');

			}, show: function() {

				// UPDATE CUFON COLORS
       			Cufon.replace('ul.tabs a', { hover: true });
       			
       			truncate();
				loading('stop');

			}

		});

	}


/* FUNCTION: AJAX LOADING INDICATOR
----------------------------------------------------------------------------- */


	function loading(event) {

		if (event == "start") {

			// SHOW LOADING INDICATOR

		} else {

			// HIDE LOADING INDICATOR
		
		}

	}


/* FUNCTION: PAGING FOR TABS
----------------------------------------------------------------------------- */ 


	function paging() {

		// AJAX TABS
		$('div.tabbed.ajax ul.paging a').livequery('click', function(event) {

			loading('start');

			$(this).parents('div.pane').load($(this).attr('href'), function(data) {

				loading('stop');

			});

			return false;

		});

		// JAVASCRIPT TABS
		$('div.tabbed:not(.ajax):not(.static) ul.paging a').each(function() {

			var pane = $(this).parents('div.pane').attr('id'); 
			$(this).attr('href', $(this).attr('href') + '#' + pane); 

		});

	}


/* FUNCTION: TRUNCATE TEXT
----------------------------------------------------------------------------- */


	function truncate() {

		// DESCRIPTIONS OF TITLED BROWSE WIDGETS
		$('div#content div.titled strong').each(function() {

			if ($(this).text().length >= 55) {

				var text = $(this).text().slice(0,55);

				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');

			}

		});

		// FEATURES BOX: PHOTO TITLE
		$('div#features #photos h4').each(function() {

			if ($(this).text().length >= 45) {

				var text = $(this).text().slice(0,45);

				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');

			}

		});

		// MEMBER STATUS: SPLIT GRID
		$('div.grid.split div#content .member dd.status').each(function() {

			if ($(this).text().length >= 50) {

				var text = $(this).text().slice(0,50);

				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');

			}

		});

		// MEMBER STATUS: TWO THIRDS GRID
		$('div.grid.two_thirds div#content .member dd.status').each(function() {

			if ($(this).text().length >= 80) {

				var text = $(this).text().slice(0,80);
				
				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');
				
			}
		
		});

		// MEMBER ALIAS: SPLIT GRID
		$('div.grid.split div#content .member a.alias strong').each(function() {

			if ($(this).text().length >= 15) {

				var text = $(this).text().slice(0,15);

				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');

			}

		});

		// MEMBER ALIAS: TWO THIRDS GRID
		$('div.grid.two_thirds div#content .member a.alias strong').each(function() {

			if ($(this).text().length >= 30) {

				var text = $(this).text().slice(0,30);

				$(this).text(text);
				$(this).append('<var>&nbsp;&hellip;</var>');

			}

		});

	}


/* FUNCTION: COMMENTS
--------------------------------------------------------------------------- */


	function comments() {

		// ADDS CANCEL BUTTON FUNCTIONALITY
		if ($('#comment').parent().siblings('ul.tabs').children().length > 1) {

			$('#comment a.cancel').click(function() {

				$('#comment textarea').val('');
				$('#comment').parent().siblings("ul.tabs").tabsClick(1);
				return false;

			});

		}

		// REMOVES CANCEL BUTTON IF NO COMMENTS EXIST
		else {

			$('#comment a.cancel').remove();

		}

	}
	
	
/* FUNCTION: EVENT LISTINGS
----------------------------------------------------------------------------- */


	function eventListings() {
	
		$('#layout.home #content #tour td:visible').each(function() {
		
			var href = "/upcoming";
			var text = $(this).text();
			$(this).html('<a href="' + href + '">' + text + '</a>');
			
		});
		
		$('#layout.home #content #tour h3').each(function() {
		
			var href = "/upcoming";
			var text = $(this).text();
			$(this).html('<a href="' + href + '">' + text + '</a>');
			Cufon.replace('#layout.home #content #tour h3');

		});
		
		if ($('#layout.home #content #tour > ul.actions a.browse').length > 0) $('#layout.home #content #tour ul.actions a.browse').text('click here for all tour dates').css('visibility', 'visible');

	}
	
	
/* FUNCTION: NEWS LISTINGS
----------------------------------------------------------------------------- */


	function newsListings() {
	
		$('#layout.home #content #news h3').each(function() {
		
			var href = "/news";
			var text = $(this).text();
			$(this).html('<a href="' + href + '">' + text + '</a>');
			Cufon.replace('#layout.home #content #news h3');

		});
		
		if ($('#layout.home #content #news > ul.actions a.browse').length > 0) $('#layout.home #content #news > ul.actions a.browse').text('click here for more news').css('visibility', 'visible');

	}
	
	
/* FUNCTION: PHOTO LISTINGS
----------------------------------------------------------------------------- */


	function photoListings() {
	
	
/* Browse */	
	
	
		$('#page-photos.public ul.photos').each(function() {
		
			$(this).children('li:nth-child(1)').addClass('one');
			$(this).children('li:nth-child(2)').addClass('two');
			$(this).children('li:nth-child(3)').addClass('three');
			$(this).children('li:nth-child(4)').addClass('four');
			$(this).children('li:nth-child(5)').addClass('five');
			$(this).children('li:nth-child(6)').addClass('six');
			$(this).children('li:nth-child(7)').addClass('seven');
			$(this).children('li:nth-child(8)').addClass('eight');
			$(this).children('li:nth-child(9)').addClass('nine');
			$(this).children('li:nth-child(10)').addClass('ten');

			$(this).show();

		});
		
		
/* Display */


		$('#page-photos.public ul.photos a').click(function() {
		
			// Create Enlarged Image
			var image = $(this).children('img').attr('src').replace('thumb.', '');
			$('<div id="viewer"><a href="#close" class="close"><img src="' + image + '" alt="" /></a><a href="#previous" class="prev">Previous</a><a href="#next" class="next">Next</a></div>').appendTo('body').hide().fadeIn();
		
			// Hide Navigation Buttons
			var currentImage = $('a.close').children('img').attr('src').split('/').pop();
			var $current = $('ul.photos').find('img[src$="' + currentImage + '"]').parent().parent();
			if ($current.next().length == 0) $('#viewer a.next').hide();
			if ($current.prev().length == 0) $('#viewer a.prev').hide();

			// Close Enlarged Image
			$('#viewer, #viewer a.close').click(function() { $('#viewer').fadeOut('fast', function() { $(this).remove(); }); return false; });
			
			// Next
			$('#viewer a.next').click(function() {
			
				// Swap Image
				var currentImage = $(this).siblings('a.close').children('img').attr('src').split('/').pop();
				var $next = $('ul.photos').find('img[src$="' + currentImage + '"]').parent().parent().next();
				var newImage = $next.find('img').attr('src').replace('thumb.','');
				$(this).siblings('a.close').children('img').replaceWith('<img src="' + newImage + '" alt="" />');
				
				// Show/Hide Buttons
				if ($next.next().length == 0) $(this).fadeOut('fast');
				if ($next.prev().length > 0) $('#viewer a.prev').fadeIn('fast');
				
				return false;
			
			});
			
			// Previous
			$('#viewer a.prev').click(function() {
			
				// Swap Image
				var currentImage = $(this).siblings('a.close').children('img').attr('src').split('/').pop();
				var $prev = $('ul.photos').find('img[src$="' + currentImage + '"]').parent().parent().prev();
				var newImage = $prev.find('img').attr('src').replace('thumb.','');
				$(this).siblings('a.close').children('img').replaceWith('<img src="' + newImage + '" alt="" />');
				
				// Show/Hide Buttons
				if ($prev.prev().length == 0) $(this).fadeOut('fast');
				if ($prev.next().length > 0) $('#viewer a.next').fadeIn('fast');

				return false;
			
			});
		
			return false;
		
		});

	}
	

/* FUNCTION: VIDEO PLAYER
----------------------------------------------------------------------------- */


	function videoListings() {
	
		if ($('#page-index.public #video').length > 0) {


/* Home Page */


			$('#page-index.public #video div > a:not(.comments)').each(function() {
			
				var title = $(this).text();
				var link = $(this).attr('href');
				$(this).text('Watch the new video');
				$(this).after('<h3><a href="' + link + '">"' + title + '"</a></h3>');
       			Cufon.replace('#page-index.public #video div h3', { hover: true });

			});
			
	
		} else if ($('#page-videos.public .widget-media.browse.video').length > 0 || $('#page-videotest.public .widget-media.browse.video').length > 0) {
		

/* Videos Page */


			// LINK STRAIGHT TO VIDEO
			if (typeof(topic) != "undefined") {
			
				// GET PLAYLIST AND ENCODE
				var playlist = site_host + '/widget/media/browse?options[items]=50&options[format]=video';
				var playlist = playlist.replace('?','%3F').replace(/\&/g,'%26').replace(/\=/g,'%3D').replace(/\[/g,'%5B').replace(/\]/g,'%5D');
					
				// DEFINE PARAMETERS       	
				var _so = new SWFObject(site_host + "/flash/player.swf", "player", "100%", "100%", "#000000" );
				_so.addParam( "allowScriptAccess", "always" );
				_so.addParam( "allowFullScreen" , "true" );
				_so.addVariable( "playerID", "player" );
				_so.addVariable( "playMode", "single" );
				_so.addVariable( "mediaMode", "video");
				_so.addVariable( "autoPlay", "true" );
				_so.addVariable("playlistXML", playlist);
				_so.addVariable( "clipName", topic );
				_so.write('videoplayer');

				// SET SELECTED INDICATOR
				$('ul.clips > li a[href$=' + topic + ']').addClass('selected');
				Cufon.replace('#page-videos.public ul.clips a:visible', { hover: true });	
				
			} 
			
			// CLICK
			$('ul.clips > li a').click(function() {
			
				if ($(this).hasClass('selected')) {
				
					// REMOVE OLD PLAYER
					$('#player').each(function() { $(this).remove(); });

					// REMOVE SELECTED INDICATOR
					$(this).parent().parent().parent().find('a.selected').removeClass('selected');
       				Cufon.replace('#page-videos.public ul.clips a:visible', { hover: true });

				} else {
				
					// REMOVE OLD PLAYER
					$('#player').each(function() { $(this).remove(); });
			
					// GET PLAYLIST AND ENCODE
					var playlist = site_host + '/widget/media/browse?options[items]=50&options[format]=video';
					var playlist = playlist.replace('?','%3F').replace(/\&/g,'%26').replace(/\=/g,'%3D').replace(/\[/g,'%5B').replace(/\]/g,'%5D');
					var topic = $(this).attr('href').split('/').pop();
					
					// EMBED NEW PLAYER    	
					var _so = new SWFObject(site_host + "/flash/player.swf", "player", "100%", "100%", "#000000" );
					_so.addParam( "allowScriptAccess", "always" );
					_so.addParam( "allowFullScreen" , "true" );
					_so.addVariable( "playerID", "player" );
					_so.addVariable( "playMode", "single" );
					_so.addVariable( "mediaMode", "video");
					_so.addVariable( "autoPlay", "true" );
					_so.addVariable( "playlistXML", playlist );
					_so.addVariable( "clipName", topic );
					_so.write('videoplayer');
					
					// SET SELECTED INDICATOR
					$(this).parent().parent().parent().find('a.selected').removeClass('selected');
					$(this).addClass('selected');
       				Cufon.replace('#page-videos.public ul.clips a:visible', { hover: true });

				}
			
				return false;

			});

			// UNHIDE
			$('#page-videos.public ul.clips').css('visibility','visible');

		}

	}


/* FUNCTION: AUDIO LISTINGS
----------------------------------------------------------------------------- */


	function audioListings() {
	
		if ($('#page-audio.public').length > 0) {
		
		
/* Create Song Lists */

			
			// Create Container
			$('#content').append('<div id="audio" class="tabbed">');
			$('#content #audio').append('<ul class="tabs"><li class="cradlesong"><a href="#cradlesong">cradlesong</a></li><li class="something_to_be"><a href="#something_to_be">something to be</a></li><li class="other_rt_tracks"><a href="#other_rt_tracks">other rt tracks</a></li></ul>');
			$('#content #audio').append('<div id="cradlesong" class="audio hide"><h3>cradlesong</h3><em class="loading">Loading...</em><ul class="clips"></ul></div>');
			$('#content #audio').append('<div id="something_to_be" class="audio hide"><h3>...something to be</h3><em class="loading">Loading...</em><ul class="clips"></ul></div>');
			$('#content #audio').append('<div id="other_rt_tracks" class="audio hide"><h3>other rt tracks</h3><em class="loading">Loading...</em><ul class="clips"></ul></div>');

			// Enable tabs
			$('#content #audio > ul.tabs').tabs();

			// Cufon
			Cufon.replace('#content ul.tabs li a', { hover: true });
			$('#content ul.tabs li a').click(function() {
			
				Cufon.refresh();
				
			});
					
			$('#content #audio > div.audio').each(function() {
			
				// Load Silverback Feed
				var playlist = $(this).attr('id');
				$.get('/playlists/' + playlist + '.xml', function(data) {
			
					// Remove Loading Indicator
					$('#' + playlist).children('em').remove();	
			
					$(data).find('topic').each(function() {
			
						// Grab Data
						var name = $(this).children('name').text();
						var url_name = $(this).children('url_name').text();
						var lyrics = $(this).children('description').text();
	
						// Render Posts
						if (lyrics != "") {
						
							var entry = '<li><div><a href="' + url_name + '" target="_blank">' + name + '</a><em>' + playlist + '</em></div><div class="lyrics"><h4>' + name + '</h4>' + lyrics + '</div></li>';
	
						} else {
						
							var entry = '<li><div><a href="' + url_name + '" target="_blank">' + name + '</a><em>' + playlist + '</em></div></li>';
						
						}
					
						$(entry).appendTo($('#' + playlist).children('ul.clips'));
			
					});

					// Cufon
					Cufon.replace('#' + playlist + ' ul.clips a', { hover: true });
					
					// Actions
					$('#' + playlist + ' ul.clips').find('a').click(audioActions);

					// Unhide
					$('#' + playlist + ' ul.clips').css('visibility', 'visible');
					
				});
				
			});
						
		}
		
	}
			
			
/* FUNCTION: AUDIO LIST ACTIONS
----------------------------------------------------------------------------- */


	function audioActions() {

									
		if ($(this).hasClass('selected')) {
					
			// REMOVE OLD PLAYER
			$('#player').each(function() { $(this).remove(); });
			
			// SET SELECTED INDICATOR
			$(this).parent().parent().parent().find('a.selected').removeClass('selected');
			Cufon.replace('#' + playlist + ' ul.clips a:visible', { hover: true });

		} else {
				
			// REMOVE OLD PLAYER
			$('#player').each(function() { $(this).remove(); });
			if ($('#info').length > 0) $('#info').remove();

			// GET PLAYLIST AND TOPIC
			var playlist = site_host + '/playlists/' + $(this).siblings('em').text() + '.xml';
			var playlist = playlist.replace('?','%3F').replace(/\&/g,'%26').replace(/\=/g,'%3D').replace(/\[/g,'%5B').replace(/\]/g,'%5D');
			var album = $(this).siblings('em').text();
			var topic = $(this).attr('href').split('/').pop();
			var title = $(this).text();
			
			// EMBED NEW PLAYER    	
			var _so = new SWFObject(site_host + "/flash/player.swf", "player", "100%", "100%", "#000000" );
			_so.addParam( "allowScriptAccess", "always" );
			_so.addParam( "allowFullScreen" , "true" );
			_so.addVariable( "playerID", "player" );
			_so.addVariable( "playMode", "single" );
			_so.addVariable( "mediaMode", "audio");
			_so.addVariable( "autoPlay", "true" );
			_so.addVariable( "playlistXML", playlist );
			_so.addVariable( "clipName", topic );
			_so.write('audioplayer');				
	
			// SET SELECTED INDICATOR
			$('ul.clips').find('a.selected').removeClass('selected');
			$(this).addClass('selected');
			Cufon.replace('#page-audio.public ul.clips a:visible', { hover: true });
			
			// SHOW LYRICS
			if ($(this).parent().siblings('div.lyrics').length > 0) {
			
				$('#page').addClass('blank');
				var title = $(this).text();
				
				// Create Container
				$('#page').append('<div id="info"><div id="artwork"></div></div>');

				// Embed Flash
				var so = new SWFObject(asset_host + '/flash/album-' + album + '.swf', 'cover', '100%', '100%', '9', '#000000');
				so.write('artwork');
				
				// Show lyrics
				$(this).parent().siblings('.lyrics').clone().appendTo('div#info');
				
			} else {
			
				$('#page').removeClass('blank');
			
			}
			
		}
	
		return false;

	}

	
/* FUNCTION: KILL PHOTO LINKS
----------------------------------------------------------------------------- */


	function killPhotoLinks() {
	
		if ($('#page-biography.public').length > 0) {
		
			$('ul.photos a').click(function() {
			
				return false;
			
			});
		
		}
		
		if ($('#page-upcoming.public').length > 0 || $('#page-past.public').length > 0) {
		
			$('ul.photos a').click(function() {
			
				return false;
			
			});
		
		}
	
	}
	
	
/* FUNCTION: MAILING LIST
----------------------------------------------------------------------------- */


	function mailingList() {
	
		$('#navigation .mailinglist a').click(function() {
		
			var href = $(this).attr('href');
			window.open(href, 'mailinglist', "location=0,status=0,menubar=0,resizable=1,width=360,height=550");
			return false;
		
		});
	
	}


