
$(document).ready(
	function() {
		// striping on search result tables
		$('.dataTable tr:even').addClass('altRow');

		// sort styles on th as well as button/link
		$('.dataTable .sort-asc').parents('th').addClass('sort-asc');
		$('.dataTable .sort-desc').parents('th').addClass('sort-desc');

		// round corners on main UI
		$('.contentMargins, .border, .borderGradient').corner();

		// roll-up search forms
		$('legend.toggle').click(function(){
			$(this).parent().toggleClass('closed').toggleClass('open');
		});

		// "confim" for delete
		$('.delete-confirm').click(function(){
			var msg = 'Are you sure you want to ';
			if (this.title && '' != this.title) {
				msg += this.title;
			} else {
				msg += 'do that?';
			}
			return confirm(msg);
		});

		// "reset" button on search forms
		var resetSearch = function() {
			$(this).parents('fieldset').find(':input').each(function() {
		        var t = this.type;
	    	    if (t == 'text' || t == 'password' ||  this.tagName.toLowerCase() == 'textarea') {
	        	    this.value = this.defaultValue;
	        	} else if (t == 'checkbox' || t == 'radio') {
	            	this.checked = this.defaultChecked;
				}
			});
			$(this).parents('fieldset').find('select option').each(function() {
				this.selected = this.defaultSelected;
			});
			return false;
		};
		$('.reset-search').click(resetSearch);

		// "clear" button on search forms
		$('.clear-search').click(function() {
			$(this).parents('fieldset').find(':input').each(function() {
		        var t = this.type;
	    	    if (t == 'text' || t == 'password' ||  this.tagName.toLowerCase() == 'textarea') {
	        	    this.defaultValue = '';
	        	} else if (t == 'checkbox' || t == 'radio') {
	            	this.defaultChecked = false;
				}
			});
			$(this).parents('fieldset').find('select option').each(function() {
				this.defaultSelected = false
			});
			resetSearch();
			return false;
		});
	}
);
