document.observe('dom:loaded', function() {
	//See bug #54040
		
	if ($('widgetFilter'))
		new SimpleReveal('widgetFilter', {oLinkSel:'.btnWhiteAlt', cLinkSel:'.close', contentSel:'#filterOpts'});
	//var courseList = new CourseList('div.dataRow table.common tbody tr.classRow', 'ajax/schedule_detail.php')
	
	$$('select.styled').each(function(s){
		new DropDown(s);
	});
	
	return true;
	
	//zip widget
	$$('.zipChange').each(function(el){
		new PositionedPopup(el, $('setLocation'), {xOffset:70,yOffset:-70, popParent:'div.main'});
	});
	

	
	var init = function(skipPops){
		$$('div.dataRow table.common tbody tr.classRow').each(function(el){
			new CourseRevealer(el, 'a.time', 'a.close', 'div.detailedView', {
				url : 'ajax/schedule_detail.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, {viewableCourses:5});
		});
		
		$$('td.col2').each(function(el){
			new PositionedToolTip(el, el.down('.overlayTip'), {xOffset:100});
		});
		
		if (! skipPops)
			$$('#courseList .lbOn').each(function(el){
					new lightbox(el);
			});
	}
	
	init(true);
	
	/*new DropDown('courseSort', {
		onchange : function(){
			$('filterForm').select("#sortByValue").first().value = $F(this.hidden);
		}
	});*/
	
	
	
	new SearchFilter('filterForm', 'courseList', {
		beforeSubmit : function(){
		// NOTE! COMMENT THIS LINE OUT AND SET URL IN THE ACTION OF THE FILTERFORM.  THIS IS FOR DEMO ONLY.
			this.form.writeAttribute('action', 'includes/components/content/course/schedule_location_'+$F('courseSort')+'.php');
		},
		callback : function(){
			init();
		},
		reset : $$('.reset').first()
	});
	
	
	$$('select.styled').each(function(s){
		//new DropDown(s);
	});
		
});