Event.observe(window,"load", function() {
	$$(".default").each(function(el) {
		el.observe("focus",function(ev) {
			el = ev.element();
			if (el.value == el.defaultValue)
				el.value = "";
		});
		el.observe("blur",function(ev) {
			el = ev.element();
			if (el.value == "")
				el.value = el.defaultValue;
		});
	});
	
	if ($("signup")) {
		$("signup").observe("submit",function(ev) {
			reqstr = "";
			errors = 0;
			if ($("alert_msg"))
				$("alert_msg").remove();
			$$(".required").each(function(el) {
				if (el.value == "") {
					new Effect.Morph(el,{ style: "background: #FFFFCC;" });
					errors++;
				} else
					el.setStyle({background: "#FFFFFF"});
			});
			if (errors != 0) {
				alertMessage("<center><h2>Error</h2><p>Please fill out all the marked fields and submit this form again.</p></center>",300,50);
				ev.stop();
			}
		});
	}
});

function alertMessage(html,width,height) {
	var dims = document.viewport.getDimensions();
	w = dims.width;
	h = dims.height;
	var scrolls = document.viewport.getScrollOffsets();
	l = scrolls.left;
	t = scrolls.top;
	
	left = (w - width) / 2 + l;
	top = (h - height) / 2 + t;

	var msg = new Element("div");
	msg.setAttribute("id","alert_msg");
	msg.setStyle({ position: "absolute", left: left + "px", top: top + "px", border: "1px solid #000", height: height + "px", width: width + "px", background: "#FFFFFF", display: "none", zIndex: "5" });
	msg.innerHTML = html;
	document.getElementsByTagName('body')[0].appendChild(msg);
	new Effect.Appear(msg);
	var msgtimer = setTimeout("new Effect.Fade('alert_msg', { afterFinish: function() { $('alert_msg').remove(); } });",7000);
}