var nwbl;
if(!nwbl) {
    nwbl = {};
} else if (typeof nwbl !== 'object') {
    throw new Error('nwbl already exists and is not an object');
}
nwbl.nbwebcast = Class.create({
	options: {
		url: '',
		containerId: '',
		_wcList: [],
		playList:[],
		player:$('siteUrl').readAttribute('value') + 'player.swf'
	},
	initialize: function(options) {
        Object.extend(this.options, options);
    },
	getWebCastList: function() {
		var opts = this.options;
		new Ajax.Request(opts.url, {
		  method: 'get',
		  onSuccess: function(e) {
		    opts._wcList = eval(e.responseText);
			this.createWebCastList();
		  	document.fire('webCastList:loaded');
		  }.bind(this),
		  onFailure: function(e) {
			document.fire('webCastList:failed');
		  }.bind(this)
        });
	},
	createWebCastList: function() {
		var tp = '';
		for(var i=0; i<this.options._wcList.length; i++) {
			var wc = this.options._wcList[i];
			if(wc.category == 'audio') {
				tp = 'sound';
			} else if(wc.category = 'video') {
				tp = 'video';
			}
			this.options.playList[i] = {
				author: 'New Bethel',
				description: wc.date + ' - ' + wc.details,
				file: $('siteUrl').readAttribute('value') + wc.url,
				link: $('siteUrl').readAttribute('value'),
				title: wc.category + ' | ' + wc.title,
				//image: $('siteUrl').readAttribute('value') + 'images/welcome1.jpg',
				type: tp
			};
		}
	}
});