function el(nombreElemento){
 return(document.getElementById(nombreElemento));
}//function


function abriVent(ruta,nombre,variables,ancho,alto){
 caract="scrollbars=yes,resizable=yes,width="+ancho+",height="+alto;
 popWin=window.open(ruta+nombre+".php?"+variables,nombre,caract);
 popWin.focus();
}

function ajax(){
 if(window.XMLHttpRequest){
		  return new XMLHttpRequest();
 }else{
  try{
   return new ActiveXObject("Microsoft.XMLHTTP");
  }catch(e){
   return false;
  }//try
 }//if
}//ajax

function consultar(respuesta,campos,filtro){
 var aj=new ajax();
 todos=campos;
 campos=campos.split(";");
 campos=campos[0].split(",");
 if(!aj){
  alert("Error al crear objeto de interfaz XMLHttpRequest");
  return;
 }//if
 aj.open('get','../php/servicio.php?funcion='+respuesta+'&campos='+todos+'&filtro='+filtro+"&dummy="+new Date().getTime(),true);
 aj.onreadystatechange=function(){
 if(aj.readyState==4){
  try{
   xml=aj.responseXML.documentElement;
   tipo=xml.getElementsByTagName('objeto')[0].firstChild.data;
   cuan=xml.getElementsByTagName('cuantos')[0].firstChild.data;
   arre = new Array();
   for(mm=0; mm<=xml.getElementsByTagName(tipo).length-1; mm++){
	arreInte=new Array();
	for(nn=0; nn<=campos.length-1; nn++){
     try{
      arreInte[nn]=xml.getElementsByTagName(campos[nn])[mm].firstChild.data;
     }catch(e){
	  arreInte[nn]="";
	 }//try
    }//for
	arre[mm]=arreInte;
   }//for
   responder(respuesta,cuan,arre);
  }catch(e){
   alert("Error al consultar los datos...\n\n"+e);
   responder("Error",0,"Error al consultar.");
  }//try
  }//if
 }//function
 aj.send(null);
}//function


function veriCamp(cade){
 bien=false;
 for(i=0; i<=cade.length-1; i++){
  if(!(cade.charAt(i)+""==" " || cade.charAt(i)+""=="\t")){
   bien=true; break;
  }
 }
 return(bien);
}

 function Asc(String)
{
return String.charCodeAt(0);
}

function Chr(AsciiNum)
{
return String.fromCharCode(AsciiNum)
}


function codi(cade){
/* ca = new Array(Asc(","),Asc(";"),Asc("á"),Asc("Á"),Asc("é"),Asc("É"),Asc("í"),Asc("Í"),Asc("ó"),Asc("Ó"),Asc("ú"),Asc("Ú"),Asc("ü"),Asc("Ü"),Asc("ñ"),Asc("Ñ"),Asc("ç"),Asc("Ç"),Asc("&"),Asc("%"),Asc("#"),Asc("-"));
 for(i=0; i<=ca.length; i++){
  while(cade.indexOf(ca[i])!=-1){
   va=(i<10?"0"+i:i);
   cade=cade.replace(new RegExp(ca[i]),"aLeX"+va);
  }//while
 }//for
 */
 cade=encodeURI(cade);
 return(cade);
}//function


function otBo(dire,cara){
 le1=cara.charAt(0);
 le2=cara.charAt(1);
 if(dire.indexOf(le1)==-1 && dire.indexOf(le2)==-1){
  dire=dire.replace(new RegExp("A"),le1);
 }else if(dire.indexOf(le1)!=-1){
  dire=dire.replace(new RegExp(le1),le2);
 }else{
  dire=dire.replace(new RegExp(le2),le1);
 }//if
 return(dire);
}//function

var miCelda=0;
function animaCe(cel){
 if(miCelda!=0){clearInterval(hiCelda); miCelda.style.backgroundPosition='0px 0px';}
 miCelda=cel;
 miCelda.style.backgroundPosition='0px 0px';
 hiCelda=setInterval("increCe()",50);
}//function
function increCe(){
 val=miCelda.style.backgroundPosition
 val=val.substring(4,val.length-2);
 val=parseInt(val);
 val-=22;
 miCelda.style.backgroundPosition="0px "+val+"px";
 if(val<=-132){clearInterval(hiCelda);}
}//function

 function quitComi(cade){
  while(cade.indexOf("'")!=-1){
   cade=cade.replace(new RegExp("'"),"´");
  }//while
  while(cade.indexOf("\"")!=-1){
   cade=cade.replace(new RegExp("\""),"``");
  }//while
  return(cade);
 }//function
 
 function comiFilt(cade){
  while(cade.indexOf("'")!=-1){
   cade=cade.replace(new RegExp("'"),"çÇ01");
  }//while
  while(cade.indexOf("çÇ01")!=-1){
   cade=cade.replace(new RegExp("çÇ01"),"''");
  }//while
  return(cade);
 }//function
 
 function capital(cade){
  pri=cade.substr(0,1);
  pri=pri.toUpperCase();
  seg=cade.substr(1,cade.length-1);
  cade=pri+seg;
  return(cade);
 }//function
 
 
 /*
 function quitAcen(cade){
  carAnt = new Array('á','Á','é','É','í','Í','ó','Ó','ú','Ú','ü','Ü','ñ','Ñ');
  carNue = new Array('a','A','e','E','i','I','o','O','u','U','u','U','n','N');
  for(ii=0; ii<=carAnt.length-1; ii++){
   while(cade.indexOf(carAnt[ii])!=-1){
    cade=cade.replace(new RegExp(carAnt[ii]),carNue[ii]);
   }//while
  }//for
  return(cade);
 }//function
 */
 
 function cadeCarg(){
  ca ="<table width='150' border='0' cellspacing='0' cellpadding='0'>";
  ca+=" <tr><td align='top' valign='left' width='7'><img src='../gif/fue1.gif' width='7' height='14'></td><td background='../gif/fue2.gif'></td><td align='right' valign='top' width='7'><img src='../gif/fue3.gif' width='7' height='14'></td></tr><tr><td background='../gif/fue4.gif'></td><td background='../gif/fue5.gif'>";
  ca+="  <table align='center'><tr><td background='../gif/cargando.gif' width='100' height='15'></td></tr><tr><td align='center' class='subtitulo'>Cargando...</td></tr></table>";
  ca+=" </td><td background='../gif/fue6.gif'></td></tr><tr><td align='bottom' valign='left'><img src='../gif/fue7.gif' width='7' height='14'></td><td background='../gif/fue8.gif'></td><td align='right' valign='bottom'><img src='../gif/fue9.gif' width='7' height='14'></td></tr>";
  ca+="</table>";
  return(ca);
 }//function
 
