FeedMenu = Class.create();
Object.extend(FeedMenu.prototype, {
	element: ''
	,feedList: '' 
	,label: 'RSS Feeds'
	,feeds: null
	,feedListHTML: null
	,cssClass: 'feedMenu'
	
	,initialize: function() {
		this.element = arguments[0];
		this.feedList = arguments[1];
		
		this.build();
	}
	
	,build: function(){
		this.feedListHTML = '<span style="display:none;" id="'+this.element+'_feedMenu" class="'+this.cssClass+'"><select id="'+this.element+'_SelFeedMenu"><optgroup label="'+this.label+'"/>'; 
		var optionTemplate = new Template('<option value="#{href}">#{title}</option>');
		this.feedList.each(function(i){
			this.feedListHTML += optionTemplate.evaluate({
				href: i.href
				,title: i.title
			});
		}.bind(this));
		this.feedListHTML += '</select></span>';
		$(this.element).insert(this.feedListHTML);
		$(this.element).observe('click', this.show.bind(this)); 
		//$(this.element).observe('mouseout', this.hide.bind(this));
		$(this.element+'_SelFeedMenu').observe('change', this.selectItem.bind(this));
	}
	
	,hide: function(){
		$(this.element+'_feedMenu').setStyle({
			display: 'none'
		});
	}
	
	,show: function(){
		$(this.element+'_feedMenu').setStyle({
			display: 'block'
		});
	}
	
	,selectItem: function(){
		window.location = $(this.element+'_SelFeedMenu').options[$(this.element+'_SelFeedMenu').selectedIndex].value;
	}
});