function getXmlHttp() {
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
      xmlhttp = false;
    }
  }
 
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function addRaitingUser(id, type, hash) {

	var xmlHttp;
	xmlHttp = getXmlHttp();
  
	xmlHttp.onreadystatechange = function()  {
	    if (xmlHttp.readyState == "4") {

		var json = eval( "(" + xmlHttp.responseText + ")" );

		var sAlert = json.alert;
		var sRaiting = json.raiting;

		// скрываем и раскрываем рисунки
		if (type == "1") {
			document.getElementById("activeMinusSpan" + hash).style.display = "block";
			document.getElementById("passiveMinusSpan" + hash).style.display = "none";

			document.getElementById("activePlusSpan" + hash).style.display = "none";
			document.getElementById("passivePlusSpan" + hash).style.display = "block";
		}
		else {
			document.getElementById("activePlusSpan" + hash).style.display = "block";
			document.getElementById("passivePlusSpan" + hash).style.display = "none";

			document.getElementById("activeMinusSpan" + hash).style.display = "none";
			document.getElementById("passiveMinusSpan" + hash).style.display = "block";
		}

		// выводим сообщение
		if (sAlert != "") {
			alert(sAlert);
		}

		// выставления новый голос
		document.getElementById("userRat" + hash).innerHTML = sRaiting;


		}
		else {
			document.getElementById("activePlusSpan" + hash).style.display = "none";
			document.getElementById("passivePlusSpan" + hash).style.display = "block";

			document.getElementById("activeMinusSpan" + hash).style.display = "none";
			document.getElementById("passiveMinusSpan" + hash).style.display = "block";
		}
	}
  
  xmlHttp.open('GET', 'http://smiline.ru/addRaiting.php?user_id='+id+'&type='+type+'&rand='+Math.random(), true);
  xmlHttp.send(null);

}



function blogComFun(idRecord) {
	var xmlHttp;
	xmlHttp = getXmlHttp();
  
	xmlHttp.onreadystatechange = function()  {
	    if (xmlHttp.readyState == "4") {

		var json = eval( "(" + xmlHttp.responseText + ")" );

		var htmlTextNewComment = json.htmlTextNewComment;

		// выставления новый голос
		document.getElementById("blog_comments").innerHTML = document.getElementById("blog_comments").innerHTML + htmlTextNewComment;

		// пишем, что коммент успешно оставлен
		document.getElementById("idSpanCommentBlogRecord").innerHTML = '<br /><center><b style="color:green;">Комментарий к записе успешно оставлен!</b></center>';

		}
		else {
			// загружаемся
			document.getElementById("idSpanCommentBlogRecord").innerHTML = '<br /><center><b style="color:green;">Ждите! Гружусь ...</b></center>';
		}
	}

  textComment	=	document.getElementById("comments").value;
  xmlHttp.open('GET', '/commentBlog.php?idRecord='+idRecord+'&textComment='+textComment+'&rand='+Math.random(), true);
  xmlHttp.send(null);

}
