/**************************
*   Funktionen
**************************/
(function($){	
	// --- Hover IMG Swap
	$.fn.hoverSwap = function() {
		$(this).hover(
			function() { $("img", this).fadeIn("fast"); },
			function() { $("img", this).fadeOut("fast"); }
		);
	};

	// --- Check Button Switch
	$.fn.checkboxSwitch = function() {
		if ($(this).is(":checked")) { $(this).next().val("Nein"); }
		else { $(this).next().val("Ja!"); }
	};

	// --- Clear Default Value
	$.fn.clearDefault = function() {
		$(this).each(function() {
		  	var defaultvalue = $(this).val();
			$(this).focus(function() {
				if( $(this).val() == defaultvalue ) $(this).val("");
			});

			$(this).blur(function() {
				if( $(this).val() == "" ) $(this).val(defaultvalue);
			});
		});
	};


	// --- Check Submit
	$.fn.checkSubmit = function() {
        $(this).submit(function () {
			var submitornot = true;
			$("*[defaultvalue]").each(function() {
				var defaultvalue = $(this).attr("defaultvalue");
				if ($(this).val() == "" || $(this).val() == defaultvalue) {
					$(this).addClass("incorrect");
					submitornot = false;
				}
				else {
					$(this).removeClass("incorrect");
				}
			});
			if (submititornot == false) { $("#message").text("Bitte füllen Sie alles aus!"); }
			return submitornot;
		});
	};



})(jQuery);

