var httpRequest = false;

function nop() {
	}

function searchExtended() {
	document.getElementById("alphaTable").style.display='none';
	if(document.getElementById("extendedPeopleSearchTerm").value=='')
		document.getElementById("alphaTable").style.display='inline';
		
	var poststr = "peopleSearchTerm=" + encodeURI( document.getElementById('extendedPeopleSearchTerm').value );
	makeRequest('/our_staff/people_search.php?extended', poststr, false );
}

function peopleSearch() {
	var poststr = "peopleSearchTerm=" + encodeURI( document.getElementById('shortPeopleSearchTerm').value );
	makeRequest('/our_staff/people_search.php', poststr, true);
}

function makeRequest( url, parameters, s ) {
	 if(s)
		ajax(url, parameters, document.getElementById( "shortSearchResults" ) );
	else
		ajax(url, parameters, document.getElementById( "extendedSearchResults" ) );
}

var xhr = window.XMLHttpRequest;

function ajax(url, vars, object) {
		
		if (xhr)
		  var http = new XMLHttpRequest();
		else
		  var http = new ActiveXObject("MSXML2.XMLHTTP.3.0");
 
        http.open("POST", url, true);
        http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 

        http.onreadystatechange = function(){

                if (http.readyState == 4 && http.status == 200) {

                        if (http.responseText){
                                object.innerHTML = http.responseText;
                        }
                }
        }
        http.send(vars);
}


function updateSearch( el ) {

    if (http_req.readyState == 4) {
        if (http_req.status == 200) {
			var results = document.getElementById( "shortSearchResults" );
			results.innerHTML = http_req.responseText;
        }
    }
}
