function closeCamResults() {
  $(".camResults")
    .slideUp(function() {
	$(this).html("");
      })
}

function showCamResults(message) {
  if (resultsTimeout != null) clearTimeout(resultsTimeout);
  $(".camResults")
    .html(message)
    .slideDown();
  var resultsTimeout = setTimeout(closeCamResults, 3000)
}

$(document).ready(function() {
    $("#signForm").ajaxForm({
      clearForm: true,
	  success: function() {
	  $(".signCam-form").removeClass("formActive").slideUp();
	  $(".boxed").removeClass("hiddenByForm").show();
	  showCamResults("Your message is in the hopper, and will scroll by soon.")
	}
      });

    $("#signForm2").ajaxForm({
      clearForm: true,
	  success: function() {
	  showCamResults("Your message is in the hopper, and will scroll by soon.")
	}
      });
    
    $(".signCam").click(function() {
	$(".signCam-form")
	  .slideDown()
	  .addClass("formActive");
	$(".boxed")
	  .hide()
	  .addClass("hiddenByForm");
      });

    $(".cancelSignForm").click(function() {
	$(".signCam-form")
	  .slideUp()
	  .removeClass("formActive");
	$(".boxed").removeClass("hiddenByForm").show();
	$("#sign").val("");
      });

    $(".camOverlay").hover(function() {
	if (!$(".hiddenByForm").length) {
	  $(".boxed", this).css("display", "block");
	}
	if ($(".formActive").length) {
	  $(".signCam-form").show();
	}
      }, function() {
	$(".boxed", this).css("display", "none");
	$(".signCam-form").hide();
      });
    
    $(".ajaxLink")
      .click(function() {
	  url = $(this).attr("href");
	  $.get(url);
	  showCamResults($(this).attr("result"));
	  return false;
	});

    $('#imgForm').ajaxForm(function() {
	alert("Your picture will be displayed soon!");
      });
	
  });
