// Use the lovely jQuery to highlight active fields
$(document).ready(function(){
	
	// Add class on form field focus
	$("input,textarea").focus(function() {
		$(this).parent().addClass("fieldFocus")
		
		// If there's some help text in the field, copy it to the help panel
		if ( $(this).next("span.helpText").length > 0 ) {
			$("#formHelp").show('fast')
			$("#formHelpText").html($(this).siblings("span.helpText").html())
		}
	});
	
	$("input,textarea").blur(function() {
		$(this).parent().removeClass("fieldFocus")
		
		// Hide the help panel's form text
		$("#formHelp").hide('fast')
	});

	
	// Use the 'example' plugin to convert hint text
		// First, check that we're on an admin page
		if ( $("adminBox").length > 0 ) { 

			// Then set the example function
			$("input").example(function() {
				return $(this).siblings("span.hint").html(); 
			});
		}


	// Disable buttons on submit
	$('form').submit(function(){
		// Hide submit buttons
		$.blockUI ({ 
			message: '<h1 style="font-size:2em; margin-top:1.5em; font-weight: bold;">Please wait...</h1><img src="/img/elements/please-wait.gif" />',
			css: {  
				height: '100px'
				}
		});
		
	});

	// Attach Datepicker to any element with the datepicker class
	if ( $(".datePicker").length > 0 ) {
		$('.datePicker').datepicker();
	}


});
