/*===================================*\
|| ################################# ||
|| # Edit Attachment Filenames 3.0 # ||
|| ################################# ||
\*===================================*/

function edit_attachment_name(attachmentid)
{
	document.getElementById('attachment_filename_' + attachmentid).innerHTML = ''

	var handleSuccess = function(o){

		if(o.responseText !== undefined){
			fetch_object('attachment_filename_edit_' + attachmentid).innerHTML = o.responseText;
		}
	}
	var handleFailure = function(o){
		if(o.responseText !== undefined){
			alert(o.responseText);
		}
	}
	var callback =
	{
  		success: handleSuccess,
  		failure: handleFailure
	};

	var sUrl = 'ajax.php';
	var postData = 'do=edit_attachment_filename&attachmentid=' + attachmentid + '&securitytoken=' + SECURITYTOKEN;

	YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}

function save_attachment_name(save, attachmentid)
{
	attachment_name = document.getElementById('attachment_name_' + attachmentid)
	attachmentextension = document.getElementById('attachmentextension_' + attachmentid)

	var handleSuccess = function(o){

		if(o.responseText !== undefined){
			fetch_object('attachment_filename_' + attachmentid).innerHTML = o.responseText;
		}
	}
	var handleFailure = function(o){
		if(o.responseText !== undefined){
			alert(o.responseText);
		}
	}
	var callback =
	{
  		success: handleSuccess,
  		failure: handleFailure
	};

	var sUrl = 'ajax.php';
	var postData = 'do=save_attachment_filename&attachmentid=' + attachmentid + "&attachment_name=" + PHP.urlencode(attachment_name.value) + "&attachmentextension=" + attachmentextension.value + "&save=" + save + '&securitytoken=' + SECURITYTOKEN;

	YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
	document.getElementById('attachment_filename_edit_' + attachmentid).innerHTML = ''
}