function make_cbo(cbo,xmlx,val,text,seleccionar){
       
      
  var combo = window.document.getElementById(cbo);
  var xml = window.document.getElementById(xmlx);
  combo.innerHTML='';xml.recordset.movefirst();
  var op1 = combo.document.createElement('OPTION');op1.value='';op1.text=seleccionar;
  combo.options.add(op1);
  while(!xml.recordset.eof)
  {
     var op = combo.document.createElement('OPTION');	    
	 op.value = xml.recordset.Fields(val).value;op.text=xml.recordset.Fields(text).value;
	 combo.options.add(op);xml.recordset.MoveNext();
  }
}


String.prototype.trim = function()
{

    return this.replace(/(^\s*)|(\s*$)/g, "");
}


function ConvToASCII(str)
{
	var arrCode = str.split('#');
	var string = arrCode[0];
	for(var i = 1; i < arrCode.length; i++)
	{
		var f = (arrCode[i].charAt(0) == '0')?1:0;
		if (arrCode[i].length>=3)
		{
			var h = arrCode[i].substring(f,3);
			if ((!(isNaN(h))) && (arrCode[i].substring(0,1)!=" ") && (arrCode[i].substring(1,2)!=" ") && (arrCode[i].substring(2,3)!=" "))
			{
				var charASCII = String.fromCharCode(parseInt(arrCode[i].substring(f,3)));
				string += String(charASCII) + String(arrCode[i].substring(3)); 
			}
			else
			{
				string += "#" + h + String(arrCode[i].substring(3)); 
			}
		}
		else
		{
			string += "#"
			if (arrCode[i].length>0)
			{
				string += String(arrCode[i]); 
			}
		}
	} 
	return string;
}

function getdata(mode,params){
 var dx=new ActiveXObject("Microsoft.XMLHTTP");
 dx.open('POST','../../../data/data.asp?m='+ mode + '&' + params,false);
 dx.setRequestheader('Content-type','text-html');
 dx.send();
 //alert(dx.responseText);
 return ConvToASCII(dx.responseText);
}


function savedata(mode,params)
{
 var dxs=new ActiveXObject("Microsoft.XMLHTTP");
 dxs.open('POST','../../../data/savedata.asp?m='+ mode + '&' + params,false);
 dxs.setRequestheader('Content-type','text-html');
 dxs.send();
 
 return String(dxs.responseText);
}

function ExitDlg(){ if(event.keyCode == 27) window.close(); }

function wOpener(consulta,abrir,abrir_hidden,cols,sep,adicionalesAborrar,functAdicionalEliminar,functAdicionalPresionar)
{
 if(!sep)sep='';
 var str ='<td  colspan="' + cols + '">';
 var reseteado = '';
 if(abrir!=0){
   var vabrir = abrir.split(',');
   for(j=0;j<vabrir.length;j++)
   {
     if(j==(vabrir.length-1)) sep = '';
     var vabrir_show = vabrir[j].split('=');   
     str += '<input name="txt_'+vabrir_show[0]+'"size="'+vabrir_show[1]+'"readonly>&nbsp;'+sep+'&nbsp;';
     reseteado+= "txt_" + vabrir_show[0] + ".value = \'\';"
   }
 }  
 
 
 
 
 
 
 
 
 if(abrir_hidden!=0){
   var vabrir_hidden = abrir_hidden.split(',');
   for(i=0;i<vabrir_hidden.length;i++)
   {
   	str += '<input name="txt_'+vabrir_hidden[i]+'"type="hidden">';
   	reseteado+= "txt_" + vabrir_hidden[i]+".value = \'\';"
   }
 } 
 if (adicionalesAborrar)
 {
   if (adicionalesAborrar.split(',')[1])
   {
   	var vadicionalesAborrar = adicionalesAborrar.split(',');
	for(j=0;j<vadicionalesAborrar.length;j++)
	{
		reseteado+= vadicionalesAborrar[j] + ".value = \'\';"
	}
   }
   else
   {
   	reseteado+= adicionalesAborrar + ".value = \'\';"
   }
 }
 str += '&nbsp;<button onclick="';
 if(functAdicionalPresionar)
 {
 	str += functAdicionalPresionar;
 }
 str += 'openData(\''+consulta+'\');">ELEGIR</button>&nbsp;&nbsp;<img ALT="QUITAR LA SELECCIÓN REALIZADA" src="../../../images/x10x10.gif" onmouseover="this.style.cursor=\'hand\';" onclick="' + reseteado;
 if (functAdicionalEliminar)
 {
 	str += functAdicionalEliminar;
 }
// por ahora este help no.
// str += '" width="10" height="10"></img>&nbsp;&nbsp;<img src="../../../images/faq.gif" onmouseover="this.style.cursor=\'hand\';" onClick="help_w();"></img></td>';
 str += '" width="10" height="10"></img></td>';
 document.write(str);
}

