// JavaScript Document
/*--------------------- jQuery helpers -----------------------*/
// Plugin to clear form using jQuery
// Usage: $('form').clearForm() or $(':input').clearForm()
jQuery.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return jQuery(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};

// Plugin to check/uncheck checkboxes in forms
// Usage: jQuery("#form-select-messages input[@type='checkbox']").check();
jQuery.fn.check = function() {
	return this.each(function() {
		this.checked = this.checked ? false : true;
	});
};