/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();
var destino='';
/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function autosuggest(id,dest) {
	q = $(id).value;
	destino=dest;
	//e = $(destino);
	if(q==''){
			$(destino).style.display="none";
			$(destino).innerHTML="";
			return;
		}
	// Set te random number to add to URL request
	nocache = Math.random();
	http.open('get', 'includes/search.php?q='+q+'&nocache = '+nocache+'&sugges='+destino+'&caja='+id);
	http.onreadystatechange = autosuggestReply;
	http.send(null);
}
function autosuggestReply() {
if(http.readyState == 4){
	//alert(destino);
	var response = http.responseText;
	e = $(destino);
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

