
    //sets the javascript to remove the default text when a textbox is clicked
    minusernameCharacters = 6;

  function setInputsBehavior()
  {
    jQuery('#search_content').focus(function(e){
      this.select();
      jQuery(this).val('');
    })

    jQuery('#login_username').focus(function(e){
      this.select();
      jQuery(this).val('');
    })
  
    //we put the password in a different function because we have to rebind the behavior in each replace
    passwordBehavior()
  }

  function replaceWithTextbox(elementID, textboxName, defaultValue)
  {
    if(defaultValue == null)
    {
      defaultValue = '';
    }
    if (textboxName == null)
    {
      textboxName = 'text_box';
    }
    $('#'+elementID).html('<input type="text" name="'+textboxName+'" id="'+textboxName+'_box" value="'+defaultValue+'"/><input type="submit" value="Change" />');
    $('#'+textboxName+'_box').focus();
  }

  function getLoading(message)
  {
    if (message == null)
    {
      message = 'Loading';
    }
    return '<div class="loading"><img src="/images/ajax-loader.gif" />'+message+' ...</div>';
  }

  function validateStep1()
  {
    var returnValue = true;
    jQuery('#personalAccount_UserForm_username').parent('.formRow').find('ul').remove();
    jQuery('#personalAccount_UserForm_email').parent('.formRow').find('ul').remove();
    jQuery('#personalAccount_UserForm_password').parent('.formRow').find('ul').remove();
    jQuery('#personalAccount_BusinessAccountForm_business_name').parent('.formRow').find('ul').remove();
    jQuery('#personalAccount_UserForm_confirm_password').parent('.formRow').find('ul').remove();
     
    if (!jQuery('#personalAccount_UserForm_username').val())
    {
      jQuery('#personalAccount_UserForm_username').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }
    else
    {
      if(jQuery('#personalAccount_UserForm_username').val().length < minusernameCharacters)
      {
        jQuery('#personalAccount_UserForm_username').parent('.formRow').find('label').after('<ul class="error_list"><li>Too short. ('+minusernameCharacters+' characters minimum)</li></ul>');
        returnValue = false;
      }
    }

    if (!jQuery('#personalAccount_UserForm_email').val())
    {
      jQuery('#personalAccount_UserForm_email').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }
    else
    {
      if (!isValidEmailAddress(jQuery('#personalAccount_UserForm_email').val()))
      {
        jQuery('#personalAccount_UserForm_email').parent('.formRow').find('label').after('<ul class="error_list"><li>Invalid Email.</li></ul>');
        returnValue = false;
      }
    }

    if (!jQuery('#personalAccount_BusinessAccountForm_business_name').val())
    {
      jQuery('#personalAccount_BusinessAccountForm_business_name').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }

    if (!jQuery('#personalAccount_UserForm_password').val())
    {
      jQuery('#personalAccount_UserForm_password').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }

    if (!jQuery('#personalAccount_UserForm_confirm_password').val())
    {
      jQuery('#personalAccount_UserForm_confirm_password').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }
    else
    {
      if (jQuery('#personalAccount_UserForm_password').val() != jQuery('#personalAccount_UserForm_confirm_password').val())
      {
        jQuery('#personalAccount_UserForm_confirm_password').parent('.formRow').find('label').after('<ul class="error_list"><li>Passwords should be equal.</li></ul>');
        returnValue = false;
      }



        else
    {
      if(jQuery('#personalAccount_UserForm_password').val().length < minusernameCharacters)
      {
        jQuery('#personalAccount_UserForm_password').parent('.formRow').find('label').after('<ul class="error_list"><li>Too short. ('+minpasswordCharacters+' characters minimum)</li></ul>');
        returnValue = false;
      }
    }



    }

    return returnValue;
  }

  function validateStep2()
  {
    var returnValue = true;

    jQuery('#location_input_city_id').parent('.formRow').find('ul').remove()
    if (!jQuery('#location_input_city_id').val())
    {
      jQuery('#location_input_city_id').parent('.formRow').find('label').after('<ul class="error_list"><li>Required.</li></ul>');
      returnValue = false;
    }

    return returnValue;
  }

  function bindEnterInSignUp()
  {
    var keyFunction = function(e){
      var keypress = e.keyCode ? e.keyCode : e.which;
      if(keypress == 13)
      {
        //enter has been pressed
        jQuery(this).parent().parent().find('.buttons input[value=Next]').click();
      }
    };
    //jQuery('form#registrationForm input[type=text]').keyup(keyFunction);
    //jQuery('form#registrationForm input[type=password]').keyup(keyFunction);
  }

  function validateUploadForm()
  {
    var ext = $('#local_photo_file').val().split('.').pop().toLowerCase();
    var allow = new Array('gif','png','jpg','jpeg');
    if(!ext)
    {
      //alert('Please select an image to upload');
      showDialog('Error','Please select an image to upload','prompt',3);
      return false;
    }
    if(jQuery.inArray(ext, allow) == -1)
    {
      //alert('Invalid file, please select an image.');
      showDialog('Error','Invalid file, please select an image.','prompt',3);
      return false;
    }
    showMessage();
    return true;
  }

  function checkusername(uri)
  {     
    var actualusername = jQuery('#personalAccount_UserForm_username').val()
    if (currentUsername == actualusername)
    {
      return;
    }
    currentUsername = actualusername;
    jQuery('#personalAccount_UserForm_username').parent('.formRow').find('ul').remove();
    if (actualusername.length >= minusernameCharacters)
    {   actualusername= actualusername.replace(/[^a-zA-Z 0-9]+/g,'')
      jQuery('span#availability').load(uri+'/username/'+actualusername);
    }
    else
    {
      jQuery('#personalAccount_UserForm_username').parent('.formRow').find('label').after('<ul class="error_list"><li>Too short. ('+minusernameCharacters+' characters minimum)</li></ul>');
    }
  }