$(init);

function init() {

  $("form.userform").each(
    function() {
      FormRegistry.init($(this));
    }
  );

  if ($.browser.msie) {
    $("object, embed, applet").each(
      function() {
        this.outerHTML = this.outerHTML;
      }
    );
    try {
      document.execCommand("BackgroundImageCache", false, true);
    }
    catch(err) {}
  }

  navShadow();
  faqList();
  marquee();

}

function navShadow() {

  $("#nav a, #primary h2").each(
    function() {
      $(this).html('<strong>' + $(this).html() + '<span>' + $(this).html() + '</span></strong>');
    }
  );

}


function marquee() {

  $("#marquee").show().html(
    '<marquee direction="left" behavior="scroll" scrollamount="2" scrolldelay="5">' + 
    $("#marquee").html() +
    '</marquee>'
  );

}


function faqList() {

  $("#faq_list").find("dt").click(
    function() {
      $(this).parent().find("dd:visible").hide();
      $(this).next().show();
    }
  ).end().find("dd").hide();

}


function input_placeholders() {

  var userLabel = $("label[@for='l_username']").text();
  var emailLabel = $("label[@for='l_email']").text();

  if ($("#l_username").val() == "") {

    $("#l_username").after('<input id="l_user_placeholder" type="text" class="inp" value="' + userLabel + '" />');
    $("#l_email").after('<input id="l_email_placeholder" type="text" class="inp" value="' + emailLabel + '" />');

    $("#l_user_placeholder").focus(
      function() {
        $(this).hide();
        $("#l_username").focus();
      }
    );

    $("#l_username").blur(
      function() {
        if ($(this).val() == "") {
          $("#l_user_placeholder").show();
        }
      }
    );

    $("#l_email_placeholder").focus(
      function() {
        $(this).hide();
        $("#l_email").focus();
      }
    );

    $("#l_email").blur(
      function() {
        if ($(this).val() == "") {
          $("#l_email_placeholder").show();
        }
      }
    );

    /*$("#l_pass_placeholder").focus(
      function() {
        $(this).hide();
        $("#l_password").focus();
      }
    );

    $("#l_password").blur(
      function() {
        if ($(this).val() == "") {
          $("#l_pass_placeholder").show();
        }
      }
    );*/

  }

}

window.onload = function() {

  input_placeholders();

}
