//this is a container script that will call the javascript to paint the authorsearch div, it will eventually be coded to make the search a bit less responsive DONE
//so it doesnt just pound the dbase
//this works by the userer making a search request and the reqid being stored as a javascript varibale, if the user makes another request before the first was processed,
//it will cancel the first and honor the second, maknig a search for a five letter word into 1 querry instead of 5, one for each letter,
//assuming the user can type faster than 1 letter per 500ms
var reqid = 0;
function aqs_wrapper(search_term) {

	if (reqid > 0) {
		clearTimeout(reqid);
	}
	
	if (search_term.length >= 2 ) {
		document.getElementById("authors_quick_search_results").style.display = "block";
		document.getElementById("page_quick_search_type").style.visibility = "hidden";
		//pull out single quotes, yeah, i know some 1337 haxor can get around this simple javascript check,
		//but, it will stop normal users from seeing javascript errors if they type a single qutoe
		//and plus, i check in the php down the road before it actually hits the dbase anyway
		//take that 'your 1337ness'
		search_term = search_term.replace(/'/g, '');
		document.getElementById("authors_quick_search_results").innerHTML = "<i>Searching for '"+search_term+"'.....</i>";
		//the request is made, the setimeout will executre the code in 500ms unless canceled
		reqid = setTimeout("xajax_quick_search('"+search_term+"')", 500);
	} else {
		document.getElementById("authors_quick_search_results").style.display = "none";
		document.getElementById("page_quick_search_type").style.visibility = "visible";
	}
}

//this will effectivly close the results div by passing an empty search term
//it uses a settimeout function to do it after 350ms
//this is done becouse when a user clicks on a link, the search box is blurred, and the link wont work, so it is closed after a delay
//this settiemout is canceled if a search is run in the meantime
//this happens when a user clicks on the feild and it has seomthing in it, 
function asb_close() {
	reqid = setTimeout("aqs_wrapper(' ')", 350);
}



