// JavaScript Document

function hideComments(id){
	$("#student_comments_"+id).hide();
	$("#link_comment_"+id).html('<a href="#Comment" onclick="activityComments('+id+');">Comments</a>');
}

function hideActivityComments(id){
	//alert(id);return false;
	$("#student_comments_"+id).hide();
}

function activityComments(id){
	//alert("ok");
	$("#student_comments_"+id).show();
	$.ajax({
	  url: "ajax_student_home.php?isajax=1&activity_id="+id,
	  cache: false,
	  success: function(data){
		 $("#student_comments_"+id).html(data);
	}});
	$("#link_comment_"+id).html('<a href="#Comment" onclick="hideComments('+id+');">Comments</a>');
	//alert("ok");
}

function addActivityComment(id){
	//alert('ok');return false;
	var desc = $("#add_comment_"+id).val();
	if(desc == ''){
		return false;
	}
	desc = desc.replace(/^\s+|\s+$/g,"");
	//alert(desc);
	$.post("ajax_student_home.php?isajax=2", {description: desc, activity_id: id} , function(data){
	activityComments(id);
	});
	
}

function deleteActivityComment(cid,id){
	//alert(cid);return false;
	$.ajax({
	  url: "ajax_student_home.php?isajax=3&comment_id="+cid,
	  cache: false,
	  success: function(data){
		 	
	}});
	activityComments(id);
}

