function Content() {};

function Comment() {};

Content.deleteChildContent = function (id) {
//	$.getJSON()

    var data = {};
	
	data.contentId = id;
	data.responseType = 1; // json

    $.getJSON('/content/delete/process', data, function(r) {
        if (Six.ajax.isError(r)) {
            Dialog.show('There was a problem deleting this content. Please try again later.');
        }
		$('[contentid="'+id+'"][ischildcontent="true"]').slideUp();
    });
};

Content.deleteParentContent = function(id){

    if(confirm('Are you sure you want to delete this content?'))
	{
		window.location = '/content/delete/process?contentId='+id+'&responseType=3';
	}
    return
}

Content.contentId = null;

Content.editPopup = function (name) {
	
	var data = {};
	data.content = name;
    $.getJSON('/content/edit/popup', data, function (r) {
        $('body').append(r.data);
        
        $('#edit-content').dialog({
        	modal: true, 
        	draggable: false,
        	resizable: false,
        	height: 200,
        	width: 400,
        	title: 'Edit Reply'
        });
        $('#edit-content').dialog('open');
    	$('#edit-content').find('.save').bind('click', Content.submitEditPopup);
    	
    	$('#edit-content').find('.cancel').bind('click', function(e) {
    		e.preventDefault();
    		$('#edit-content').remove();
    	});	
    });
	
	
}


Content.submitEditPopup = function (e) {
	e.preventDefault();
	
	var data = {};
	
	data.body = $('#edit-content').find('textarea').val();
	data.content = $('#edit-content').attr('contentname');
	data.responseType = 1;
	
	$.getJSON('/content/edit/process', data, function (r){
		if (r.status){
			$('#edit-content').remove();
			
			$('.reply[contentid="'+ r.data.id +'"]').find('.body')
				.html(r.data.body);
		}
		else {
			$('#edit-content').remove();
			Dialog.show('There was a problem with your request. Please try again later.', Dialog.ERROR)
		}
	});	
};

Content.deleteAttachment = function(id) {
	var conf = confirm('Deleting attachments is permanent, it will be lost forever!');
	if (conf) {
		var data = {};
		data.id = id;
		$.getJSON('/services/content/delete', data, function (r){
			if (r.status){
				$('#attachmentRow' + r.data.id).remove();
			}
			else {
				Dialog.show('There was a problem with your request. Please try again later.', Dialog.ERROR)
			}
		});	
	}
};
