function create_new_album()
{
  // Get confirmation of the request
  var create = confirm( 'Would you like to create a new album?' );

  // Send the request if necessary
  if( create == true )
    window.location = "index.php?module=Photos&op=user_create_album";
}

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

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

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

  // 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_album_title();">';
    }
  }

}


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

  // Get the title from the input field
  var AlbumID = document.getElementById('AlbumID').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=" + AlbumID + "&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 = vc_Title;
      document.getElementById("ModuleTitle").innerHTML = vc_Title;
    }
  }

}


function edit_album_description()
{

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

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

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

  // 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: 200px;">' + xmlhttp.responseText + '</textarea><br/><input type="button" class="color" value="Save Album Description" onClick="save_album_description();">';
    }
  }

}



function save_album_description()
{

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

  // Get the title from the input field
  var AlbumID = document.getElementById('AlbumID').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=" + AlbumID + "&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 remove_album( pk_ID )
{
  var remove = confirm( 'Are you sure you want to remove this album?\n\nThis action can not be undone!\n\nAll images will be automatically moved to your unsorted folder.' )

  if( remove == true )
    window.location = "index.php?module=Photos&op=user_remove_album&albumID=" + pk_ID;
}

function increase_uploads()
{
  // First determine how many we currently have
  var uploads = document.getElementsByName('ary_Photo[]').length;

  // Add another to the list if we have less than 10
  if( uploads < 10 )
  {
    document.getElementById("upload_cell").innerHTML = document.getElementById("upload_cell").innerHTML + 'Upload image: <input type="file" name="ary_Photo[]" style="border: 1px solid #c0c0c0;" /> (<a href="#NULL" onclick="increase_uploads();">add another file</a>)<br/>';
  }
  else
  {
    alert( 'You may only send up to 10 files at a time' );
  }

}
