function livesearch(e,key){
	if (e.keyCode == 13) key.form.submit();
	if (key.value.length > 2) AjaxPost('limit=10&keyword='+key.value, "index2.php?no_html=1&option=com_owgenajax&gaf=vm_livesearch", function(txt){
		document.getElementById('searchresults').innerHTML = txt;
		document.onclick = function(e){
			document.onclick=null;
			document.getElementById('searchresults').innerHTML = '';
		}	
	});
	function AjaxPost(req, url, callback) {
		var A = Ajax();                                 
		if (A) {
			A.onreadystatechange = function(){
				if ((A.readyState==4 || A.readyState=="complete") && A.status == '200') {
					callback(A.responseText);
					A = null;
				}
			}
			A.open('POST', url, true);
			A.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			A.send(req);		
		}
	}
	function Ajax(){
		if (window.XMLHttpRequest) return new XMLHttpRequest();                    
		try { return new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(e) {}
	}
	return true;
}	
