
var ajaxFile = "http://nsse.iub.edu/cms/ajax.cfm";


// ---------------------------------------------------------------------------------------------------------------------------------

function addComm(cID)
{
//	var cText = FCKeditorAPI.GetInstance('cText_'+cID).GetXHTML();
	var cText = document.getElementById('cText_'+cID).value;
	addComment(cID, cText, document.getElementById('cEmail_'+cID).value, document.getElementById('cName_'+cID).value, document.getElementById('cInstitution_'+cID).value);
}

function addComment(cID,cText,cEmail,cName,cInstitution)
{
	var cText = trim(cText);
	var tempurl = ajaxFile + "?action=addComment&comment_email="+cEmail+"&comment_text="+cText+"&content_id="+cID+"&comment_name="+cName+"&comment_institution="+cInstitution;
//	alert(tempurl);
	var aj = ajax('passive',tempurl,'');
	if (aj=="")
	{
//		alert('Your comment has been submitted, and will appear once it has been reviewed by a moderator.');
//		alert('Comment received.');

		document.getElementById('cText_'+cID).value = "";
		document.getElementById('cName_'+cID).value = "";
		document.getElementById('cEmail_'+cID).value = "";
		document.getElementById('cInstitution_'+cID).value = "";
	}
	else
	{
//		alert(aj);	
		document.getElementById('debug').innerHTML = (aj);
	}
	updateComments(cID);
}

function deleteComment(comID,cID)
{
	if (confirm("Are you sure you want to delete this comment?"))
	{
		var tempurl = ajaxFile + "?action=deleteComment&comment_id="+comID;
		ajax('passive',tempurl,'');
		updateComments(cID);
	}
}

function approveComment(comID,cID)
{
	if (confirm("Are you sure you want to approve this comment?"))
	{
		var tempurl = ajaxFile + "?action=approveComment&comment_id="+comID;
		ajax('passive',tempurl,'');
		updateComments(cID);
	}
}



function updateComments(cID)
{
	var tempurl = ajaxFile + "?action=getComments&content_id="+cID;
	var aj = ajax('passive',tempurl,'');
	document.getElementById("contentComments_"+cID).innerHTML = aj;
}

// ---------------------------------------------------------------------------------------------------------------------------------
