//  podcast div class
//  expects a div containing link
//  link with class "podcast";inside can be text or image 
//  href of that link is the podcast audio file
//  requires ufo.js
//
var podcastPlayer = new  Class({
	Implements: [Options,Events],
	options: {
		width:380,
		height:16,
		auto:"false",
		kiosk:"true",
		pod_element:"a.podcast"// this is the image or link that is clicked to activate player
	},
	pods:[],
	initialize: function(options) {
		this.setOptions(options);
		this.pods = $$(this.options.pod_element);
		this.pods.each( function(pod) {
										 pod.addEvent('click',function(event) { event.stop();});
										 pod.addEvent('click',this.openPlayer.pass(pod,this));
										 this.ID++;// increment the id's
										 }, this );
	},
	openPlayer: function(pod,event) {
		pod.removeEvent('click',this.openPlayer);
		this.closePlayer();
		var container = pod.getParent('li');
		container.set('id','activeplayer');
		container.store("original",container.get('html'));//  store the contents for later retrieval
		var title = pod.get('text');
		container.set('html', title+'<br/><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+this.options.width+'" height="'+this.options.height+'"><param name="src" value="'+pod.getProperty('href')+'" /><param name="controller" value="true" /><param name="autoplay" value="'+this.options.auto+'" /><!--[if !IE]>--><object type="audio/x-mpeg" data="'+pod.getProperty('href')+'" width="'+this.options.width+'" height="'+this.options.height+'"><param name="autoplay" value="'+this.options.auto+'" /><param name="controller" value="true" /></object><!--<![endif]--></object>');
		
	},
	closePlayer: function() {
		if ( $('activeplayer') != null ) {
			var container = $('activeplayer');
			container.set('html', $('activeplayer').retrieve('original'));
			var pod = container.getFirst('a');
			pod.addEvent('click',function(event) { event.stop();});
			pod.addEvent('click',this.openPlayer.pass(pod,this));
			container.erase('id');
		}
	}
											 
									 });
		