function MenuCommBuild_p( m_id, name, profile ){

var menu=new Array();

menu[0]='<a onclick="ajax_comm_edit_p(\'' + m_id + '\', \'' + profile + '\'); return false;" href="#">' + menu_short + '</a>';
menu[1]='<a href="' + dle_root + '?subaction=userinfo&user=' + name + '&actp=comments&action=comm_edit&id=' + m_id + '&profile_id=' + profile + '">' + menu_full + '</a>';

return menu;
};

function ajax_comm_edit_p( c_id, c_profile )
{
	if ( ! c_cache[ c_id ] || c_cache[ c_id ] == '' )
	{
		c_cache[ c_id ] = document.getElementById( 'comm-id-'+c_id ).innerHTML;
	}

	var ajax = new dle_ajax();
	comm_id = c_id;
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("id", c_id);
	ajax.setVar("profile_id", c_profile);
	ajax.setVar("action", "edit");
	ajax.requestFile = dle_root + "engine/ajax/profile_com/editcomments.php";
	ajax.method = 'GET';
	ajax.element = 'comm-id-'+c_id;
	ajax.execute = true;
	ajax.onCompletion = whenCompletedCommentsEdit;
	ajax.sendAJAX(varsString);
	return false;
};

function ajax_save_comm_edit_p( c_id, c_profile )
{
	var ajax = new dle_ajax();
	var comm_txt = '';

	comm_edit_id = c_id;
	ajax.onShow ('');

	if (dle_wysiwyg == "yes") {

		comm_txt = ajax.encodeVAR( tinyMCE.get('dleeditcomments'+c_id).getContent() );

	} else {

		comm_txt = ajax.encodeVAR( document.getElementById('dleeditcomments'+c_id).value );

	}

	var varsString = "comm_txt=" + comm_txt;

	ajax.setVar("id", c_id);
	ajax.setVar("profile_id", c_profile);
	ajax.setVar("action", "save");
	ajax.requestFile = dle_root + "engine/ajax/profile_com/editcomments.php";
	ajax.method = 'POST';
	ajax.element = 'comm-id-'+c_id;
	ajax.onCompletion = whenCompletedSaveComments;
	ajax.sendAJAX(varsString);

	return false;
};


function doAddComments_Profile(){

	var form = document.getElementById('dle-comments-form');
    	var dle_comments_ajax = new dle_ajax();

	if (dle_wysiwyg == "yes") {
		document.getElementById('comments').value = tinyMCE.get('comments').getContent();
		dle_comments_ajax.setVar("editor_mode", 'wysiwyg');
	} 

	if (form.comments.value == '' || form.name.value == '')
	{
		alert ( dle_req_field );
		return false;
	}

	dle_comments_ajax.onShow ('');
	var varsString = "profile=" + form.profile.value;

	dle_comments_ajax.setVar("comments", dle_comments_ajax.encodeVAR(form.comments.value));
	dle_comments_ajax.setVar("name", dle_comments_ajax.encodeVAR(form.name.value));
	dle_comments_ajax.setVar("mail", dle_comments_ajax.encodeVAR(form.mail.value));
	dle_comments_ajax.setVar("skin", dle_skin);

	if ( form.sec_code ) {

	   dle_comments_ajax.setVar("sec_code", form.sec_code.value);

    }

	dle_comments_ajax.requestFile = dle_root + "engine/ajax/profile_com/addcomments.php";
	dle_comments_ajax.method = 'POST';
	dle_comments_ajax.element = 'dle-ajax-comments';
	dle_comments_ajax.sendAJAX(varsString);
};
