
// ----- WARNING ----- \\
// COPYRIGHTED CONTENT \\
//  COPYRIGHT © NERVA  \\
//   nerva@nerva.ee    \\
// All rights reserved \\
// ------------------- \\

function showComments(returnid, articleid, deletecomment) {
	// All parameters are optional. See comments.php/directcall_comments for details.
	if (returnid != null) {
		unhide(document.getElementById("commentstitlerow_" + returnid));
		unhide(document.getElementById("commentscontentrow_" + returnid));
		hide(document.getElementById("commentsbutton_" + returnid));
		hide_comments_candies(returnid);
	  }
	var q = root + "content/direct.php?&call=content/article/comments|comments&langid=" + langid;
	if (returnid != null) q += "&returnid=" + returnid;
	if (articleid != null) q += "&articleid=" + articleid;
	if (deletecomment != null) q += "&deletecomment=" + deletecomment;
	loadcontent(q, comments_callback);
  }

function comments_callback(content) {
	if (content.substr(0, 6) == 'ERROR:') {
    alert(getString("error") + ": " + content.substr(6));
	  }
	else {
		var i = content.indexOf(":");
		if (i > 0) {
			var e = document.getElementById("commentscontent_" + content.substr(0, i));
			if (e != null) e.innerHTML = content.substr(i + 1);
			}
		}
  }

// \'mb_showcomments("'.$a['mbindex'].'", "'.$a['contentid'].'")\'

var comments_candies_series = 0;
var comments_candies_showing = false;
var comments_candies_disabled = false;

function show_comments_candies() {
	if (comments_candies_disabled) return;
	var i, pos;
	comments_candies_series++;
	for (i = 1; i <= last_mbindex; i++) {
		o = document.getElementById("articlecommentstitle_" + i);
		if (o != null) {
			pos = get_object_pos(o); // returns rect(left, top, width, height)
			addhtml('<img id="comments_candies_' + comments_candies_series + '_' + i + '" src="' + root + 'content/mb/images/button/candies_' + langid + '.png"' + 'class="comments_candies" style="left: ' + (pos[0] - 40) + 'px; top: ' + (pos[1] - 55) + 'px;" onmouseover="hide_comments_candies(' + i + ');" />');
		  }
	  }
  }

function show_comments_candies_soon() {
	if (comments_candies_showing) return;
	comments_candies_showing = true;
	setTimeout("show_comments_candies();", 5000);
  }

function _hide_comments_candies(mbindex) {
	var i;
	for (i = 1; i <= comments_candies_series; i++) {
	  o = document.getElementById('comments_candies_' + i + '_' + mbindex);
	  if (o != null) o.className = 'hidden';
	  }
  }

function hide_comments_candies(optional_mbindex) { // if you want to hide all, omit mbindex or set to 0
	if ((optional_mbindex != null) && (optional_mbindex > 0)) {
		_hide_comments_candies(optional_mbindex);
		return;
	  }
	var i;
	for (i = 1; i <= last_mbindex; i++) {
		_hide_comments_candies(i);
	  }
  }
	
function disable_comments_candies() {
	hide_comments_candies();
	comments_candies_disabled = true;
  }

