function hideSearchForm() {
  jQuery('#locality_id').fadeOut(700);
  jQuery('#restaurant_cuisine_id').fadeOut(700);
  jQuery('#region_id').fadeOut(700);
  jQuery('#search_options_area').fadeOut(700);
  jQuery('#search_form_box').animate({height: "hide"}, 800);
}

function hideProfileForm() {
  jQuery('.profile_box .select_custom').each(function() {jQuery(this).fadeOut(700);});
  jQuery('#profile_form_box').animate({height: "hide"}, 800);
}

function hideProfileFormWithRefresh() {
  jQuery('#profile_form_box').animate({height: "hide"}, {duration:800,callback:refreshProfile()});
}

function hideForgotPasswordForm() {
  jQuery('#forgot_password_form_box').animate({height: "hide"}, 800);
}

function hideCommentsProfile() {
  jQuery('#comments_profile').animate({height: "hide"}, 800);
}

function hideLoginForm() {
  jQuery('#login_form_box').animate({height: "hide"}, 800);
}

function hideMessages() {
  jQuery('.messages').each(function() {
    jQuery(this).animate({height: "hide"}, {duration: 800, callback: jQuery('body').remove(this)});

    setTimeout("removeMessages()",800);
  });
}

function removeMessages() {
   jQuery('#msgs').empty();
}

function emptyMessages() {
   jQuery('#messages').empty();
}

function emptyTopMessages() {
   jQuery('#top_area_messages').empty();
}

function displayMessages() {
  jQuery('#messages').animate({height: "show"}, 800);
}

function displayLoginForm() {
  hideMessages();
  hideSearchForm();
  hideProfileForm();
  hideForgotPasswordForm();
  hideCommentsProfile();
  jQuery('#top_area_messages').animate({height: "hide"}, {duration: 800});

  jQuery('#login_form_box').animate({height: "show"}, 800);
}

function displaySearchForm() {
  hideMessages();
  hideLoginForm();
  hideProfileForm();
  hideForgotPasswordForm();
  hideCommentsProfile();
  jQuery('#top_area_messages').animate({height: "hide"}, {duration: 800});

  jQuery('#locality_id').fadeIn(900);
  jQuery('#restaurant_cuisine_id').fadeIn(900);
  jQuery('#region_id').fadeIn(900);
  jQuery('#search_options_area').fadeIn(900);
  jQuery('#search_form_box').animate({height: "show"}, 800);
}

function displayProfileForm() {
  jQuery('.profile_box .select_custom').each(function() {jQuery(this).hide();});
  hideMessages();
  hideLoginForm();
  hideSearchForm();
  hideForgotPasswordForm();
  hideCommentsProfile();
  jQuery('#top_area_messages').animate({height: "hide"}, {duration: 800});

  jQuery('#profile_form_box').animate({height: "show"}, {duration: 800});
  jQuery('.profile_box .select_custom').each(function() {jQuery(this).fadeIn(900);});
  jQuery('#sf_guard_user_profile_gender div.select_option_container').css("z-index", "5000");
  jQuery('#sf_guard_user_profile_birth_year div.select_option_container').css("z-index", "5000");
  jQuery('#sf_guard_user_profile_country_id div.select_option_container').css("z-index", "5000");
  jQuery('#sf_guard_user_profile_locality_id div.select_option_container').css("z-index", "5000");

}

function displayForgotPasswordForm() {
  hideMessages();
  hideLoginForm();
  hideSearchForm();
  hideProfileForm();
  hideCommentsProfile();
  jQuery('#top_area_messages').animate({height: "hide"}, {duration: 800});

  jQuery('#forgot_password_form_box').animate({height: "show"}, 800);
}

jQuery(document).ready(function() {


   jQuery('.go_login').click(function(){
        displayLoginForm();
        return false;
    });

    jQuery('.go_profile').click(function(){
        displayProfileForm();
        return false;
    });

    jQuery('.go_top_login').click(function(){
        displayLoginForm();
        self.location.hash='#top';
        return false;
    });

    jQuery('.go_top_profile').click(function(){
        displayProfileForm();
        self.location.hash='#top';
        return false;
    });

    jQuery('.go_forgot_password').click(function(){
        displayForgotPasswordForm();
    });

    jQuery('.back_to_search_button').click(function(){
        displaySearchForm();
    });

    jQuery('#login_form_area .checkbox').click(function(){
      if(!jQuery(this).hasClass('active')) {
        jQuery(this).addClass('active');
        jQuery(this).parent().children('input').val(1);
      }
      else {
        jQuery(this).removeClass('active');
        jQuery(this).parent().children('input').val(0);
      }
      return false;
    });


    jQuery('#search_form_box img.error').each(function(){
      jQuery(this).click(function(){
        jQuery('#search_form_box .box2').empty();
        var error = jQuery(this).parent().children("span.message").text();
        jQuery('#search_form_box .box2').text(error);

      });
    });


});







    /* var options = {
        target:        '#messages',   // target element(s) to be updated with server response
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse  // post-submit callback

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    }; */