// Get the HTTP Object
function getHTTPObject()
{
	if (window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) 
		return new XMLHttpRequest();
	else
	{
		alert("Your browser does not support AJAX.");
		return null;
	}
}

/* Change the value of the outputText field
    * 0 = uninitialized
    * 1 = loading
    * 2 = loaded
    * 3 = interactive
    * 4 = complete
*/
function setOutput()
{
	if(httpObject.readyState == 4)
	{
		document.getElementById('output').innerHTML = httpObject.responseText;
		document.getElementById('outputButton').innerHTML = '<input type="button" value="Unhook" onclick="delClauseInfo()">';
		document.getElementById('outputButtonSearch').innerHTML = "";
	}
}

// Implement business logic
function genClauseInfo(clauseID)
{
	if (document.getElementById('outputButtonSearch')!=null)
		document.getElementById('outputButtonSearch').innerHTML = "";
	if (document.getElementById('outputID')!=null)
		document.getElementById('outputID').innerHTML = clauseID;
	if (document.getElementById('output')!=null)
		document.getElementById('output').innerHTML = "<img src=http://www.vietlaw.biz/blimages/loading.gif>";
	
	httpObject = getHTTPObject();
	if (httpObject != null)
	{
		httpObject.open("POST", "clause_related.php", true);
		httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpObject.onreadystatechange = setOutput;
		httpObject.send("clauseID=" + clauseID);
	}
}

function delClauseInfo()
{
	document.forms[0].txtRelation.value="";
	document.getElementById('outputID').innerHTML = "";
	document.getElementById('output').innerHTML = "";
	document.getElementById('outputButton').innerHTML = "";
	document.getElementById('outputButtonSearch').innerHTML = "<input type=button value=\"T&igrave;m &#273;i&#7873;u kho&#7843;n c&#7847;n gi&#7843;i th&iacute;ch\" onclick=\"modalWin('document_pane.php')\">";
}

var httpObject = null;
