function loadForm() {
  $('errorBoxContainer').hide();
  $('lead_submit').hide();
  $('form_loader').show();
}

function submitViaEnter(evt) {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13) {
            form.submit();
            return false;
    }
    return true;
};

function observeSendToFriends() {
  if ($("sendToFriendsForm")) {
    if ($('sendToFriends')){
      $('sendToFriends').observe('click',function() {return addthis_open(this, 'email', 'http://starthere.clearedgepower.com/?s=sendtofriend', 'Send to a Friend', ''); });
    }
    if ($('sendToFriends-l2')){
      $('sendToFriends-l2').observe('click',function() {return addthis_open(this, 'email', 'http://learnmore.cleanpowerguide.org/?s=sendtofriend', 'Send to a Friend', ''); });
    }
    if ($('sendToFriends-l3')){
      $('sendToFriends-l3').observe('click',function() {return addthis_open(this, 'email', 'http://greenerbusiness.clearedgepower.com/?s=sendtofriend', 'Send to a Friend', ''); });
    }
  }
}

function setActions() {
  // swapping out image for stupid IE 6
  Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6;
  
  Effect.Appear('main-container', {duration: .5});
  
  if ($("signup")) {
    Form.focusFirstElement("signup");
    
    // first name and last name are automatically title-cased
    $('lead_first_name').observe('blur', function(){this.value = this.value.toTitleCase()});
    $('lead_last_name').observe('blur', function(){this.value = this.value.toTitleCase()});
  }
};

Event.observe(window, 'load', setActions);