// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var Login = {
  showLoginFailed: function()
  {
    Element.hide($("loginform"));
    new Effect.Pulsate("failed", {duration: 3.0});
    setTimeout(this.showForm,3000)
  }, 

  showForm: function()
  {
    Element.hide($("failed"));
    new Effect.Appear("loginform");
  }          
};

var FormUtils = {
  
  submitOnEnter: function(id)
  {
    $(id).onkeydown= function(e) 
    { 
      e = e || window.event;
      if (e.keyCode == 13)
      {
        $(id).parentNode.submit();
        return false;
      }
    }
  },
 
  validate: function(f)
  {
    retval=true;
    f.getElements().each(function(e)
    {
      if (e.up().hasClassName("required") && e.value =='')
      {
        alert("The " + e.name + " field cannot be blank.")
	retval=false
      }
    });
    return(retval)
  }

};

var PageUtils = {
  toggleSection: function(link,section)
  {
     $(link).toggle();
     $(section).toggle();
  }
};

