/*
 * The base class/namespace for all comment javascript functions
 */

var comment = function() {

};

comment.prototype = {

	post : function(_element) {
	
		var _author 	= $('#post_author').val();
		var _comment 	= $('#post_comment').val(); 
		var _type		= $('#post_media_type').val();
		var _id			= $('#post_media_id').val();
		
		if (_author == "" || _author == "Your Name"){
			alert("Please enter your name."); 
			return false;
		}
		
		if (_comment == "" || _comment == "Please leave a comment"){
			alert("Please enter a comment."); 
			return false;
		}
	
		$.ajax({
			type: "POST",
			url: "/scripts.php?script=post_comment",
			data: 	"author="+escape(_author)+"&comment="+escape(_comment)+'&type='+_type+'&id='+_id,
			success: function(html){
			//	alert(html);
				$('#'+_element).html(html);
			}
		});
	},
	
	report : function (_id) {
		$.ajax({
			type: "POST",
			url: "/scripts.php?script=report_comment",
			data: 	"id="+_id,
			success: function(html){
				alert("Thank you, the comment has been reported");
			}
		});
	}
	
};



/* instantiate a singleton of this class for use */
var comment = new comment();
