document.observe('dom:loaded', function() {
	
	//var courseList = new CourseList('div.dataRow table.common tbody tr.classRow', 'ajax/schedule_detail.php')
	
	var init = function(skipPops){
		$$('div.dataRow table.common tbody tr.classRow').each(function(el){
			new CourseRevealer(el, 'a.btnGreen', 'a.close', 'div.detailedView', {
				url : 'ajax/event_form.php',
				parameters : {id:el.readAttribute('id').split('course_')[1]}
			});
			el.select('.foot').invoke('hide');
			
			// hover states
			new BasicHover(el, 'hover');
		});
		
		
		$$('#widgetListing .dataRow').each(function(table){
			new ShowAll(table);
		});
		
		$$('td.col2').each(function(el){
			new PositionedToolTip(el, el.down('.overlayTip'), {xOffset:100});
		});
		
		if (! skipPops)
			$$('#courseList .lbOn').each(function(el){
				//if (! el.hasClassName('lbInited'))
					new lightbox(el);
			});
	}
	
	init(true);
	
	
	new DropDown('courseSort', {
		onchange : function(){
			$('filterForm').select("#sortByValue").first().value = $F(this.hidden);
		}
	});
	
	$$('select.styled').each(function(s){
		new DropDown(s);
	});
	
	
	if ($('widgetFilter'))
		new SimpleReveal('widgetFilter', {oLinkSel:'.btnWhiteAlt', cLinkSel:'.close', contentSel:'#filterOpts'});
	
	new SearchFilter('filterForm', 'courseList', {
		
		beforeSubmit : function(){
			// NOTE! COMMENT THIS OUT AND SET URL IN THE ACTION OF THE FILTERFORM.  THIS IS FOR DEMO ONLY.
			this.form.writeAttribute('action', 'includes/components/content/events/schedule_location_'+$F('courseSort')+'.php');
		},
		callback : function(){
			init();
		},
		reset : $$('.reset').first()
	});
	
	$$('select.styled').each(function(s){
		//new DropDown(s);
	});
	
	
	//show more cities revealer
	var show = $$('#filterForm div.row.last');
	if (show.length>0)
		new ShowAll(show.first(), 
			{viewableCourses:4,
			rowSelector:'div.clear',
			toggleSel:'a.viewAll',
			heightSelector:'.fullset'
		});
	
});