Event.observe(window, 'dom:loaded', function(e){
	// If there is a submit button and a validation function, connect the two
	if($$('input[type=submit]') && $('validate')) $$('input[type=submit]').each(function(o){
		o.setAttribute('onclick', 'return validate();');
	});

	// class="fix" means "only hide if javascript is enabled"
	if($$('.fix')) $$('.fix').each(function(o){ o.hide(); });
});

function populateDate(objForm, selectIndex) {
	var numDays = objForm.day.length;
	for (var i = 0; i < numDays; i++) {
		objForm.day.options[1] = null;
	}
	if (objForm.year.options[objForm.year.selectedIndex].value && objForm.month.options[objForm.month.selectedIndex].value) {
		timeA = new Date(objForm.year.options[objForm.year.selectedIndex].text, objForm.month.options[objForm.month.selectedIndex].value,1);
		timeDifference = timeA - 86400000;
		timeB = new Date(timeDifference);
		var daysInMonth = timeB.getDate();
		for (var i = 1; i <= daysInMonth; i++) {
			objForm.day.options[i] = new Option(i,i);
		}
		objForm.day.options[0].selected = true;
	}
}
function correlate(checkbox,id){
	// Remember:  this runs before the checked state is altered by the click.
	var o = $(id);
	if(checkbox.checked)
		o.show();
	else {
		o.select('input select textarea').each(function(ob){
			ob.value = null;
			ob.checked = null;
			ob.innerHTML = null;
			ob.selectedIndex = null;
		})
		o.hide();
	}
}
function mark(o){	// mark a basic forum element as invalid (input[type=text] or textarea)
	if(!o || !o.setStyle) return;
	on_action = 'blur';
	if('INPUT' == o.tagName && ('checkbox' == o.getAttribute('type') || 'radio' == o.getAttribute('type'))){
		o = o.up();
		on_action = 'click';
	}
	o.addClassName('mark');
	o.focus();
	o.observe(on_action, function(e){
		o.removeClassName('mark');
	});
}