$(document).ready(function (){
	// set JS class for CSS
//	$('HTML').addClass('JS'); WE'RE NOW DOING THIS IN THE DOC ITSELF TO AVOID FLICKER
	
	// Add login link and set it to open and close the login panel
	
	$("div#utility-bar a:first").before('<a href="#" class="open-contact-mailing">Contact + Join mailing list</a> | ');
	$("a.open-contact-mailing").click(function () {
		if ($("#contact-mailing-panel").css("display")=="none") {
			$("#contact-mailing-panel").slideDown();
			$("a.login-link").addClass("open");
		} else {
			$("#contact-mailing-panel").slideUp();
			$("a.login-link").removeClass("open");
		}
	});
	
	// set up mailing list form
	
	$("div#mailing input#name").val("Your name").addClass("blank").focus(function () {
		if ($(this).val() == "Your name") $(this).val("").removeClass("blank");
	}).blur(function () {
		if ($(this).val() == "") $(this).val("Your name").addClass("blank");
	});
	$("div#mailing input#hhqv-hhqv").val("Your email address").addClass("blank").focus(function () {
		if ($(this).val() == "Your email address") $(this).val("").removeClass("blank");
	}).blur(function () {
		if ($(this).val() == "") $(this).val("Your email address").addClass("blank").addClass("blank");
	});

	// if calendar exists, set up popup windows
	
	$("table.calendar td.event").mouseenter(function() {
		$("table.calendar td.event").css("z-index", "1"); /* set all tds to low level*/
		$(this).css("z-index", "10"); /* position this TD above all others */
		$("p", this).fadeIn(500);
	}).mouseleave(function(){
		$("p", this).fadeOut(200);
	});	
});
