var profileCommentDialog			= null;
var lastCommentID					= 0;
var profileCommentSubmitMode		= 0;		// 0=LOAD DIALOG, 1=REFRESH VIDEO COMMENTS
var lastProfileUserID				= 0;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doProfileCommentDialog(userID) {
	if (profileCommentDialog != null) {
	return;
	}
var url								= "/clientServer/?section=ProfileCommentDialog&userID=" + userID;
profileCommentDialog				= document.createElement('DIV');
profileCommentSubmitMode			= 0;
lastProfileUserID					= userID;
handleGetComplete					= 'handleProfileCommentGetComplete';
handleDialogClose					= 'closeProfileCommentDialog';
doAjaxPopup('commonDialogLong',profileCommentDialog,url,500,400);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function closeProfileCommentDialog() {
closeAjaxPopup(profileCommentDialog);
profileCommentDialog				= null;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function submitProfileCommentForm(formObj) {
var F1								= formObj.COMMENTS;

	if (F1.value.length == 0) {
	alert('Please enter some comments before proceeding.');
	F1.focus();
	return;
	}
	
var userID							= formObj.userID.value;
var comments						= encodeURIComponent(F1.value);
var params							= "section=ProfileCommentDialog&DOFORM=1&userID="+userID+"&comments="+comments;
showLoadingMessage();
handlePostComplete					= 'handleProfileCommentPostComplete';
postAjaxContent('/clientServer/',params);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function handleProfileCommentGetComplete(success,xmlHTTP) {
	switch (profileCommentSubmitMode) {
	case 0:
	responseContainer.innerHTML		= xmlHTTP.responseText;
	break;
	case 1:
	var container					= document.getElementById('profileCommentsPane');
		if (container) {
		container.innerHTML			= xmlHTTP.responseText;
		}
	break;
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function refreshProfileComments() {
profileCommentSubmitMode			= 1;
getAjaxContent("/clientServer/?section=ProfileComments&userID="+lastProfileUserID);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function handleProfileCommentPostComplete(success,xmlHTTP) {
var response						= xmlHTTP.responseText;
	if (response == "SUCCESS=1") {
	closeProfileCommentDialog();
	refreshProfileComments();
	} else {
		if(responseContainer!=null) {
		responseContainer.innerHTML	= xmlHTTP.responseText;
		}
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function deleteProfileComment(CID, USERNAME){
var confirmed						= confirm("Are you sure you wish to delete this Profile comment?");
	if (confirmed) {
	document.location.href			= ("/users/"+USERNAME+"/?ACTION=DELETECOMMENT&CID="+CID);
	}
}