function help_w()
{
	window.open("../../../helps/Buscadores.htm",null, "height=600,width=640,status=yes,toolbar=no,menubar=no,location=no,scrollbars=Yes");
}

function print_div_espere()
{
	document.write('<div id="div_espere_fondo" name="div_espere_fondo" style="position:absolute;display:none;"><div id="div_espere" name="div_espere" class="div_espere_style" style="position:absolute;background-color:#FFFFFF;width:160px;height:24px;font-size:11pt;font-family:Verdana;text-align:center;vertical-align:middle;font-weight:900;border-top: #006699 1.0 solid;border-bottom: #006699 1.0 solid;border-left: #006699 1.0 solid;border-right: #006699 1.0 solid;color: #006699;">Espere, por favor.</div></div>');
}

function mostrarEspere(func_a_ejecutar,milisegundos)
{
	div_espere_fondo.style.display="block";
	var izq_c=((self.document.body.clientWidth/2)-75);
	var top_c=((self.document.body.clientHeight/2)-20);
	div_espere_fondo.style.height=self.document.body.clientHeight + "px";
	div_espere_fondo.style.width=self.document.body.clientWidth + "px";
	div_espere_fondo.style.top="0";
	div_espere_fondo.style.left="0";
	div_espere.style.left=(parseInt(izq_c));
	div_espere.style.top=(parseInt(top_c));
	/*
	alert(div_espere_fondo.style.left);
	alert(div_espere_fondo.style.top);	
	alert(div_espere.style.left);
	alert(div_espere.style.top);
	*/
	setTimeout(func_a_ejecutar,milisegundos);
}

function ocultarEspere()
{
	div_espere_fondo.style.display="none";
}

function print_div_espere2()
{
	document.write('<div id="div_espere_fondo" name="div_espere_fondo" style="position:absolute;display:none;"><div id="div_espere" name="div_espere" class="div_espere_style" style="position:absolute;background-color:#FFFFFF;width:160px;height:24px;font-size:11pt;font-family:Verdana;text-align:center;vertical-align:middle;font-weight:900;border-top: #006699 1.0 solid;border-bottom: #006699 1.0 solid;border-left: #006699 1.0 solid;border-right: #006699 1.0 solid;color: #006699;">Espere, por favor.</div></div>');
}

function mostrarEspere2(func_a_ejecutar,milisegundos)
{
	div_espere_fondo.style.display="block";
	var izq_c=((self.document.body.clientWidth/2)-75);
	var top_c=((self.document.body.clientHeight/2)-20);
	div_espere_fondo.style.height=self.document.body.clientHeight + "px";
	div_espere_fondo.style.width=self.document.body.clientWidth + "px";
	div_espere_fondo.style.top="0";
	div_espere_fondo.style.left="0";
	div_espere.style.top=(parseInt(top_c));
	div_espere.style.left="0";	
	/*
	div_espere.style.left=(parseInt(izq_c));
	div_espere.style.top=(parseInt(top_c));

	alert(div_espere_fondo.style.left);
	alert(div_espere_fondo.style.top);	
	alert(div_espere.style.left);
	alert(div_espere.style.top);
	alert(div_espere.style.left);
	alert(div_espere.style.top);
	*/	
	setTimeout(func_a_ejecutar,milisegundos);
}

function ocultarEspere2()
{
	div_espere_fondo.style.display="none";
}


function reemplazar(texto, que, por_que, noDistingueCase){
	if (noDistingueCase){
		var re = new RegExp(que, "gi");
	} else {
		var re = new RegExp(que, "g");
	}
	var tex = texto.replace(re, por_que);
  	return tex;
}