// JavaScript Document

function handleHttpResponseFlagBlog() {
  if (httpFlagBlog.readyState < 4) {
	document.getElementById('sendFlagBlogContainer').innerHTML = "<p><img src='../images/misc/loader.gif'></p>";
  }
  if (httpFlagBlog.readyState == 4) {
    if (httpFlagBlog.responseText.indexOf('invalid') == -1) {
      // Use the XML DOM to unpack the info
      //var xmlDocument = http.responseXML; 
     // var bdump = xmlDocument.getElementsByTagName('blog').item(0).firstChild.data;
	 // bdump = bdump.replace(/\n/, '<br />');
	  //bdump = bdump.replace(/\n/g, '<br />');
	  //alert (bdump);
	  document.getElementById('sendFlagBlogContainer').innerHTML = httpFlagBlog.responseText;
      isWorking = false;
    }
  }
}

var isWorking = false;

function doFlagBlog(bid) {
	var url = "/blogs/ajax/flagblog.php";	// The server-side script
//	var url = "ajax/flagblog.php";	// The local-side script
	
	var flagcomment = document.getElementById('flagComment').value;

	  if (!isWorking && httpFlagBlog) {
		var param = "bid=" + bid + "&flagcomment=" + flagcomment;
		
	    httpFlagBlog.open("POST", url, true);
	    httpFlagBlog.onreadystatechange = handleHttpResponseFlagBlog;
		httpFlagBlog.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    isWorking = true;
	    httpFlagBlog.send(param);
	  }
}


function getHTTPObjectFlagBlog() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var httpFlagBlog = getHTTPObjectFlagBlog(); // We create the HTTP Object
