// JavaScript Document
var show_div = 0;

function LoadSearch(force) {

	var query = '' + document.getElementById('substring_id').value;
	var req = new Subsys_JsHttpRequest_Js();
	var txt = '';

	req.onreadystatechange = function() {
		
		if (req.readyState == 4) {

    		if (req.responseJS[0]) {
    	        txt = '<TABLE border=0 cellpadding=0 cellspacing=0 width="100%">';
				for (i=0; i<req.responseJS.length; i++) {
					txt += "<TR class='ajaxSearch' style='cursor: pointer;' onMouseOver='this.className=\"ajaxSearchSelected\";' onMouseOut='this.className=\"ajaxSearch\";' id='sear_" + i + "' onClick='javascript:self.location=\"" + req.responseJS[i]['link'] +"\"'>";
					txt += "<TD class='ajaxSearchText' width='100%'>" + req.responseJS[i]['product'] + "</TD></TR>\n";
				}
				txt += '</TABLE>';
				document.getElementById('result_str').innerHTML = txt;
				document.getElementById('result_str').style.visibility = '';
    	    }
			else {
				document.getElementById('result_str').innerHTML = '';
				document.getElementById('result_str').style.visibility = 'hidden';
			}
		}
	}

	req.caching = false;
	req.open('GET', 'ajax_search.php', true);
	req.send({quest: query});
}

var timeout = null;
function doLoadSearch() {
	if (document.getElementById('substring_id').value != '') {
		if (timeout) clearTimeout(timeout);
    	timeout = setTimeout(LoadSearch, 200);
	}
	else
	{
		document.getElementById('result_str').innerHTML = '';
		document.getElementById('result_str').style.visibility = 'hidden';
	}
}