function search_engine(){	
	if (document.getElementById("busca").value.replace(/^\s*|\s*$/g,"")!=""){
		var nombre=document.getElementById("busca").value.replace(/ /g,"********");
		var alto=40;
		var url = "http://limakid.com/search_modelito.asp";
		var parameters = "a="+nombre; 
		http.open("POST", url, true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		http.setRequestHeader("Content-length", parameters .length); 
		http.setRequestHeader("Connection", "close");   
		http.onreadystatechange = function() {
			if(http.readyState == 4) {         
				document.getElementById("resultados").innerHTML="";
				if(http.responseText == "0-0-0") {  
					document.getElementById("resultados").innerHTML="<div style='width:200px;height:"+alto+"px;margin-top:2px;margin-bottom:2px;text-align:left;font-family: Arial, Tahoma, Verdana, sans-serif;font-size:12px;color:#666666;font-weight:bold;'>No se encontraron resultados</div>";
					document.getElementById("resultados").style.height=alto;
				}
				else{
					var resultado="";					
					var signos=http.responseText.split("**");
					for(i=0;i<signos.length-1;i++){
						var datos=signos[i].split("--");
						var id=datos[0];
						var nom=datos[1].toLowerCase();
						var foto=datos[2];
						if(i==0){
							var posy=getY(document.getElementById("busca"));
							var posx=getX(document.getElementById("busca"));
							document.getElementById("resultados").style.top=(posy+25)+"px";	
							document.getElementById("resultados").style.left=posx+"px";	
							var estilo="color:#ffffff;background-color:#57bac9;";
						}
						else{
							var estilo="color:#57bac9;background-color:#ffffff;";
						}
						document.getElementById("resultados").innerHTML=document.getElementById("resultados").innerHTML+"<div id='ye-"+i+"' onmouseover='pinta("+i+",0)' onmouseout='pinta("+i+",1)' onclick='ir("+id+");' style='text-align:left;font-family: Arial, Tahoma, Verdana, sans-serif;font-size:12px;font-weight:bold;width:200px;height:"+alto+"px;"+estilo+"'><div style='float:left;position:relative;width:40px;margin-left:5px;margin-top:2px;margin-bottom:2px;'><img width='30' height='30' src='http://limakid.com/"+foto+"' /></div><div style='float:left;position:relative;margin-top:2px;margin-bottom:2px;width:150px;'>"+nom+"</div></div>";
						document.getElementById("resultados").style.height=alto*(i+1);
						
						document.getElementById("resultados").style.visibility = "visible";
						
					}
				}										
			} 
		} 
		http.send(parameters);	
	}
}	
function ir(i){
	window.open("http://limakid.com/modelito/"+i,"_self");
}
function pinta(i,x){
	if(x==0){
		document.getElementById("ye-"+i).style.background="#57bac9";
		document.getElementById("ye-"+i).style.color="#ffffff";
		document.getElementById("ye-"+i).style.cursor="hand";
	}
	else{
		document.getElementById("ye-"+i).style.background="#FFFFFF";
		document.getElementById("ye-"+i).style.color="#57bac9";
		document.getElementById("ye-"+i).style.cursor="pointer";
	}

}		
function getY( oElement ){
	var iReturnValue = 0;
	while( oElement != null ) {
	iReturnValue += oElement.offsetTop;
	oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function getX( oElement ){
	var iReturnValue = 0;
	while( oElement != null ) {
	iReturnValue += oElement.offsetLeft;
	oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function vacia(){
	document.getElementById("busca").value="";
}
function chau(){
	document.onclick = function (e) {
		document.getElementById('resultados').style.visibility="hidden";
	}
}
