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 = document.getElementsByClassName("e-item");
		calendar.attach();
	},
	attach : function() {
		var i;
		for (i=0;i<calendar.codes.length;i++ ) {
			Event.observe(calendar.codes[i],'click',calendar.collapse,false);
			Element.cleanWhitespace(calendar.codes[i].parentNode);
			Element.cleanWhitespace(calendar.codes[i].parentNode.parentNode);
		}
	},
	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 = calendar.getEventSrc(e).nextSibling.nextSibling;
		Effect.toggle(el.id,'slide', {duration:0.2});
		
		if (el.style.display == "none") {
			calendar.getEventSrc(e).className = "e-itemOn";
		} else {
			calendar.getEventSrc(e).className = "e-item";
		}
	}
};

// ATTACH ONCLICK EVENT TO ALL ELEMENTS WITH THE l-item CLASS
//Event.observe(window,'load',calendar.init,false);
