function createRequestObject() {
    var ro;
    
    try{
	ro = new XMLHttpRequest();
    } catch (e){
	try{
            ro = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
	    try{
	        ro = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(e) {
		return false;
	    }
	}
    }
    
    return ro;
}
var http = createRequestObject();
function sndReq(action) {
  http.open('get', action);
  http.onreadystatechange = handleResponse;
  http.send(null);
}
function handleResponse() {
    if(http.readyState == 4) {
        document.getElementById('searchResultsDiv').innerHTML = http.responseText;
    }
}
function doSearch() {
    var val = '/inc/inc_search.php?search=' + document.getElementById('search').value;
    sndReq(val);
    return false;
}
function openWindow(url) {
  window.open(url,'popupWindow','resizable=no, scrollbars=yes, toolbar=no, status=no, height=650, width=720');
}
function expandOrClose(arrow_id, list_num, list_name)  {
	var a = document.getElementById(arrow_id);
	if(a.name=='d') {
		a.src='arrowRight.gif';
		a.name='r';
		hideSearchTypes(list_num,list_name);
	}
	else {
		a.src='arrowDown.gif';
		a.name='d';
		showSearchTypes(list_num,list_name);
	}
	return false;
}
function hideSearchTypes (i,j) {
	var theDiv = document.getElementById(j).getElementsByTagName('li');
	for(var d = 1; theDiv.length; d++) {
		var theID = 'res-'+i+'-'+d;
		document.getElementById(theID).style.display = 'none';
	}
}
function showSearchTypes (i,j) {
	var theDiv = document.getElementById(j).getElementsByTagName('li');
	for(var d = 1; theDiv.length; d++) {
		var theID = 'res-'+i+'-'+d;
			document.getElementById(theID).style.display = '';
	}
}
function setSearchField(val) {
    document.getElementById('search').value = val;
}
function submitSearch() {
    document.searchForm.submit();
}
