function now_init_fb()
{
	var url_str = "./includes/_ajax.fb_connect.module.php";
	var myRandom=parseInt(Math.random()*99999999);  // cache buster

	// alert(url_str + "?rand=" + myRandom);
	http.open("POST", url_str + "?rand=" + myRandom, true);
	http.onreadystatechange = handleHttpFBConnectResponse;
	http.send(null); //	*/
}

function init_fb()
{
	FB.XFBML.Host.parseDomTree();
}

function unsigned_fb()
{
}

function MemberTag(member_id)
{	
	var url_str = "../includes/_ajax.module.php?response=MEM_TAG&id="+member_id;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster

	// alert(url_str + "&rand=" + myRandom);
	http.open("POST", url_str + "&rand=" + myRandom, true);
	http.onreadystatechange = handleHttpSilentResponse;
	http.send(null);

}

function handleHttpFBConnectResponse() // response to member login from fb
{
	if (http.readyState == 4) 
	{
		// alert(http.responseText);
		results = http.responseText.split("~");

		flag = results[1];
		
		if(results[0])	//SUCCESFULL IN UPDATING
		{
			if(flag)
				window.location.reload();				
			else
				window.document.location.href='index.php';
		}
  	}
}

function ValidateComment(frm)
{
	var err=0;
	
	if(str_trim(frm.txtcomment.value) == "")
	{
		err_arr[err] = frm.txtcomment;
		err++;
	}

	if(err > 0)
	{
		err_arr[0].focus();
		return false;
	}
	
	var myRandom = parseInt(Math.random()*99999999);  // cache buster
	var url_str = "./includes/_ajax.module.php?rand=" + myRandom;
	var content = FormData2QueryString(frm);
	
	http.open("POST", url_str, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", content.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = handleHttpXFBMLResponse;
	http.send(content);
}

function handleHttpXFBMLResponse() 
{
	if (http.readyState == 4) 
	{
		// alert(http.responseText);
		results = http.responseText.split("~");

		str = results[1];
		div_nm = results[2];
		
		if(results[0] && document.getElementById(div_nm))	//SUCCESFULL IN UPDATING
		{
			document.getElementById(div_nm).innerHTML=str;
			FB.XFBML.Host.parseDomTree();
		}
  	}
}

function SetImageComments(id, flag)
{
	var url_str = "./includes/_ajax.module.php?response=COMMENT&id="+id+"&flag="+flag;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster

	// alert(url_str + "&rand=" + myRandom);
	http.open("POST", url_str + "&rand=" + myRandom, true);
	http.onreadystatechange = handleHttpXFBMLResponse;
	http.send(null); //	*/
}

function ReportAbuse(commentid)
{
	var url_str = "./includes/_ajax.module.php?response=REPORT_COMMENT&id="+commentid;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster

	// alert(url_str + "&rand=" + myRandom);
	http.open("POST", url_str + "&rand=" + myRandom, true);
	http.onreadystatechange = handleHttpSetResponse;
	http.send(null); //	*/
}