
function deleteImage(id){

			new Ajax.Request('./tools_php/all.php', {
			   method: 'get',
			   parameters: 'fuse=deleteImage&id='+id,
			   onSuccess: function(transport) {
			      if(transport.responseText == 'error'){
			         alert('There was an error.');
			      }else{
			         alert(transport.responseText);
            new Effect.Fade('img_'+id);
         }
      },
      onFailure: function(){
         alert('There was an error.');
      }
			});


}

function saveTitle(id,title){

			new Ajax.Request('./tools_php/all.php', {
			   method: 'get',
			   parameters: 'fuse=saveTitle&id='+id+'&newTitle='+title,
			   onSuccess: function(transport) {
         //alert('Title Saved');
      },
      onFailure: function(){
         alert('There was an error.');
      }
			});
}

function addTag(id){
	
	$('addTagBtn').disabled=true;
	$('addTagBtn').update('SAVING TAGS!');
	
	tags = $('newTag').value;
	new Ajax.Request('/tools_php/all.php', {
		method: 'get',
		parameters: 'fuse=addTags&id='+id+'&tags='+tags,
		onSuccess: function(transport) {
			$('addTagBtn').disabled=false;
			$('addTagBtn').update('ADD TAG');
			$('tagList').innerHTML = transport.responseText;
			$('newTag').value='';
		},
		onFailure: function(){
			alert('There was an error.');
		}
	});
}

function removeTag(id,img_id){
   new Ajax.Request('/tools_php/all.php', {
			   method: 'get',
			   parameters: 'fuse=removeTag&id='+id+'&img_id='+img_id,
			   onSuccess: function(transport) {
         $('tagList').innerHTML = transport.responseText;
      },
      onFailure: function(){
         alert('There was an error.');
      }
			});
}

function editTextTitle(){
   if($('editButton').innerHTML == 'edit'){
      $('textTitle').focus();
      $('editButton').innerHTML = 'save';
   }else{
      $('textTitle').blur();
      $('editButton').innerHTML = 'edit';
   }
}

comments = {
	
	add: function(){
		
		$('save_comment').disabled = true;
		
		var fdata = $('comment_form').down().serialize();
		
		new Ajax.Request('/tools_php/comments.php',{
			parameters: 'fuse=add&'+fdata,
			method: 'post',
			onSuccess: function(t){
				$('comment_form').insert( { 'before': t.responseText } );
				if($('be_first')){ $('be_first').remove(); }
				$('save_comment').disabled = false;
				$$('#comment_form input').each(function(s){s.value = '';})
				$$('#comment_form textarea').each(function(s){s.value = '';})
			}
		})
		
	}
	
}


