jQuery.noConflict();
jQuery(document).ready(function($) {
	
  	/* 
	 * This where all of the functions that extend the jQuery object go
	 */
	
	//Validates a form
	$.fn.extend({
		validateForm: function() {
	   		// check for blank required fields
				/* If blank then not valid*/
		   		/* If not blank then call server and validate */
			
			if ( $("input", this).val().length > 0 )
				return true;
	   		else {
				$(this).displayIsBlankNotices();
				$(this).executeRebuke();
				return false;
	   		}
		},
		
		displayIsBlankNotices: function() {
			$("p.error", this).remove();
			$(".required", this).after("<p class=\"error\" style=\"display: none\">This field is required.</p>");
			$("p.error", this).show();
			return this;
		},
		 
		executeRebuke: function() {
			$(this).parent().Shake(2);
			return this;
		} 
	 });
	
	//Puts focus on the first input field in a form   
	$.fn.extend({ 
		focusOnFirstFieldinForm: function() {
		  	var elem = $("input[@type=text]", this).get(0);
			if (elem) {
				elem.focus();
			}
			return this;
		}, 
		
		focusOnThis: function() {
		  	var elem = $(this).get(0);
			if (elem) {
				elem.focus();
			}
			return this;
		}
	});
});