/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();

/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function autosuggest() {
q = document.getElementById('strSub').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'jscripts/search_lib/vnet_search.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggestReply() {
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results');
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

function autosuggest_p_add() {
q = document.getElementById('strSuburb').value;
strErf = document.getElementById('strErf').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'jscripts/search_lib/vnet_search_property.php?q='+q+'&strErf='+strErf+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply_p_add;
http.send(null);
}
function autosuggestReply_p_add() {
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results_p_add');
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

function autosuggest_body() {
q = document.getElementById('strSub').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'jscripts/search_lib/vnet_search.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestResults_body;
http.send(null);
}
function autosuggestResults_body() {
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results_body');
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

function autosuggest_srv() {
q = document.getElementById('srv_area').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'jscripts/search_lib/srv_search.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply_srv;
http.send(null);
}

function autosuggestReply_srv() {
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results_srv');
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

