var show_div = 0;



function LoadSearch(force) {

	   var forsearch = document.getElementById("substring_id");

       var insearch = forsearch.value.split(" ").join("");	
	   
	   if (insearch != "")
		{
				
			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 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});
	
	}
	
	else {
		document.getElementById("substring_id").value = "";
		
		}
}

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';
	}
}

function check_valid()
{
	
	if(document.getElementById('substring_id').value=='')
	{
		alert("Please Enter Search Keyword");
		return false;
	}
	else
	{

		document.productsearchform.submit();
		return true;
	}
}