var GE_EventDropDown = Class.create( GE_DropDown, {
	upcoming_event_list:null,
	past_event_list:null,
	upcoming_events:null,
	past_events:null,
	initialize:function($super, el) {
		$super(el);
		this.titleEl.update('All Events &amp; Presentations');

		this.upcoming_event_list = $$('.container')[0].down('.list');
		this.past_event_list = $$('.container')[1].down('.list');

		if (this.upcoming_event_list) this.upcoming_events = this.upcoming_event_list.childElements();
		if (this.past_event_list) this.past_events = this.past_event_list.childElements();
		
		this.items.each(
			function(el) {
				var a = el.down('a');
				a.observe('click',function(e){
					e.stop();
					this.o.titleEl.update(this.a.innerHTML);
					this.o.filter(this.o.upcoming_event_list,this.o.upcoming_events,this.a.innerHTML.replace(' ','_'));
					this.o.filter(this.o.past_event_list,this.o.past_events,this.a.innerHTML.replace(' ','_'));
					this.o.toggleSelect();
				}.bind({o:this,a:a}));
			}.bind(this)
		);
	},
	filter:function(list,events,c) {
		if (events) {
			var events_on = [];
			events.each(function(el){
				if (el.down('div').hasClassName(c) || c=='All_Events &amp; Presentations') {
					events_on.push(el);
				}
			});
			list.childElements().each(function(el){el.remove()});
			events_on.each(function(el){
				var i = this.events_on.indexOf(el);
				this.list.insert(el);
			}.bind({events_on:events_on,list:list}));

			if (list.childElements().length==0) {
				var msg = (list==this.upcoming_event_list)? 'There are no public events scheduled for the next 15 business days.' : 'There are no past public events.';
				list.insert( new Element('li').addClassName('list_item').insert(msg) );
			}
		}
	}
});


GE_Main.mapCSSToFn('dropdown_list', GE_EventDropDown);

