function getAjax()
{
	var xmlHttp;
	try
	{
		 // Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
	catch (e)
	 {
			// Internet Explorer
			try
  			{
  				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  			}
			catch (e)
 			 {
				  try
 				   {
 					   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  				  }
				  catch (e)
 				   {
   					 return false; //No AJAX !
				    }
			  }
	 }

	return xmlHttp;
}

function getCommentHtml(id)
{
	var xmlHttp = getAjax();

	xmlHttp.open("GET", "index.php?comments_popup="+id, true);

	xmlHttp.onreadystatechange=function() //EVENT
		{
			if(xmlHttp.readyState==4)
				{
					// Get the data from the server's response
				document.getElementById("comments-"+id).innerHTML =  xmlHttp.responseText;
				
				}
		} //END OF EVENT

	xmlHttp.send(null);
}

function comments (id)
{
	if (document.getElementById("comments-"+id).style.display != "block"){
		document.getElementById("comments-"+id).style.display = "block";

		getCommentHtml(id); //Asynchronous !
	}else{
		document.getElementById("comments-"+id).style.display = "none";
		document.getElementById("comments-"+id).innerHTML = '<img src = "wp-content/themes/sunburn-10/sunburn-10/images/spinner.gif" class = "loading">';
	}
}

