(function($) {
	$.fn.delay = function(time, callback){
		// Empty function:
		jQuery.fx.step.delay = function(){};
		// Return meaningless animation, (will be added to queue)
		return this.animate({delay:1}, time, callback);
	};
	$.fn.checkForm = function(url) {
		var theObj = this;
		var data = $(theObj).serialize();
		$(theObj).workingForm(true);
		$.get(url, data, function(data) {
			// make sure this is a lable
			if($("#"+theObj.attr('id')+" label[for='"+data+"']").length) {
				// change all labels to black
				$("#"+theObj.attr('id')+" label").css("color","black") ;
				// change the error label red
				$("#"+theObj.attr('id')+" label[for='"+data+"']").css("color","red") ;
				$(theObj).workingForm(false);
			}
			else {
				if(data == "true") {
					$("#"+theObj.attr('id')+" label").css("color","black") ;
					$.doTimeout( 1500, function(){
						document.getElementById($(theObj).attr('id')).reset();
						$(theObj).workingForm(false);
						$(document.createElement("div")).attr({"id":"resutls","class":"success"}).prependTo($(theObj)).text("Your Message Has Been Sent!");
					});
				}
				else {
					$(theObj).workingForm(false);
						alert(data);
				}
			}
		});	
	};
	$.fn.workingForm = function(status) {
		var theForm = $("#"+this.attr("id"));
		var theW = theForm.width();
		var theH = theForm.height();
		var method = {
			show: function() {
				$(document.createElement("div")).attr("id","progression").prependTo(theForm);
				$("#progression").css({"position":"absolute","width": theW+"px","height": theH+"px","background-color":"black","z-index": "100"});
				$("#progression").animate({opacity: 0.4});
				$(document.createElement("div")).attr({"id":"progressBOX"}).prependTo(theForm);
				$("#progressBOX").hide();
				$(document.createElement("img")).attr({"id":"progressGIF","src":"images/progress.gif"}).prependTo("#progressBOX");
				$("#progressGIF").ready(function() {
					$("#progressBOX").css({"position":"absolute","background-color":"white","padding":"12px","z-index": "101","border":"#ccc medium inset"});
					var pW = $("#progressBOX").width();
					var pH = $("#progressBOX").height();
					pWm = ($("#progression").width() - pW) / 2
					pHm = ($("#progression").height() - pH) / 2
					$("#progressBOX").css({"width":pW+"px","height":pH+"px","margin-left":pWm+"px","margin-top":pHm+"px"});
					$("#progressBOX").show();
				});
			},
			hide: function() {
				$("#progressBOX").remove();
				$("#progression").remove();
			}
		};
		if(status == true) {
			method.show();
			return false;
		};
		if(status == false) {
			method.hide();
			return false;
		}
	}
})(jQuery);