function validate_calform(frm) {
	with (frm) {			
		if (cal_sdate.value.length == 0 && cal_edate.value.length == 0 && cal_keyword.value.length == 0 && cal_catID.selectedIndex == 0) {
			alert('Please enter a date range, keyword, or choose a Category!');
			cal_sdate.focus();
			return false;		
		}

		if (cal_sdate.value.length > 0 && !fmtDate(cal_sdate, '-')) {
			alert('Please enter a valid From Date!');
			cal_sdate.focus();
			return false;
		}
		
		if (cal_edate.value.length > 0 && !fmtDate(cal_edate, '-')) {
			alert('Please enter a valid To Date!');
			cal_edate.focus();
			return false;
		}			
	
		if (new Date(cal_edate.value) < new Date(cal_sdate.value)) {
			alert('The end date should be after the start date!');
			cal_edate.focus();
			return false;
		}
	}
		
	return true;
}

var calendar = {
	codes : Array,
	init : function() {
	
		calendar.codes = jQuery('.e-item');
		calendar.attach();
	},
	attach : function() {
		var i;
		calendar.codes.click(calendar.collapse);
	},
	getEventSrc : function (e) {
		if (!e) e = window.event;
		if (e.originalTarget)
			return e.originalTarget;
		else if (e.srcElement)
			return e.srcElement;
	},
	collapse : function(e) {
			var el = jQuery(this);
			var extra =jQuery('#' + el[0].parentNode.id.replace('event','extra'));
			extra.toggle();
			el.toggleClass('e-itemOn');
			el.toggleClass('e-item');
	}
};

// ATTACH ONCLICK EVENT TO ALL ELEMENTS WITH THE l-item CLASS
jQuery(document).ready(calendar.init);
//Event.observe(window,'load',calendar.init,false);
