/* _________________________________________________________________________________________________________________________________________
	
	DESCRIPTION: 	This is a generic AJAX script. There are 3 variables required when calling this script:
					PHPfile       = The PHP file to call
					fileVariables = Any additional variables required by the PHP file (leave off the "?")
					target        = The div ID on the calling page that will recieve the result from the called PHP

	EXAMPLE: 		Place this code in the header:
						<script type="text/javascript" src="../js/x_generic.js"></script>
						
						<script language="JavaScript">
								runFunction('test.php', 'var1=1&var2=2&var3=3', 'result');
						</script>
						
					Place this code in the body:
						<div id='result'></div>
	
	AUTHOR:			Original code by Tom Arenberg
  __________________________________________________________________________________________________________________________________________ */

var xmlHttp

function runFunction(PHPfile, fileVariables, target) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url=PHPfile
	url=url+"?sid="+Math.random()
	url=url+"&" + fileVariables
//alert("x_search. js URL = " + url)
	xmlHttp.onreadystatechange=stateChangedMake 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedMake() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var txt = xmlHttp.responseText;
		if (txt !== "") {
			document.getElementById('result').innerHTML = txt;
		}else{
alert("HERE" + txt);
			document.getElementById('result').style.visibility = 'hidden';
		}
	} 
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e) {
 		//Internet Explorer
 		try {
  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  	}
	catch (e) {
  	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;

}




