/*
* Handles hiding and showing of label that is placed over the target textbox.
* Simply add class "overlabel" to the label element, and class "overlabelTarget" to the target textbox and call overLabelInit() on document ready
*
* Created by Ruud van Falier
*/

(function ($) {
	$(document).ready(function() {
		$(".overlabel").click(function () {
			$(this).css("display", "none");
		});

		$(".overlabel").select(function () {
			$(this).css("display", "none");
		});

		$(".overlabelTarget").focus(function () {
			var id = $(this)[0].id;
			$(".overlabel[for=" + id + "]").css("display", "none");
		});

		$(".overlabelTarget").blur(function () {
			if ($(this).attr("value") == "") {
				var id = $(this)[0].id;
				$(".overlabel[for=" + id + "]").css("display", "");
			}
		});

		$(".overlabel").each(function () {
			targetId = $(this).attr("for");
			if (!$(this).hasClass("errormessage") && $("#" + targetId).attr("value") != "") {
				$(this).css("display", "none");
			}
		});
		
		/* Custom implementation for error messages on contact and application form */
		
	});
})(jQuery);
