function joshwurlencode(str) {
	return str.replace(/\?/g,'%3F').replace(/\&/g, '%26');
	return str;
}


$(document).ready(function() {
	var topHref = top.location.href.replace(/#.+/,'').replace(/^https?:\/\/[^\/]+/,'');
	var paneHref = window.location.href.replace(/#.+/,'').replace(/^https?:\/\/[^\/]+/,'');

//	eLog("Top: " + topHref + ", pane: " + paneHref);

	if( topHref == paneHref &&
		!topHref.match(/\/b\//) ) {
		// if we're not in a frameset, get one...
		window.location.replace('/b/#' + joshwurlencode(topHref));
	}

	// If we've already killed the player, don't show the pause button
	if( top.framePlayer && top.framePlayer.document.body.innerHTML == '' ) { return; }

	$('<img id="bgmIcon" src="/common/images/pause.png" alt="Stop Music">')
		.css('position','absolute')
		.css('right', '30px')
		.css('top', '30px')
		.css('cursor', 'pointer')
		.click(function() {
			top.framePlayer.document.body.innerHTML = '';
			$(this).fadeOut('slow');
		})
		.appendTo('body');
});


