<?php	
 require ("conecta.php");
 $nombre=$_GET['nombre'];
 $sql="select * from m02001 where nombre like '%$nombre%';";  
 $result=mysql_query($sql,$con) or die( mysql_error());
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>Busqueda</TITLE>
<!--<script language="javascript" src="fstandar.js"></script>!-->
<link rel="stylesheet" href="styles.css">
<style type="text/css">
<!--
.Estilo1 {color: #0000FF}
.Estilo2 {color: #FF0000}
-->
</style>
  <script language="JavaScript"> 
   var seleccionado = ""; 
   <?php 
    $num=mysql_num_rows($result);
	$cont=0;
   if ($num>0){
    echo "var aEdit = new Array("; 
    while ($fila=mysql_fetch_row($result)){   
	 $cont++;
      echo "\"" . $fila[0]  . " " . $fila[1] . "\"";         
	  if ($num != $cont){echo ",";}
	  }//fin while
     echo ");"; 
   }// fin si
  
   ?>
   function cambiaSel(chk){ 
    seleccionado = chk.value; 
   } 

   function envia(){
    var a = new String;
	a=seleccionado.substr(seleccionado,100);
    opener.document.form1.rut.value = a.substring(0,9);
	opener.document.form1.nombre.value = a.substring(10,100);
	//Agrega el rut e inicia la carga de la pagina nuevamente.
	//document.form1.hdrut.value=a.substring(0,9);
	
	close(); 
   } 
function agregarn(){
  open("m0201001.php");
}
  </script>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></HEAD>
<BODY>
<form id="form1" name="form1" method="post" action="">
<?php mysql_close($con); ?>
<TABLE height="56%" cellSpacing=0 cellPadding=0 width="57%" align=left 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=top height="100%">
      <TABLE height=135 cellSpacing=0 cellPadding=0 width=421 border=0>
        <TBODY>
        <TR>
          <TD width="717" height=22>
            <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="javascript:close();"><IMG src="images/xc_left.gif" alt="Inicio" width=24 
                  height=22 
                  border=0></A></TD>
                <TD vAlign=top align=left width="100%"><IMG height=22 
                  src="images/xc_center.gif" width="100%" 
                border=0></TD>
              <TD vAlign=top align=right width=24><IMG height=22 
                  src="images/xc_right.gif" width=24 
              border=0></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%">
            <TABLE class=IconsTable height=33 cellSpacing=0 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD height="32"><div align="right" class="larger">
                  <div align="right">Vemol</div>
                </div></TD>
                </TR></TBODY></TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="377" 
              border=0>
              <TBODY>
			  
              <TR>
                <TD width=23 height=18>&nbsp;</TD>
                <TD height=18 align=left vAlign=top class="MainMenuHead">Busqueda:</TD>
                <TD width=20 height=18>&nbsp;</TD></TR>
              <TR>
                <TD width=23 height="100%">&nbsp;</TD>
                <TD height="100%" align=left vAlign=top>
				 <p>
				  <script language="JavaScript">
				   for (var i = 0; i < aEdit.length; i++)
				    document.write("<input type='radio' name='ed' value='" + aEdit[i] + "' onclick='cambiaSel(this)'>" + aEdit[i] + "<br>");
				</script>
				<input type="submit" name="enviar" value="Enviar" onClick="envia()">
				<input name="hdrut" type="hidden" id="hdrut" />
				 </p>
				 
				   <label></label>
				   <label>
				   <input name="agregar" type="button" id="agregar" value="Agregar Nuevo" onclick="agregarn();"/>
				   </label>
				 
				 </TD>
                <TD width=20 height="100%">&nbsp;</TD></TR>
              <TR>
                <TD width=23 height=8>&nbsp;</TD>
                <TD height=8 class="Estilo2"><span class="Estilo1">Encontrados=</span> <?php echo $cont; ?></TD>
                <TD width=20 
      height=8>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
  </TR></TBODY>
</TABLE>
</form>

</BODY>
</HTML>