$(document).ready(function(){
	$('#profile_comment').submit(function() {
		if($('form textarea').val() == ""){
			Boxy.alert("You can't post blank comments...", null, {title: 'Ooops!'});
			return false;
		}

		if($(':input[name=user]').val() == ""){
			Boxy.alert("Please <a href=\"/\">login to post comments</a>", null, {title: 'Login'});
			return false;
		}
			
		$.ajax({
		    url: this.getAttribute('action'),
			data: $(this).serialize(),
		    type: 'POST',
		    dataType: 'html',
		    timeout: 5000,
		    error: function(XMLHttpRequest, textStatus, errorThrown){
    			Boxy.alert("A problem occurred. "+textStatus, null, {title: 'Ooops!'});
		    },
		    success: function(j){
				$(":input[name=comment]").val("");
				//$("#comment_box").append(j);
				$(".mirror_p").append(j);
		    }
		});
		return false;
	});
	
	
	
	$('.del_comment').live('mouseover mouseout', function(event) {
	  if (event.type == 'mouseover') {
	    $(this).css('cursor', 'pointer');
	  } else {
	    $(this).css('cursor', 'hand');
	  }
	});
	
	
	
	$('.del_comment').live('click',function(){
		$span = $(this);
		if(confirm('Are you sure you want to delete this comment?')){
			$.ajax({
			    url: 'controller/comment/delete.php',
				data: {id : $span.attr('id')},
			    type: 'POST',
			    dataType: 'html',
			    timeout: 1000,
			    error: function(){
			        alert('We had a problem');
			    },
			    success: function(j){
					$span.parent().parent().animate({	
					//$span.parents('.comment').animate({
						opacity: 0.25,
						'background-color': '#E6E6E6'
					},700,function(){
						$(this).remove();
					});

			    }
			});			
		}
		
	})
	
	
	
	
});






