$(document).ready(function() {
	
	// Submit button - disable on click
	$('form').submit(function(){
		$('input[type=submit]:not(.no-disable)', this).attr('disabled', 'disabled');
	});
	
	// Error class on inputs before a field-error
	$('span.field-error').each(function() {
		$(this).parent().find('input,select,textarea').addClass('field-error');
		$(this).parent().next('td.field-info').prepend(this);
	});
	
	
	$('input[title]').each(function() {
		// on focus - make text empty if it is set to emptytext
		$(this).focus(function() {
			if ($(this).attr('value') == $(this).attr('title')) {
				$(this).attr('value', '');
			}
		});
		
		// on blur - make text emptytext if it is empty
		$(this).blur(function() {
			if ($(this).attr('value') == '') {
				$(this).attr('value', $(this).attr('title'));
			}
		});
		
		// run the blur event
		$(this).blur();
	});
	
	// on submit - make text empty if it is set to emptytext 
	$('input[title]').closest('form').submit(function() {
		$(this).find('input[title]').each(function() {
			if ($(this).attr('value') == $(this).attr('title')) {
				$(this).attr('value', '');
			}
		});
	});
});

