/*
 * General jQuery functions that can be called
 * on any page of the frontend
 */
jQuery(document).ready(function() {
  // Auto-submit login-box address form
  jQuery('#profile_address').bind('change', function() {
    jQuery('#address_list_form').submit();
	});

  /*
   * Address list in login box is a link. If
   * clicked, a select box has to appear to
   * change user's current address
   */
  jQuery('#list_address_current').click(function(event) {
    event.preventDefault();
    jQuery('#address_current').addClass('nodisplay');
    jQuery('#div_address_list_form').removeClass('nodisplay');
  });

  /*
   * Clearonfocus for login box
   */
  jQuery('#signin_username').clearonfocus();
  jQuery('#signin_password').clearonfocus();


  /*
   * Favorite restaurants list in navbar
   * Auto submit on change
   */
  jQuery('#favorite_restaurants_list').change(function(event) {
    //event.preventDefault();
    jQuery('#favorite_restaurants_form').submit();
  });
});

