var http;

var gmode;

function handleHttpResponse_Contact()

{

	if (http.readyState == 4)

	{

      	isWorking = false;

    	if (http.responseText.indexOf('invalid') == -1)

		{

		  	var xmlDocument = http.responseXML;

			var addedflag = xmlDocument.getElementsByTagName('addedflag').item(0).firstChild.data;

			tb_remove();
			if(gmode == "AddMember")
			{

				if(addedflag == 2)

				{

					alert("Member has been added to your contacts.")

					return false;

				}

				else if(addedflag == 1)

				{

					alert("Member is already a contact.")

					return false;

				}

			}

			else if(gmode == "BlockMember")

			{

				if(addedflag == 0)

				{

					alert("Member Not Added In Contacts.");

					return false;

				}

				else if(addedflag == 1)

				{

					alert("Member Already Blocked.");

					return false;

				}

				else if(addedflag == 2)

				{

					alert("Member is blocked from your contact list");

					return false;

				}

			}

		}

  	}

}

function addtocontact(mode,intConatctMemberID)
{
	var conf=true;
	if(mode == "BlockMember")
	{
		conf = confirm("Are you sure you want to block this member?");
	}
	if(conf)
	{
		gmode = mode;

		openthickbox("Adding contact","http://addcontact.gif","");

		var url = "ajax/addContact_ajax.php?mode="+mode+"&intConatctMemberID="+intConatctMemberID;
		//alert(url);return false;
		var isWorking = false;
		if (!isWorking)

		{

			isWorking = true;

			if (window.XMLHttpRequest)

		  	{

		  		http=new XMLHttpRequest()

		  		http.open("GET",url, true);

			  	http.onreadystatechange=handleHttpResponse_Contact

			  	http.send(null)

		  	}

			// code for IE

			else if (window.ActiveXObject)

		  	{

		  		http=new ActiveXObject("Microsoft.XMLHTTP")

		    	if (http)

		    	{

		    		http.open("GET",url, true);

		    		http.onreadystatechange=handleHttpResponse_Contact

		    		http.send()

		    	}

		  	}

	  	}
	}
}




