(function(){
	if (document.location.hostname != "www.bbc.co.uk") {
		alert('Not the bbc domain. Aborting.');
		return;
	}
	
	var controls;
	try {
		controls = document.getElementsByTagName('frame')
		[2].contentDocument.getElementsByTagName('frame')
		[0].contentDocument.getElementsByTagName('embed');
	} catch(e){}
	
	if (controls == null || controls.length != 5){
		alert('Unexpected page layout. Aborting.');
		return;
	}

	var c;
	for (var i = controls.length - 1; i >= 0; i--){
		c = controls[i];
		
		if(c.getAttribute('type') != 'audio/x-pn-realaudio-plugin')
			continue; // Ignore non-realplayer embed elements
			
		buttons = c.getAttribute('controls');
		
		if (buttons == 'PlayButton') {
			c.removeAttribute('width');
			c.setAttribute('controls','ControlPanel');
			var p = c.parentNode;
			p.removeChild(c);
			p.appendChild(c);
		} else if (	buttons == 'StopButton' || 
					buttons == 'VolumeSlider' ||
					buttons == 'FFCtrl') {
			c.parentNode.removeChild(c);
		}
	};

})();