// JavaScript Document

function searchproperty(action)
{
	var queryString = "?pname=" + document.getElementById('txtsearch').value;	
	
	var ajaxRequest; // The variable that makes Ajax possible!
	try{
	ajaxRequest = new XMLHttpRequest();
	} catch (e){
	try{
	ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try{
	ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e){
	// Something went wrong
	alert("Your browser broke!");
	return false;
	}
	}
	}
	
	
	var ajaxDisplay = document.getElementById('searchresult');	
	// Function to receive data sent from the server and update div's
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ajaxRequest.responseText != '' && action == 'search')
			{
				ajaxDisplay.innerHTML = ajaxRequest.responseText;	
			}
			if( document.getElementById('txtsearch').value	 == '')
			{
				ajaxDisplay.innerHTML ='';
			}
			if(action == 'clear')
			{
				ajaxDisplay.innerHTML ='';
			}
			
		}
	}
	

		ajaxRequest.open("GET", "../../../../getproperty5.php" + queryString, true);
		ajaxRequest.send(null); 
		return true;

}