function ToggleAccountSetting( id, setting )
{

  // Switch the appropriate id the appropriate setting
  if( setting == 'on' )
  {
    document.getElementById( 'AccountSetting_' + id + '_link' ).innerHTML = '<a href="#NULL" onclick="ToggleAccountSetting( \'' + id  + '\', \'off\' );">hide</a>';
    document.getElementById( 'AccountSetting_' + id + '_off' ).style.display = 'none';
    document.getElementById( 'AccountSetting_' + id + '_on' ).style.display = 'block';
  }
  else if( setting == 'off' )
  {
    document.getElementById( 'AccountSetting_' + id + '_link' ).innerHTML = '<a href="#NULL" onclick="ToggleAccountSetting( \'' + id  + '\', \'on\' );">change</a>';
    document.getElementById( 'AccountSetting_' + id + '_off' ).style.display = 'block';
    document.getElementById( 'AccountSetting_' + id + '_on' ).style.display = 'none';
  }

}

function account_save_status()
{

  // Start by getting the message body
  // and only process the request if the message body is not null
  var txt_Status = document.getElementById('UserStatusInput').value.replace( /&/g, '%26' );

  if( txt_Status != '' )
  {

    // Disable the text field
    document.getElementById( 'UserStatusInput' ).readOnly = true;
    document.getElementById( 'UserStatusInput' ).backgroundColor = '#cccccc';

    // Set the backend filename to process
    var filename = 'modules/Account/ajax_status_save.php';

    // Create the parameter list
    var params = "txt_Status=" + txt_Status;

    // Process the AJAX POST request
    AJAX_POST( filename, params );

    // Update the form when the AJAX process finishes
    xmlhttp.onreadystatechange = function()
    {
      if( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) )
      {
        // Create the new DIV section node
        var newDiv = document.createElement("DIV");
  
        // Fix the properties of the new div
        newDiv.innerHTML = xmlhttp.responseText;

        // Append the new element to the document
        document.getElementById( 'UserStatus' ).appendChild(newDiv);

        // Once the div layer has been appended, we want to make the input field
        // useful for writing once again
        document.getElementById( 'UserStatusInput' ).readOnly = false;
        document.getElementById( 'UserStatusInput' ).backgroundColor = '#ffffff';
        document.getElementById( 'UserStatusInput' ).value = '';

      }
    }

  } // end if txt_Status != ''

} // end function account_save_status()


function account_status_remove( StatusID )
{
  // Set the backend filename to process
  var filename = 'modules/Account/ajax_status_remove.php';

  // Create the parameter list
  var params = "fk_StatusID=" + StatusID;

  // Process the AJAX POST request
  AJAX_POST( filename, params );

  // Update the form when the AJAX process finishes
  xmlhttp.onreadystatechange = function()
  {
    if( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) )
    {
      // Append the new element to the document
      document.getElementById( 'StatusUpdate_' + StatusID ).style.display = 'none';
    }
  }

} // end function account_status_remove()


function account_update_name()
{

  var vc_FirstName = document.getElementById( 'AVI_vc_FirstName' ).value;
  var vc_LastName = document.getElementById( 'AVI_vc_LastName' ).value;

  var vc_FirstInitial = vc_FirstName.charAt(0);
  var vc_LastInitial = vc_LastName.charAt(0);
  
  document.getElementById( 'vc_PrivacyName01' ).innerHTML = vc_FirstName + ' ' + vc_LastName;
  document.getElementById( 'vc_PrivacyName02' ).innerHTML = vc_FirstInitial + '. ' + vc_LastName;
  document.getElementById( 'vc_PrivacyName03' ).innerHTML = vc_FirstName + ' ' + vc_LastInitial + '.';

}
