﻿/// <reference path="~/scripts/jquery-1.3.2.js" />
$(document).ready(function() {
	// Storing default values and adding focus/blur event handlers to input elements
	$("input.textbox").each(function() {
		$(this)
			.data("defValue", $(this).attr("value"))
			.focus(function() {
				if ($(this).attr("value") == $(this).data("defValue"))
					$(this).attr("value", "");
				$(this).addClass("filledbox");
			})
			.blur(function() {
				if ($(this).attr("value") == "") {
					$(this).attr("value", $(this).data("defValue"));
					if ($(this).attr("value") == $(this).data("defValue"))
						$(this).removeClass("filledbox");
				}
			});
	});
	$("textarea.textbox").each(function() {
		$(this)
			.data("defValue", $(this).attr("value"))
			.focus(function() {
				if ($(this).attr("value") == $(this).data("defValue"))
					$(this).attr("value", "");
				$(this).addClass("filledbox");
			})
			.blur(function() {
				if ($(this).attr("value") == "")
					$(this).attr("value", $(this).data("defValue"));
				if ($(this).attr("value") == $(this).data("defValue"))
					$(this).removeClass("filledbox");
			});
	});
	// Assign mousedown/up functions to buttons
	$("a.button").mousedown(function() {
		$(this).addClass("active");
	})
	.mouseup(function() {
		$(this).removeClass("active").blur();
	});
	// Assign function to #clearform button
	$("#clearForm").click(function() {
		$("input.textbox").each(function() {
			$(this).attr("value", $(this).data("defValue")).removeClass("filledbox");
		});
		$("textarea.textbox").each(function() {
			$(this).attr("value", $(this).data("defValue")).removeClass("filledbox");
		});
	});
});
