/**
 * registration.js - Functions to execute on registration
 */
 
jQuery(document).ready(registration_setup);

function registration_setup()
{
  jQuery(".register_dialog").dialog({ autoOpen: false, width: 330, title: "Member Sign In", modal: true, dialogClass: 'shortDialog' });
  
  /**
   * if the login button on the homepage login box is
   * pressed and the login fields are empty, then the
   * login popup should display; else the form should
   * submit.
   * This should only apply to the login box.
   */
  jQuery('#sidebarLoginBox form').submit(function(){
    
    if(jQuery('#loginEmail').val() == '' && jQuery('#loginPassword').val() == '')
    {
      // show login dialog
      jQuery('#login_dialog').dialog('open'); 
      
      // stop form submission
      return false;
    }
    else
    {
      // submit form
      return true;
    }
    
  });
}

function text_field_focus(element)
{
  jQuery(element).addClass("active");
}

function text_field_blur(element)
{
  jQuery(element).removeClass("active");
}

/**
 * load reg info for user tabs
 * when not logged in
 */
function loadRegInfo(page_id)
{
  hideSearch();
  
  jQuery.get(
    '/reginfo.php',
    {page: page_id},
    function(data){
      
      // populate info area
      jQuery('#regInfoArea').html(data);
    },
    'html'
  );
}

/**
 * general function to hide search divs
 * and show reg. info div
 */
function hideSearch()
{
  // hide search area
  jQuery('#liveSearchWrap').hide();
  
  // hide search bar
  jQuery('#searchBar').hide();
  
  // insert loading image and text
  jQuery('#regInfoArea').html('<div id="regInfoLoading"><img src="/images/v2/ajax-loader-reg_info.gif" /><span>loading...</span></div>');
  
  // show info area
  jQuery('#regInfoArea').show();
}

/**
 * general function to show search divs
 * and hide reg. info div
 */
function showSearch()
{
  // show search area
  jQuery('#liveSearchWrap').show();
  
  // show search bar
  jQuery('#searchBar').show();
  
  // hide info area
  jQuery('#regInfoArea').hide();
}
