function edit_photo_title()
{
  // Set the backend filename to process
  var filename = 'modules/Photos/ajax_edit_photo_title.php';

  // Get the title from the input field
  var PhotoID = document.getElementById('PhotoID').value;

  // Create the parameter list
  var params = "pk_ID=" + PhotoID;

  // 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) )
    {
      document.getElementById("vc_Title_cell").innerHTML = '<input type="text" id="vc_Title" class="text" size="40" value="' + xmlhttp.responseText + '"> <input type="button" class="color" value="Save Title" onClick="save_photo_title();">';
    }
  }

}


function save_photo_title()
{
  // Set the backend filename to process
  var filename = 'modules/Photos/ajax_save_photo_title.php';

  // Get the title from the input field
  var PhotoID = document.getElementById('PhotoID').value;
  var vc_Title = document.getElementById('vc_Title').value;

  // Format any ampersands with URL friendly characters
  var vc_Title_safe = vc_Title.replace( /&/g, '%26' );

  // Create the parameter list
  var params = "pk_ID=" + PhotoID + "&vc_Title=" + vc_Title_safe; 

  // 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) )
    {
      document.getElementById("vc_Title_cell").innerHTML = '<strong>' + vc_Title + '</strong>';
    }
  }

}


function edit_photo_description()
{

  // Set the backend filename to process
  var filename = 'modules/Photos/ajax_edit_photo_description.php';

  // Get the photo ID being edited
  var PhotoID = document.getElementById('PhotoID').value;

  // Create the parameter list
  var params = "pk_ID=" + PhotoID;

  // 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) )
    {
      document.getElementById("txt_Description_cell").innerHTML = '<textarea id="txt_Description" style="width: 425px; height: 100px;">' + xmlhttp.responseText + '</textarea><br/> <input type="button" class="color" value="Save Description" onClick="save_photo_description();">';
    }
  }

}


function save_photo_description()
{

  // Set the backend filename to process
  var filename = 'modules/Photos/ajax_save_photo_description.php';

  // Get the photo ID being edited
  var PhotoID = document.getElementById('PhotoID').value;
  var txt_Description = document.getElementById('txt_Description').value;

  // Format any ampersands with URL friendly characters
  txt_Description = txt_Description.replace( /&/g, '%26' );

  // Create the parameter list
  var params = "pk_ID=" + PhotoID + "&txt_Description=" + txt_Description;

  // 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) )
    {
      document.getElementById("txt_Description_cell").innerHTML = xmlhttp.responseText;
    }
  }

}



function rotatePhoto( orientation, image_filename )
{

  // Set the backend filename to process
  var filename = 'modules/Photos/ajax_rotate_photo.php';

  // Get the photoID and albumID
  var photoID = document.getElementById('PhotoID').value;
  var albumID = document.getElementById('AlbumID').value;

  // Create the parameter list
  var params = "albumID=" + albumID + "&photoID=" + photoID + "&orientation=" + orientation;

  // 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) )
    {
      // In order to ensure that the photo reloads in the browser
      // we need to pass a parameter to the image src
      var now = new Date();
      document.getElementById('myImg').src = image_filename + '?' + now.getTime();
    }
  }

}

