function bderecho(e) { 
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) 
		return false; 
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { 
		alert(" Esta funcion esta desabilitada "); 
	return false; 
	} 
		return true; 
} 
if (document.layers) window.captureEvents(Event.MOUSEDOWN); 
window.onmousedown=bderecho; 
document.onmousedown=bderecho; 

//desabiliar F11
document.onkeydown = function(){ 
	var presKey;
	presKey = (document.all) ? event.keyCode : event.which; 
	

	if(presKey == 116 || presKey == 122 || presKey == 112){
		return false;
	}
	return true;
}
//desabilita
function mueve(valorx){
	document.frm1.t_r3_gru.value=eval(valorx.value)+1;
}
function openpage(pag,ta){ 
	if(typeof arguments[2]!="undefined"){
		var objAct=document.getElementById('butAct');
		if(typeof objAct!='undefined')
			objAct.value=arguments[2];	
			
	}
	if(typeof arguments[3]!="undefined"){
		var objFrm=document.getElementById(arguments[3]);
		if(typeof objFrm=='undefined')
			objFrm=document.frm1;	
	}else{
		var objFrm=document.frm1;
	}
	
	objFrm.action = pag; 
	objFrm.target = ta;
	
	if(checaDatos())
    	objFrm.submit();
} 
function checaDatos(){
	return true;	
}
function envia2(pag,ta,fr){ 
    document.getElementById(fr).action = pag; 
	document.getElementById(fr).target = ta;
    document.getElementById(fr).submit();
} 


function sendFormNAS(formu,paginaDestino,targetForm){
	formulario=getFormByName(formu);
	if(formulario==null){
		alert("Formulario no existente: "+formu);
	}
	else{
		formulario.action = paginaDestino; 
		formulario.target = targetForm;
	}
}

function sendForm(formu,paginaDestino,targetForm,autoSubmit){
	formulario=getFormByName(formu);
	if(formulario==null){
		alert("Formulario no existente: "+formu);
	}
	else{
		formulario.action = paginaDestino; 
		formulario.target = targetForm;
		if(autoSubmit){
			formulario.submit();	
		}
	}
	
}

function getFormByName (formName) {
	if (!document.all)
    	return document[formName];
    else
    	for (var f = 0; f < document.forms.length; f++)
        	if (document.forms[f].name == formName)
            	return document.forms[f];
	return null;
}

function envia1(pag){ 
    document.frm1.action = pag;
    document.frm1.submit();
} 
function calculate1(valor){
	document.form1.tsal_actual.value=valor;
}
function may(field) 
{ 
field.value = field.value.toUpperCase(); 
}
function nom_pag() 
{ 
	document.PP.modulo.value=document.title;
}
function relojload(){
    var Today = new Date();
	var hours = Today.getHours();
	var min = Today.getMinutes();
	var sec = Today.getSeconds();
	var Time = ((hours > 12) ? hours - 12 :(hours == 0) ? 12 :hours);
	Time += ((min < 10) ? ":0" : ":") + min;
	Time += ((sec < 10) ? ":0" : ":") + sec;
	Time += (hours >= 12) ? " PM" : " AM";
    document.form_reloj.reloj.value = Time;
    setTimeout("relojload()",1000);
}

function MM_jumpMenu(targ,selObj,restore)
{ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function opciones()
{
	if(document.frm1.ttipo.selectedIndex==0 || document.frm1.ttipo.selectedIndex==1){
		document.frm1.tgen.disabled = 1;
		document.frm1.tgen.value = "";
		document.frm1.ttit.disabled = 1;
		document.frm1.ttit.value = "";
		document.frm1.tap.disabled = 1;
		document.frm1.tap.value = "";
		document.frm1.tam.disabled = 1;
		document.frm1.tam.value = "";
		
	}else{
		document.frm1.tgen.disabled = 0;
		document.frm1.ttit.disabled = 0;
		document.frm1.tap.disabled = 0;
		document.frm1.tam.disabled = 0;
	}
}

function opciones1()
{
		document.frm1.tip_com1.disabled = 1
		document.frm1.select.disabled = 1
		document.frm1.select2.disabled = 1
		document.frm1.ttmon.disabled = 1
		document.frm1.tpai.disabled = 1
		document.frm1.select3.disabled = 1
		document.frm1.tfe.disabled = 1
		document.frm1.tdesgr.disabled = 1
		document.frm1.t_sub1.disabled = 1
		document.frm1.t_iva1.disabled = 1
		document.frm1.t_tot1.disabled = 1
}
function soloNumeros(evt) { 
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && (charCode < 47 || charCode > 57)) { 
        alert("Solo se permiten numeros en este campo."); 
        return false; 
    } 
    return true; 
 } 
 function val_cam_cta(evt) { 
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && ((charCode < 48 && charCode != 45) || charCode > 57)) { 
        /*alert("Solo se permiten numeros en este campo."); */
        return false; 
    } 
    return true; 
 } 
 
function checar(varr){
var linea1=varr.name;
var linea=new String(linea1);
var lista = linea.substr(2); 
var can = parseInt(lista);
nm = "li" + can;
//document.frm1.hola.value = nm; 
if (document.getElementById(nm).value < parseInt(varr.value)){ 
	alert("No se permite este valor"); 
	document.getElementById(varr.name).value=document.getElementById(nm).value;
} 
 } 

function validar(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    // dejar la línea de patron que se necesite y borrar el resto 
    //patron =/[A-Za-z]/; // Solo acepta letras 
    patron = /\d/; // Solo acepta números 
    //patron = /\w/; // Acepta números y letras 
    //patron = /\D/; // No acepta números 
    // 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}

function esFlotante(string) {
	var illegalChars = /^[0-9]+[\.]{0,1}\d*$/;
	var patron = /^[0-9]+[\.]$/;
	if (illegalChars.test(string) && string.search(patron) )
		return true;
	return false;
}

function validar1(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    // dejar la línea de patron que se necesite y borrar el resto 
    //patron =/[A-Za-z]/; // Solo acepta letras 
    //patron = /\d/; // Solo acepta números 
    patron = /\w/; // Acepta números y letras 
    //patron = /\D/; // No acepta números 
    // 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}

function solo_letras(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    // dejar la línea de patron que se necesite y borrar el resto 
    patron =/[A-Za-z]/; // Solo acepta letras 
    //patron = /\d/; // Solo acepta números 
    //patron = /\w/; // Acepta números y letras 
    //patron = /\D/; // No acepta números 
    // 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}

function numeros(evt) { 
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && (charCode < 46 || charCode > 57)) { 
        alert("Solo se permiten numeros en este campo."); 
        return false; 
    } 
    return true; 
 } 
 
function ventanaSecundaria (URL){
   
   ventana= window.open(URL,"ventana1","width=300,height=200,scrollbars=NO");
} 

function cerrarVentana(){
           ventana.close();
      }

function imprimir() {
   version = parseInt(navigator.appVersion);
   if (version >= 4)
     window.print();
  }

function ventanaSecundariaS (URL){
   
   ventana= window.open(URL,"ventana2","width=900,height=300,top=200,Left=800,scrollbars=NO"); 
} 

function impr_che_pol (URL){
   ventana= window.open(URL,"vent_che","width=900,height=300,top=100,Left=100,scrollbars=NO"); 
}

function mazimiza2(){
	window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}

function mazimiza(){
	window.resizeTo(screen.availWidth, screen.availHeight);
	window.moveTo(0,0); 
}

function sel_opc1(va)
{	
	if(va == true){
		for (var j = 1; j <= 10; j++) 
		{
			box = eval("document.frm1.ad" + j); 
			box.checked = true;
		}
	}else{
		for (var j = 1; j <= 10; j++) 
		{
			box = eval("document.frm1.ad" + j); 
			box.checked = false;
		}
	}
}
function sel_opc2(va)
{	
	if(va == true){
		for (var j = 1; j <= 6; j++) 
		{
			box = eval("document.frm1.ca" + j); 
			box.checked = true;
		}
	}else{
		for (var j = 1; j <= 6; j++) 
		{
			box = eval("document.frm1.ca" + j); 
			box.checked = false;
		}
	}
}
function sel_emp_sn()
{
	if(document.frm1.t6.value==1){
		document.frm1.t7.disabled = 1;
	}else{
		document.frm1.t7.disabled = 0;
		document.frm1.t7.focus();
		document.frm1.t7.click();
	}
}

function sel_em(va)
{
	if(va == true){
		document.frm1.select.disabled = 0;
		document.frm1.select4.disabled = 0;
		document.frm1.select5.disabled = 0;
	}else{
		document.frm1.select.disabled = 1;
		document.frm1.select4.disabled = 1;
		document.frm1.select5.disabled = 1;
	}
}

function sel_em2(va)
{
	if(va == true){
		document.frm1.r1.disabled = 0;
		document.frm1.r2.disabled = 0;

	}else{
		document.frm1.r1.disabled = 1;
		document.frm1.r2.disabled = 1;
		document.frm1.r2.checked = 0;
		document.frm1.r1.checked = 0;
		document.frm1.select2.disabled = 1;
		document.frm1.select3.disabled = 1;
	}
}

function sel_em3(va)
{
	if(va == true){
		document.frm1.select2.disabled = 0;
		document.frm1.r2.disabled = 1;
		document.frm1.r2.checked = 0;
		document.frm1.select3.disabled = 1;
	}else{
		document.frm1.select2.disabled = 1;
	}
}

function sel_em4(va)
{
	if(va == true){
		document.frm1.select3.disabled = 0;
		document.frm1.r1.disabled = 1;
		document.frm1.r1.checked = 0;
		document.frm1.select2.disabled = 1;
	}else{
		document.frm1.select3.disabled = 1;
	}
}

function cierrame() { 
event.returnValue = "Escribe el texto a mostrar ";
}

function des1(va)
{
	if(va == "vendedor"){
		document.frm1.s1.disabled = 0;
		document.frm1.s2.disabled = 1;
	}else{
		document.frm1.s1.disabled = 1;
		document.frm1.s2.disabled = 0;
	}
}

function act_des_cua()
{
	if(document.frm1.t2.value==1){
		document.frm1.t3.disabled = 1;
		document.frm1.t5.disabled = 1;
		document.frm1.t6.disabled = 1;
		document.frm1.t52.disabled = 0;
		document.frm1.t5.value="";
		document.frm1.t6.value="";
		document.frm1.t52.value="";
	}else{
		document.frm1.t3.disabled = 0;
		document.frm1.t5.disabled = 0;
		document.frm1.t6.disabled = 0;
		document.frm1.t52.disabled = 1;
	}
}

function esDigito(sChr){
var sCod = sChr.charCodeAt(0);
return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt){
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
return bOk;
}

function finMes(oTxt){
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; break;
case 3: nRes = 31; break;
case 4: nRes = 30; break;
case 5: nRes = 31; break;
case 6: nRes = 30; break;
case 7: nRes = 31; break;
case 8: nRes = 31; break;
case 9: nRes = 30; break;
case 10: nRes = 31; break;
case 11: nRes = 30; break;
case 12: nRes = 31; break;
}
return nRes;
}

function valDia(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(6);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

	function valFecha(oTxt){
	var bOk = true;
		if (oTxt.value != ""){
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
		if (!bOk){
		alert("Fecha invalida");
		oTxt.value =  "";
		oTxt.focus();
		}
	}
}

	function pp(varr){
		var linea1=varr.name;
		var linea=new String(linea1);
		var lista = linea.substr(3); 
		var can = parseInt(lista);
		document.frm1.t2.value = lista;
		if(varr.checked == true){
			nm = "ba" + can;
			document.getElementById(nm).checked = 1;
			nm1 = "bc" + can;
			document.getElementById(nm1).checked = 1;
			nm2 = "be" + can;
			document.getElementById(nm2).checked = 1;
			nm3 = "bi" + can;
			document.getElementById(nm3).checked = 1;
			nm4 = "bm" + can;
			document.getElementById(nm4).checked = 1;
		}else{
			nm = "ba" + can;
			document.getElementById(nm).checked = 0;
			nm1 = "bc" + can;
			document.getElementById(nm1).checked = 0;
			nm2 = "be" + can;
			document.getElementById(nm2).checked = 0;
			nm3 = "bi" + can;
			document.getElementById(nm3).checked = 0;
			nm4 = "bm" + can;
			document.getElementById(nm4).checked = 0;
		}
	} 
	
	function act_fichero(va)
{
	if(va == true){
		document.frm1.fichero.disabled = 0;
		document.getElementById("capa").style.visibility='visible';
	}else{
		document.frm1.fichero.disabled = 1;
		document.getElementById("capa").style.visibility='hidden';
	}
}
function op()
{
	if(document.frm1.tteve.selectedIndex==0){
		document.frm1.ttel.disabled = 1;
		document.frm1.tven.disabled = 1;
		document.frm1.ttel.selectedIndex = 0;
		document.frm1.tven.selectedIndex = 0;
	}else{
		if(document.frm1.tteve.selectedIndex==2){
			document.frm1.ttel.disabled = 1;
			document.frm1.tven.disabled = 0;
			document.frm1.tven.selectedIndex = 0;
		}else{
			document.frm1.ttel.disabled = 0;
			document.frm1.tven.disabled = 1;
			document.frm1.ttel.selectedIndex = 0;
		}
	}
}
function op1()
{
	
	if(document.frm1.tt1.selectedIndex==0){
		document.frm1.ttel1.disabled = 1;
		document.frm1.tven1.disabled = 1;
		document.frm1.ttel1.selectedIndex = 0;
		document.frm1.tven1.selectedIndex = 0;
	}else{
		if(document.frm1.tt1.selectedIndex==2){
			document.frm1.ttel1.disabled = 1;
			document.frm1.tven1.disabled = 0;
			document.frm1.tven1.selectedIndex = 0;
		}else{
			document.frm1.ttel1.disabled = 0;
			document.frm1.tven1.disabled = 1;
			document.frm1.ttel1.selectedIndex = 0;
		}
	}
}


//otros datos
	var ancho = 200 
   var alto = 100 
   var fin = 300 
   var x = 100 
   var y = 100 

   function inicio(){ 
    ventana = window.open("DZ23000.php", "_blank", "resizable,height=1,width=1,top=x,left=y,screenX=x,screenY=y"); 
    abre(); 
   } 

   function abre(){ 
    if (ancho <= fin) { 
     ventana.moveTo(x, y); 
     ventana.resizeTo(ancho, alto); 
     x += 5; 
     y += 5; 
     ancho += 200; 
     alto += 15; 
     timer = setTimeout("abre()", 1); 
    } else { 
     clearTimeout(timer); 
    } 
   } 
  
  //--> algo de  AJAX 
  
  function objetus(file) {
		xmlhttp=false;
		this.AjaxFailedAlert = "Su navegador no soporta las funcionalidades de este sitio y podria experimentarlo de forma diferente a la que fue pensada. Por favor habilite javascript en su navegador para verlo normalmente.\n";
 this.requestFile = file;
 this.encodeURIString = true;
 this.execute = false;
 if (window.XMLHttpRequest) { 
            this.xmlhttp = new XMLHttpRequest();
            if (this.xmlhttp.overrideMimeType) {
                this.xmlhttp.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) { // IE
try {
  this.xmlhttp  = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
 try {
  this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e) {
   this.xmlhttp = null;
   }
       }
 if (!this.xmlhttp  && typeof XMLHttpRequest!='undefined') {
                this.xmlhttp = new XMLHttpRequest();
    if (!this.xmlhttp){
   this.failed = true; 
  } } }
 return this.xmlhttp ;
 }

function recibeid(_pagina,valorget,valorpost,capa){ 
	ajax=objetus(_pagina);
	if(valorpost!="")
	{
		ajax.open("POST", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
	} else {
		ajax.open("GET", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
	}
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1)
		{
			document.getElementById(capa).innerHTML = "<img src='GIF32.gif' align='center'> Aguarde por favor...";
		}
		if (ajax.readyState==4) {
			if(ajax.status==200){
				document.getElementById(capa).innerHTML = ajax.responseText;
			}else if(ajax.status==404){
					capa.innerHTML = "La direccion no existe";
			}else{
				 capa.innerHTML  = "Error: ".ajax.status;
		   }
		}
	}
	if(valorpost!="")
	{
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send(valorpost);
	} else {
		ajax.send(null);
	}

} 
  
  function recibeidx(_pagina,valorget,valorpost,capa){ 
	ajax=objetus(_pagina);
	if(valorpost!="")
	{
		ajax.open("POST", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
	} else {
		ajax.open("GET", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
	}
	ajax.onreadystatechange=function(){
		if (ajax.readyState==1)
		{
			//document.getElementById(capa).innerHTML = "<img src='GIF32.gif' align='center'> Aguarde por favor...";
			top.frames[capa].location = "<img src='GIF32.gif' align='center'> Aguarde por favor...";
		}
		if (ajax.readyState==4) {
			if(ajax.status==200){
				//document.getElementById(capa).innerHTML = ajax.responseText;
				top.frames[capa].location=ajax.responseText;
			}else if(ajax.status==404){
					capa.innerHTML = "La direccion no existe";
			}else{
				 capa.innerHTML  = "Error: ".ajax.status;
		   }
		}
	}
	if(valorpost!="")
	{
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send(valorpost);
	} else {
		ajax.send(null);
	}
} 

  //--> AJAX
  
  //--> ABRIR EN OTRA PANTALLA
  function sendValue(v,va,va1,va2,va3,va4,va5){
	var sv = va;
	cs = sv.split("|");
	var va = cs[0];
	if (va != "") {
		window.opener.document.frm1.tcol1.value = v;
		window.opener.document.frm1.tcol.value = cs[0];
		window.opener.document.frm1.tcve.value = va1;
		window.opener.document.frm1.tcp.value = va2;
		window.opener.document.frm1.pais.selectedIndex = va3;
		window.opener.document.frm1.estados.selectedIndex = va4;
		window.opener.document.frm1.tmun.selectedIndex = va5;
		window.opener.document.frm1.tcol.focus();
		//window.opener.document.frm1.submit();
	} else {
		alert("El GRUPO DE RUBRO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tcol.value = "";
		window.opener.document.frm1.tcol.focus();
	}
	window.close();
}

  function sendValAddress(action,v,va,va1,va2,va3,va4,va5){
	var sv = va;
	cs = sv.split("|");
	var va = cs[0];
	if (va != "") {
		window.opener.document.frm1.tcol1.value = v;
		window.opener.document.frm1.tcol.value = cs[0];
		window.opener.document.frm1.tcve.value = va1;
		window.opener.document.frm1.tcp.value = va2;
		window.opener.document.frm1.pais.selectedIndex = va3;
		window.opener.document.frm1.estados.selectedIndex = va4;
		window.opener.document.frm1.tmun.selectedIndex = va5;
		window.opener.document.frm1.action=action+'?tcoll='+v+'&tcol='+cs[0]+'&tcve='+va1+'&tcp='+va2+'&pais='+va3+'&estados='+va4+'&tmun='+va5;
		//alert(window.opener.document.frm1.action);
		window.opener.document.frm1.target='_self';
		window.opener.document.frm1.submit();
		
		//window.opener.document.frm1.submit();
	} else {
		alert("El GRUPO DE RUBRO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tcol.value = "";
		window.opener.document.frm1.tcol.focus();
	}
	window.close();
}
  //-->FIN
  
  //--DESABILITAR FORMULARIO
  	function deshab() {
  		frm = document.forms['frm1'];
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			if(Type=="text"){
				ele.readOnly =true;
			}else{
				ele.disabled =true;
			}
		}
	}
  //-->FIN
  
  function chex() {
  		if (document.frm1.tfactura.value == "") {
			alert("Nesesario escribir # de la Factura");
			document.frm1.tfactura.focus();
		}
	}
	
	//--> ABRIR EN OTRA PANTALLA
  function sendValue1(va1,va2,va3,va4){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.tncli.value = va1;
		window.opener.document.frm1.tnom_alt.value = va2 + " " + va3 + " " + va4;
		window.opener.document.frm1.tncli.focus();
	} else {
		alert("EL CLIENTE NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tncli.value = "";
		window.opener.document.frm1.tncli.focus();
	}
	window.close();
}
  //-->FIN
  
//--> MANDA NUEVA CANTIDAD A VENTAS
  function cam_can_ven(va1){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.tpre.value = va1;
		window.opener.document.frm1.tp11.value = va1;
		window.opener.document.frm1.tpre.focus();
	} else {
		alert("CANTIDAD INCORRECTA POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tpre.value = "";
		window.opener.document.frm1.tpre.focus();
	}
	window.close();
}
  //-->FIN
  
  	//--> DATOS SEGUN CANTIDAD
  function seg_can(va){
	if (parseFloat(va) <= parseFloat(document.frm1.tp1.value) ||  parseFloat(document.frm1.tp1.value)==0 || document.frm1.tp1.value=='') {
		document.frm1.tpre.value = parseFloat(document.frm1.tp11.value).toFixed(2);
	} else if (parseInt(va) <= parseFloat(document.frm1.tp2.value)) {
		document.frm1.tpre.value = parseFloat(document.frm1.tp22.value).toFixed(2);
	} else{
		document.frm1.tpre.value = parseFloat(document.frm1.tp33.value).toFixed(2);
	}
	//--> Si no hay limite
	if (parseFloat(document.frm1.tp1.value)==0 || document.frm1.tp1.value=='') {
		document.frm1.tpre.value = parseFloat(document.frm1.tp11.value).toFixed(2);
		//alert ("4");
	}
	//--> Precio si es distribuidor
	if (parseInt(document.frm1.tdis.value) == 1) {
		document.frm1.tpre.value = parseFloat(document.frm1.tp44.value).toFixed(2);
		//alert ("5");
	}
	//-->Si la cantidad es igual a 0
	if (parseFloat(document.frm1.tpre.value) == 0 || document.frm1.tpre.value == ""){
		document.frm1.tpre.value = parseFloat(document.frm1.tp11.value).toFixed(2);
		//alert ("6");
	}
	if (document.frm1.tcan.value == ""){
		document.frm1.tpre.value = parseFloat(document.frm1.tp11.value).toFixed(2);
		//alert ("7");
	}
	if (document.frm1.t_m.value == "E") {
		//alert("Es nesesario escribir el Numero de la Factura");
		var can = parseFloat(document.frm1.tpre.value) ;
		document.frm1.tpre.value = parseFloat(can).toFixed(2);
		//alert ("tip_cam:"+parseFloat(document.frm1.dll.value)+ "  Precio:" +parseFloat(document.frm1.tpre.value));
	}
}
  //-->FIN
  //-->No te deja capturar la venta si no escribes el numero de la factura priemro
    function chey() {
  		if (document.frm1.tdev.value == "") {
			//alert("Es nesesario escribir el Numero de la Factura");
			document.frm1.tdev.focus();
		}
	}
	
function actx_opc()
{
	if(document.frm1.s2.value==0 || document.frm1.s2.value==5 || document.frm1.s2.value==6){
		document.frm1.tfi.disabled = 0;
		document.frm1.reset.disabled = 0;
		document.frm1.tff.disabled = 0;
		document.frm1.reset2.disabled = 0;
	}else{
		
		document.frm1.tfi.disabled = 1;
		document.frm1.reset.disabled = 1;
		document.frm1.tff.disabled = 1;
		document.frm1.reset2.disabled = 1;
		//document.frm1.t7.focus();
		//document.frm1.t7.click();
	}
}

//pudo haber servido para la venta pero lor esolvi de otra forma directamente con php
function rrxx(va)
{
	var linea1=va;
	var linea=new String(linea1);
	var lista = linea.substr(2); 
	var can = lista;
	nm1 = "nu_re1" + va;
	nm2 = "nu_re2" + va;
	//document.frm1.tcan.value = nm1;
	if(va.checked == true){
		document.getElementById(nm1).checked = 0;
		document.getElementById(nm2).checked = 0;
	}else{
		document.getElementById(nm1).checked = 1;
		document.getElementById(nm2).checked = 1;
	}
}
//este es para el modulo de traspaso
function manday(va)
{
	document.frm1.tap12.value = va;
}

  //--CONTAR TEXT
  	function con_text() {
		var h = 0;
  		for(i=0; i<document.frm1.elements.length; i++)
		{
			if(document.frm1.elements[i].type == "text")
			{
				alert ("hola" + i);
				h += 1;
			}
		}
		document.frm1.tc.value = document.frm1.elements.length;
	}

function arriba(va)
{
	//alert(va);
	if(va == "na"){
		document.form3.tt.disabled = 1;
		document.form3.fec.disabled = 1;
		document.form3.fec2.disabled = 1;
		//document.form3.bot.disabled = 1;
		//document.form3.bot1.disabled = 1;
		
	}else if(va == "a" || va == "f"){
		document.form3.tt.disabled = 1;
		document.form3.fec.disabled = 0;
		document.form3.fec2.disabled = 0;
		//document.form3.bot.disabled = 0;
		//document.form3.bot1.disabled = 0;
	}else if(va == "no"){
		document.form3.tt.disabled = 0;
		document.form3.fec.disabled = 0;
		document.form3.fec2.disabled = 0;
		//document.form3.bot.disabled = 0;
		//document.form3.bot1.disabled = 0;
	}else if(va == "p"){
		document.form3.tt.disabled = 0;
		document.form3.fec.disabled = 1;
		document.form3.fec2.disabled = 1;
		//document.form3.bot.disabled = 1;
		//document.form3.bot1.disabled = 1;
	}
}
//checar si hay nota de credito

  function chex1() {
  		if (document.frm1.tdev.value == "") {
			alert("Nesesario escribir # de la Nota de credito");
			document.frm1.tdev.focus();
		}
	}
	//fin
	
	//--DESABILITAR TODOS LOS CHECKBOX
  	function todos(va) {
  		frm = document.forms['frm1'];
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			if(Type=="checkbox" && va.checked == true){
				ele.checked = true;
			}else if(Type=="checkbox" && va.checked == false){
				ele.checked = false;
			}
		}
	}
  //-->FIN
  
//--------------------DESABILITAR TODOS LOS CHECKBOX DV31000.php
	function cal_cula(va) {
		var frm = document.frm1; 
		var iva=new String(frm.t4.value);
		var dat=iva.split("|");  
		var res = va * (parseInt(dat[1])/100);
		resultado = parseFloat(res).toFixed(2);
		frm.t5.value = resultado;
		//datos de retencion
		var valor1 = frm.t9.value;
		var valor2 = frm.t12.value;
		
		var resx = va * (parseFloat(valor1)/100);
		frm.t10.value = parseFloat(resx).toFixed(2);

		var resy = va * (parseFloat(valor2)/100);
		frm.t13.value = parseFloat(resy).toFixed(2);
		var rt1 = frm.t10.value;
		var rt2 = frm.t13.value;
		tot_doc = parseFloat(va) + parseFloat(resultado) - rt1 - rt2;
		frm.t14.value = parseFloat(tot_doc).toFixed(2);
		frm.t19.value = parseFloat(tot_doc).toFixed(2);
	/*var part_num=0;
	while (part_num < dat.length)
	{
		 alert(dat[part_num]);
		 part_num+=1;
	}
	*/
	}
	
	function cal_cula_deIVA(res) {
		
		var frm = document.frm1; 
		//var res=document.getElementById('t5').value;
		var iva=new String(frm.t4.value);
		var dat=iva.split("|");  
		/*var vas = res / (parseInt(dat[1])/100);
		var va = parseFloat(vas).toFixed(2);
		frm.t3.value = va;*/
		var vas=parseFloat(frm.t3.value);
		va=parseFloat(frm.t3.value).toFixed(2);		
		
		//datos de retencion
		var valor1 = frm.t9.value;
		var valor2 = frm.t12.value;
		
		var resx = va * (parseFloat(valor1)/100);
		frm.t10.value = parseFloat(resx).toFixed(2);

		var resy = va * (parseFloat(valor2)/100);
		frm.t13.value = parseFloat(resy).toFixed(2);
		var rt1 = frm.t10.value;
		var rt2 = frm.t13.value;
		tot_doc = parseFloat(vas) + parseFloat(res) - rt1 - rt2;
		frm.t14.value = parseFloat(tot_doc).toFixed(2);
		frm.t19.value = parseFloat(tot_doc).toFixed(2);
	/*var part_num=0;
	while (part_num < dat.length)
	{
		 alert(dat[part_num]);
		 part_num+=1;
	}
	*/
	}
	
	// --Retenciones
	function ret(va) 
	{
		var frm = document.frm1; 
		var valor = va.value
		var tas=new String(valor);
		var dat=tas.split("|"); 
		var c1 = frm.t3.value;
		var c2 = frm.t5.value;
		var rt1 = frm.t10.value;
		var rt2 = frm.t13.value;
		
		if(va.name == "t8"){
			//alert("valor:" + dat[1]);
			frm.t9.value = parseFloat(dat[1]).toFixed(2);
			var res = c1 * (parseFloat(dat[1])/100);
			frm.t10.value = parseFloat(res).toFixed(2);
		}else if(va.name == "t11"){
			frm.t12.value = parseFloat(dat[1]).toFixed(2);
			var res = c1 * (parseFloat(dat[1])/100);
			frm.t13.value = parseFloat(res).toFixed(2);
		}
		var rt1 = frm.t10.value;
		var rt2 = frm.t13.value;
		tot_doc = parseFloat(c1) + parseFloat(c2) - parseFloat(rt1) - parseFloat(rt2);
		frm.t14.value = parseFloat(tot_doc).toFixed(2);
		frm.t19.value = parseFloat(tot_doc).toFixed(2);
	}
	
 //--> ABRIR EN OTRA PANTALLA PARA DV31000AA1
  function buscar_cuntas(v,va){
	var sv = va;
	cs = sv.split("|");
	var va = cs[0];
	if (va != "") {
		window.opener.document.frm1.t2.value = v;
		window.opener.document.frm1.t2.focus();
	} else {
		alert("El GRUPO DE RUBRO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.t2.value = "";
	}
	window.close();
}
  //-->FIN
  
  //--------------------DESABILITAR TODOS LOS CHECKBOX DV33000.php
	function cons_nott(va) {
		var frm = document.frm1; 
		var con=new String(va);
		var dat=con.split("|");  
		var res = parseInt(dat[1]) + 1;
		frm.t3.value = res;
	}
  //-->FIN
  
   //--------------------DESABILITAR TODOS LOS CHECKBOX DV33000_AG1.php
	function opera_det() {
		var frm = document.frm1; 
		frm.tt5.value =  parseFloat(frm.tt4.value) * (parseFloat(frm.tt45.value)/100);
		var res = parseFloat(frm.tt4.value) - parseFloat(frm.tt5.value);
		frm.tt6.value = res;
		frm.tt7.value = res * parseFloat(frm.tt3.value);
		frm.tt8.value = res * parseFloat(frm.tt3.value);
	}
  //-->FIN
  
  //--------------------DESABILITAR TODOS LOS CHECKBOX DV35000_AG.php
	function sum_c() {
		var frm = document.frm1; 
		var can = parseFloat(frm.t6.value) + parseFloat(frm.t7.value);
		frm.t8.value = parseFloat(can).toFixed(2);
	}
  //-->FIN
  
    //--------------------DEPENDIENDO DEL TIPO HABILITA O DESABILITA DG17000_AG.php
	function checa_DG(va) {
		var frm = document.frm1;
		if(va=="V"){
			frm.select2.disabled = 0;
			//frm.select2.style.display = "block"; 
		}else{
			frm.select2.disabled = 1;
			//frm.select2.style.display = "none"; 
		}
	}
  //-->FIN
  
 // --SEGUN OPCION DE PAGO HABILITA O DESABILITA CAMPOS
	function hab_camp(va) 
	{
		//alert (va);
		var frm = document.frm1; 
		var tas=new String(va);
		var dat=tas.split("|"); 
		if(dat[1] == "N"){
			frm.tref.disabled = 1;
			frm.taut.disabled = 1;
			frm.taut1.disabled = 1;
		}else if(dat[1] == "R" || dat[1] == "V"){
			frm.tref.disabled = 0;
			frm.taut.disabled = 0;
			frm.taut1.value = dat[2];
		}

	}
	// -- > Polizas
		function pepe(){
		var frm = document.frm1;
		for(i=0;i<=2;i++){
			if(frm.r1[i].checked == 1){
				recibeid('DC21000_CO.php','tipo='+frm.r1[i].value,'busq='+frm.tbus.value,'capa3');
			}
		} 
	}
	//regreso en polizas
	//--> ABRIR EN OTRA PANTALLA
  	function regreso(){
		var frm = document.frm1;
		//si son iguales regreso si no cuadrar
		if(frm.tcargo.value == frm.tabono.value){
			window.opener.document.frm1.b1.focus();
			window.close();
		}else{
			alert ('Es necesario cuadrar la poliza N: '+frm.tnum_pol.value);	
		}
	}
	
	function regreso1(){
		var frm = document.frm1;
		//si son iguales regreso si no cuadrar
		if(frm.tcargo.value != frm.tabono.value){
			alert ('Es necesario cuadrar el detalle del Cheque');	
		}
	}
	//--> ABRIR EN OTRA PANTALLA
  	function regr_val(va,va1){
		document.frm1.tt1.value = va;
		document.frm1.tt2.value = va1;
		recibeid('DC21000_AG2.php','','','Layer2');
	}
	
	function val_car_abo(va){
		var frm = document.frm1;
		if(va == "tt5"){
			frm.tt6.value = 0;
		}else if(va == "tt6"){
			frm.tt5.value = 0;
		}
	}
	
	//-- >Salir de la pcapa de polizas
	function salir_capa(){
		recibeid('DC21000_AG2.php','','','Layer2');
	}
	
	function sin_dato(va){
		if(va.value==""){
			document.getElementById(va.name).value = 0;	
		}
	}
	// -- > Mandar el boton de eliminar
		function pepe2(va){
		//frm.r1[i].checked == 1
		
		frm = document.forms['frm1'];
		var vv = 0;
		var regis="";
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			//alert ("sac:"+sac);
			if(Type=="checkbox" && ele.checked == true && sac == "bot" ){
				//ele.checked = true;
				vv = vv + 1;
				regis = regis+ele.value+"|";
				//alert (regis);
			}
		}
		if(vv == 0){
			if(va == "b2"){
				recibeid('DC21000_CO.php','','','capa3');
			}else if(va == "b22"){
				recibeid('DC22000_CO.php','','','capa3');
			}
		}else{
			if(va == "b2"){
				recibeid('DC21000_EL.php','nn='+regis,'','capa3');
			}else if(va == "b22"){
				recibeid('DC22000_EL.php','nn='+regis,'','capa3');
			}	
		}
	}
	function pepe2gen(pagina,va){
		//frm.r1[i].checked == 1
		
		frm = document.forms['frm1'];
		var vv = 0;
		var regis="";
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			//alert ("sac:"+sac);
			if(Type=="checkbox" && ele.checked == true && sac == "bot" ){
				//ele.checked = true;
				vv = vv + 1;
				regis = regis+ele.value+"|";
				//alert (regis);
			}
		}
		if(vv == 0){
			if(va == "b2"){
				recibeid('DC21000_CO.php','','','capa3');
			}else if(va == "b22"){
				recibeid(pagina+'_CO.php','','','capa3');
			}
		}else{
			if(va == "b2"){
				recibeid('DC21000_EL.php','nn='+regis,'','capa3');
			}else if(va == "b22"){
				recibeid(pagina+'_EL.php','nn='+regis,'','capa3');
			}	
		}
	}
	// -- > Mandar el boton de modificar en polizas
	function pepe3(va){
		//frm.r1[i].checked == 1
		frm = document.forms['frm1'];
		var vv = 0;
		var regis="";
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			//alert ("sac:"+sac);
			if(Type=="checkbox" && ele.checked == true && sac == "bot" ){
				//ele.checked = true;
				vv = vv + 1;
				regis = ele.value;
				
			}
		}
		if(vv == 0 || vv > 1){
			if(va == "b3"){
				recibeid('DC21000_CO.php','','','capa3');
			}else if(va == "b33"){
				recibeid('DC22000_CO.php','','','capa3');
			}
		}else if(vv == 1){
			if(va == "b3"){
				recibeid('DC21000_MO1.php','nn='+regis,'','capa3');
			}else if(va == "b33"){
				recibeid('DC22000_MO1.php','nn='+regis,'','capa3');
			}
		}
	}
  //-->FIN
  // -- > Mandar el boton de consultar
	function pepe4(va){
		//frm.r1[i].checked == 1
		frm = document.forms['frm1'];
		var vv = 0;
		var regis="";
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			//alert ("sac:"+sac);
			if(Type=="checkbox" && ele.checked == true && sac == "bot" ){
				//ele.checked = true;
				vv = vv + 1;
				regis = ele.value;
				
			}
		}
		if(vv == 0 || vv > 1){
			if(va == "b4"){
				recibeid('DC21000_CO.php','','','capa3');
			}else if(va == "b44"){
				recibeid('DC22000_CO.php','','','capa3');
			}
		}else if(vv == 1){
			if(va == "b4"){
				recibeid('DC21000_CO2.php','nn='+regis,'','capa3');
			}else if(va == "b44"){
				recibeid('DC22000_CO2.php','nn='+regis,'','capa3');
			}
			//alert("hola");
		}
	}
  //-->FIN
//--------------boton de actualizar para polizas
	function pepe5(va){
		//frm.r1[i].checked == 1
		
		frm = document.forms['frm1'];
		var vv = 0;
		var regis="";
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			//alert ("sac:"+sac);
			if(Type=="checkbox" && ele.checked == true && sac == "bot" ){
				//ele.checked = true;
				vv = vv + 1;
				if((i+1)<frm.elements.length)
					regis = regis+ele.value+"|";
				else
					regis = regis+ele.value;
				//alert (regis);
			}
		}
		if(vv == 0){
			recibeid('DC22000_CO.php','','','capa3');
		}else{
			recibeid('DC22000_AC.php','nn='+regis,'','capa3');
		}
	}
//---------------<fin de la actualizacion

// -->verificar la cantidad
  function validar_valor(va){

	  	var frm = document.frm1;
		//var ncan =  frm.tcheca1.value - frm.tcheca.value;
		var linea=new String(va.name);
		var sac = linea.substr(3);
		//alert (sac);
		var pagos=new String("tcheca"+sac);
		var gg=new String("tchecaa"+sac);
		var tt=new String("tchecab"+sac);
		//var uu=new String("tcheca2"+sac);
		//alert (pp);
		var t1 = parseFloat(document.getElementById('pagos').value).toFixed(4);
		var t2 = parseFloat(document.getElementById('gg').value).toFixed(4);
		var t3 = parseFloat(document.getElementById('tt').value).toFixed(4);
		//alert (t1);
		//alert (t2);
		//alert (t3);
		var ncan =  t2 - t1;
		//alert (ncan);
		//alert (frm.tcheca.value);
	  	if (parseFloat(va.value).toFixed(4) > ncan){
			alert('la cantidad no es posible de aplicar ');
			document.getElementById(va.name).value = parseFloat(t3).toFixed(2);	
		}
		//moneda extranjera
		//if (t4 == "E"){
			
		//}
  }
//solicitud cheques 
  function val_sum_doc(va,v1){
	  //validar_valor(va);
	  	frm = document.forms['frm1'];
		var vv = 0;
		var regis=0;
  		for(i=0; ele=frm.elements[i]; i++){
			var Type = ele.type;
			//alert ("Type:"+Type);
			var linea=new String(ele.name);
			//alert ("linea:"+linea);
			var sac = linea.substr(0,3); 
			var sac1 = linea.substr(3); 
			var jj = "botc" + sac1;
			/*alert('sacl_ '+ sacl+' sac: '+sac);
			var tipCam=parseFloat(document.getElementById('te_t_c').value).toFixed(2);
			var tipMon=document.getElementById('tip_mon'+sacl).value;
			
			if(tipMon!='1') tipCam=1;*/
			
			if(Type=="text" && ele.value > 0 && sac == "saa" && document.getElementById(jj).checked == true){
				
				
				
				//ele.checked = true;
				vv = vv + 1;
				//alert (regis);
				regis = parseFloat(regis) + parseFloat(ele.value);
				//alert (regis);
			}
		}
		document.getElementById(v1).value = parseFloat(regis).toFixed(2);	
		cs = document.frm1.te_cve_iva.value.split("|");
		var iv = cs[1];
		var iva =parseFloat(regis) - (parseFloat(regis) / (1 + (parseFloat(iv)/100)));
		document.frm1.te_imp_iva.value = parseFloat(iva).toFixed(2);
  }
  
    function che_cta_con(va,v1){
		var frm = document.frm1;
		var cta =new String(va.value);//cadena
		//alert (cta);
		if(cta != ""){
			var linea=new String(frm.ttr.value);//cadena
			//alert (linea);
			if(linea == ""){
				alert ("No hay estructura contable");
			}else{
				var sac = linea.substr(0,1); //limite
				//alert (sac);
				var cc = parseInt(sac) - 1;//limite de busqueda
				//alert (cc);
				var dat=cta.split("-");//sacra datos de la matriz de la cuenta
				//alert (dat);
				var cad_fin = "";
				//alert (dat.length);
				if (dat.length > 1){//validar cuenta contable
					//alert ("hola");
					for(i=0; i < cc; i++){
						var sacx = linea.substr(i,1);//substraer dato x dato
						//alert (sacx);
						var ff = dat[i].substr(0,sacx);
						//alert (dat[i]);
						//alert (ff);
						var cad = new String(ff);
						var ncad = cad;
						//alert (ncad);
						if(cad.length <= sacx){//si la cadena es mas pequeña que el tamaño requerido
							var dif = sacx - cad.length;
							//alert (dif);
							var dd = dif + 1;
							//alert (dd);
							var ncad = str_pad (dat[i],sacx , "0", "STR_PAD_LEFT");
							//alert (ncad);
							var cad_fin = cad_fin + ncad + "-";
						}else{
							var cad_fin = cad_fin + ncad + "-";
						}
						//alert (cad_fin);
					}
					//alert ("una prueba mas");
					cad_fin = cad_fin.substr(0,cad_fin.length-1);
					//alert(cad_fin);
					//alert ("una prueba");
					do {    
					cad_fin = cad_fin.replace('-','');
					} while(cad_fin.indexOf('-') >= 0);
					va.value = cad_fin;
					if (v1 == "") recibeid('DC22000_AG3.php','cta=' + cad_fin,'','capa4');
				}else{//no validar por que no hay suficientes elementos
					var y=0;
					//alert (cc);
					for(i=1; i <= cc+1; i++){
						var sacx = parseInt(linea.substr(i,1));
						//alert (sacx);
						y = y + sacx;
						//alert (y);
						//alert (cta.length);
						if (parseInt(cta.length) < y){
							va.value = "";
							alert ("No es una cuenta valida");
							va.focus();
							i = cc + 1;
						}
						if (parseInt(cta.length) == y){
							i = cc + 1;
						}
						
					}
					//alert (y);
					//alert (cta.length);
					if (parseInt(cta.length) > y){
						va.value = "";
						alert ("No es una cuenta valida");
						va.focus();
					}
						
					if (v1 == "") recibeid('DC22000_AG3.php','cta=' + cta,'','capa4');
				}
			}
		}		
  }
// -------------------> Funcion para rellenar
	function str_pad (input, pad_length, pad_string, pad_type)
{
  input = String (input);
  pad_string = pad_string != null ? pad_string : " ";
  if (pad_string.length > 0)
  {
    var padi = 0;
    pad_type = pad_type != null ? pad_type : "STR_PAD_RIGHT";
    pad_length = parseInt (pad_length);
    switch (pad_type)
    {
      case "STR_PAD_BOTH":
        input = str_pad (input
                       , input.length + Math.ceil ((pad_length - input.length) / 2.0)
                       , pad_string, "STR_PAD_RIGHT");
     // break;  // kein break!
      case "STR_PAD_LEFT":
        var buffer = "";
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          buffer += pad_string.charAt(padi); // [padi] IE 6.x bug
          if (++padi == pad_string.length)
            padi = 0;
        }
        input = buffer + input;
        break;
      default:
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          input += pad_string.charAt(padi);
          if (++padi == pad_string.length)
            padi = 0;
        }
        break;
    }
  }
  return input;
}

/////////sirve para abrir la ayuda

function open_help (URL){
var w = screen.availWidth - 100;
var h = screen.availHeight -100;
w=885;
h=780;
   ventana = window.open(URL,'ventana_ayuda','width='+w+',height='+h+',top=10,left=10,scrollbars=yes,menubar=no,status=no')
} 
/*MANDAR CUENTA CONTABLE A LA PANTALLA EN NOMINA*/
  	function regr_va2(va,va1,oo){
		//alert (va);
		//alert (va1);
		//alert (pag);
		//alert (oo);
		
		//document.frm1.t5.value = va;
		document.getElementById(oo).value = va;
		//alert ("otro");
		recibeid('DC21000_AG2.php','','','Layer2');
	}
/*FIN DE LA MANDADA*/
function val_checks(){
	var frm = document.frm1;
	var vv = 0;
	//alert ("listo");
	for(i=0; ele=frm.elements[i]; i++){
		//alert ("listo1");
		var Type = ele.type;
		//alert ("Type:"+Type);
		var linea=new String(ele.name);
		//alert ("linea:"+linea);
		var sac = linea.substr(0,3); 
		//alert ("sac:"+sac);
		if(Type=="checkbox" && ele.checked == true && sac == "bot"){
			//ele.checked = true;
			vv = vv + 1;
			if(vv >= 2){
				alert ("No se puede modificar mas de dos registros");
			}
		}
	}
}
//documentos x cobrar
			function de_fe(vv){
				if (vv == 3) {
					document.frm1.fec.disabled = 1;
					document.frm1.fec1.disabled = 1;
				}else{
					document.frm1.fec.disabled = 0;
					document.frm1.fec1.disabled = 0;
				}
			}
			
			/*function selecCombo(){
				for (j = 0; j < document.frm1.seclipro.length; j++){
						if(document.frm1.seclipro[j].value == document.frm1.tebusclipro.value){
							document.frm1.seclipro[j].selected=1;
						}
				}
			}*/
//cuenta contable
function nivcta(v){
	var frm = document.frm1;
	frm1.T2.disabled = 0;
	frm1.T3.disabled = 0;
	frm1.T4.disabled = 0;
	frm1.T5.disabled = 0;
	frm1.T6.disabled = 0;
	frm1.T7.disabled = 0;
	frm1.T8.disabled = 0;
	frm1.T9.disabled = 0;
	
	if (v == 1){
		frm1.T3.disabled = 1;
		frm1.T4.disabled = 1;
		frm1.T5.disabled = 1;
		frm1.T6.disabled = 1;
		frm1.T7.disabled = 1;
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
	}else if (v == 2){
		frm1.T4.disabled = 1;
		frm1.T5.disabled = 1;
		frm1.T6.disabled = 1;
		frm1.T7.disabled = 1;
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
		
	}else if (v == 3){
		frm1.T5.disabled = 1;
		frm1.T6.disabled = 1;
		frm1.T7.disabled = 1;
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
		
	}else if (v == 4){
		frm1.T6.disabled = 1;
		frm1.T7.disabled = 1;
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
		
	}else if (v == 5){
		frm1.T7.disabled = 1;
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
		
	}else if (v == 6){
		frm1.T8.disabled = 1;
		frm1.T9.disabled = 1;
	
	}else if (v == 7){
		frm1.T9.disabled = 1;
		
	}
}

//mas para cuenta contable agregar

    function che_cta_con_1(va){
		var frm = document.frm1;
		var cta =new String(document.getElementById(va.name).value);//cadena
		if(cta != ""){
			var linea=new String(frm.ttr.value);//cadena
			if(linea == ""){
				alert ("No hay estructura contable");
			}else{
				var sac = linea.substr(0,1); //limite
				//alert ("limite: "+sac);
				var cc = parseInt(sac) - 1;//limite de busqueda
				//alert ("limite de busqueda: "+cc);
				var dat=cta.split("-");//sacra datos de la matriz de la cuenta
				//alert (dat);
				var cad_fin = "";
				if (dat.length >= 1){//validar cuenta contable
					for(i=0; i <= cc; i++){
						var sacx = linea.substr(i,1);//substraer dato x dato
						//alert("alf");
						//alert ("substraer dato x dato: "+sacx);
						var ff = dat[i].substr(0,sacx);
						var cad = new String(ff);
						//alert ("cad: "+cad);
						var ncad = cad;
						//alert ("ncad: "+ncad);
						
						//alert ("cad.length: "+cad.length);
						if(cad.length <= sacx){//si la cadena es mas pequeña que el tamaño requerido
							var dif = sacx - cad.length;
							var dd = dif + 1;
							var ncad = str_pad (dat[i],sacx , "0", "STR_PAD_LEFT");
							var cad_fin = cad_fin + ncad + "-";
						}else{
							var cad_fin = cad_fin + ncad + "-";
						}
						//alert ("cadena: "+cad_fin);
					}
					cad_fin = cad_fin.substr(0,cad_fin.length-1);
					//alert(cad_fin);
					//alert("1");
					do {    
					cad_fin = cad_fin.replace('-','');
					} while(cad_fin.indexOf('-') >= 0);
					document.getElementById(va.name).value = cad_fin;
					//recibeid('DC22000_AG3.php','cta=' + cad_fin,'','capa4');
				}else{//no validar por que no hay suficientes elementos
					//alert("no se puede");
					//document.getElementById(va.name).value = "";
					//recibeid('DC22000_AG3.php','cta=' + cta,'','capa4');					
				}
			}
		}		
  }
  ///----------->
  //para menus esta esta opcion
  
/*dxacceso*/


	function ppe(varr){
		//alert (varr);
		var frm = document.frm1;
		var linea=new String(varr.name);
		//alert(linea);
		var lista = linea.substr(2); 
		//alert (lista)
		var can = parseInt(lista);
		//alert(can);
		/*-----------------------------------*/
		/*boton seleccionado*/
		var b1 = linea.substr(0,2); 
		
		if(b1=="o3"){
			bu = "ba";
		}else if(b1=="o4"){
			bu = "bc";
		}else if(b1=="o5"){
			bu = "be";
		}else if(b1=="o6"){
			bu = "bi";
		}else if(b1=="o7"){
			bu = "bm";
		}
		//alert (bu);
		var nmom = 0;
		nmom = "limite" + can;
		//alert (nmom);
		var cade = document.getElementById(nmom).value;
		//alert ('v'+cade);
		var dat=cade.split("-");
		//alert (dat[0]);
		// (dat[1]);
		//alert('boton precionado: '+bu);
		/*-----------------------------------*/
		for(i=dat[0];i<=dat[1];i++){
			var lim=new String(bu+i);
			var bb=new String("bot"+i);
			var boton11=new String("ba"+i);
			var boton12=new String("bc"+i);
			var boton13=new String("be"+i);
			var boton14=new String("bi"+i);
			var boton15=new String("bm"+i);
			//alert (lim);
			//alert (varr.name);
			if(document.getElementById(varr.name).checked == true){
				document.getElementById(lim).checked = 1;
				document.getElementById(bb).checked = 1;
			}else{
				document.getElementById(lim).checked = 0;
				if(document.getElementById(boton11).checked == 0 && document.getElementById(boton12).checked == 0 && document.getElementById(boton13).checked == 0 && document.getElementById(boton14).checked == 0 && document.getElementById(boton15).checked == 0){
					document.getElementById(bb).checked = 0;
				}
			}
		}
		/*for(i=0; ele=frm.elements[i]; i++){
			alert('objeto seleccionado: '+ele.name);
			var Type = ele.type;
			alert('tipo: '+Type);
			var lr=new String(ele.name);
			//alert('lr: '+lr);
			var lrr = lr.substr(0,2); 
			alert (lrr);
			var dif = lr.substr(2); 
			alert (dif);
			alert (lrr + '-' + bu);
			alert (ele.checked);
			
			
			
			
			if(Type=="checkbox" && ele.checked == true && lrr == bu && (dif>=dat[0] && dif<= dat[1])){
				nm = "ba" + can;
				document.getElementById(nm).checked = 1;
				nm1 = "bc" + can;
				document.getElementById(nm1).checked = 1;
				nm2 = "be" + can;
				document.getElementById(nm2).checked = 1;
				nm3 = "bi" + can;
				document.getElementById(nm3).checked = 1;
				nm4 = "bm" + can;
				document.getElementById(nm4).checked = 1;
			}else{
				nm = "ba" + can;
				document.getElementById(nm).checked = 0;
				nm1 = "bc" + can;
				document.getElementById(nm1).checked = 0;
				nm2 = "be" + can;
				document.getElementById(nm2).checked = 0;
				nm3 = "bi" + can;
				document.getElementById(nm3).checked = 0;
				nm4 = "bm" + can;
				document.getElementById(nm4).checked = 0;
			}	
		}*/
		

	} 
	
	//cancelacion de facturas
	function cancela_factura1(){
		if(document.frm1.val_fac.value == 0){
			if(confirm("Estas seguro de eliminar?")) {
				document.frm1.val_fac.value = 1;
			} 
		}
	}
	
	function acti_can_nom(va){
		if(va == true){
			document.frm1.te1.disabled = 0;
			document.frm1.te1.focus();
		}else{
			document.frm1.te1.value = "";
			document.frm1.te1.disabled = 1;
		}
	}
	
	function entrada(ven,v1,v2){
		recibeid(ven,'usuario='+v1,'password='+v2,'capa3');	
	}


//boton derecho
//function bderecho(e) { 
	//if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) 
		//return false; 
	//else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { 
		//alert(" Esta funcion esta desabilitada "); 
	//return false; 
	//} 
		//return true; 
	//} 
//if (document.layers) window.captureEvents(Event.MOUSEDOWN); 
//window.onmousedown=bderecho; 
//document.onmousedown=bderecho; 
//-------------->

 
	//--> REGRESA BENEFICIARIO Y CONCEPTO (BANCOS)
  function regresa_beneficiario(va1,va2,va3){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.te_cve_ben.value = va1;
		window.opener.document.frm1.tnom_alt.value = va2;
		window.opener.document.frm1.t5.value = va3;
		window.opener.document.frm1.tnom_alt.focus();
	} else {
		alert("EL BENEFICIARIO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tnom_alt.value = "";
		window.opener.document.frm1.tnom_alt.focus();
	}
	window.close();
}

  function regresa_concepto(va1,va2,va3){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.te_cve_des.value = va1;
		window.opener.document.frm1.te_concepto.value = va2;
		window.opener.document.frm1.t5.value = va3;
		window.opener.document.frm1.te_concepto.focus();
	} else {
		alert("EL BENEFICIARIO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.te_concepto.value = "";
		window.opener.document.frm1.te_concepto.focus();
	}
	window.close();
}

  function alfredoxxx(vv1,vv2,vv3){
	var sv = vv1;
	cs = sv.split("|");
	var va = cs[0];
	if (vv1 != "") {
		window.opener.document.frm1.te_cve_des.value = vv1;
		window.opener.document.frm1.te_concepto.value = vv2;
		window.opener.document.frm1.t5.value = vv3;
		window.opener.document.frm1.te_concepto.focus();
	} else {
		alert("EL BENEFICIARIO NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.te_concepto.value = "";
		window.opener.document.frm1.te_concepto.focus();
	}
	window.close();
	
	
	
}

//agregar datos a la cantidad
function sum_res(va){
	
	var linea=new String(va.name);
	var lista = linea.substr(4); 
	var lista1 = linea.substr(4); 
	var auxLista=lista;
	lista = "saa"+lista;
	lista1 = "saaiva"+lista1;
	var tipMon=document.getElementById('tip_mon'+auxLista).value;
	var tipCam,auxTipCam=parseFloat(document.getElementById('te_t_c').value).toFixed(6);
	if(tipMon!='1'){//si no es moneda nacional
		if(auxTipCam=='NaN' || auxTipCam=='' && va.checked){//verificar que haya tipo de cambio valido
			va.checked=false;
			alert('Tipo de Cambio Requerido');
			document.getElementById('te_t_c').focus();
			
			return 0;
		}
		else{
			tipCam=auxTipCam;
		}
	}else{
		tipCam=1.00;
	}
	var can1 = parseFloat(tipCam*parseFloat(document.getElementById(lista).value)); 
	var df = parseFloat(document.frm1.te_impte.value);
	if(va.checked == true) {
		df += can1; 
	}else{
		df = df-can1; 
	}
	document.frm1.te_impte.value = parseFloat(df).toFixed(2);
	cs = document.frm1.te_cve_iva.value.split("|");
	var iv = cs[1];
	var iva =parseFloat(df) - (parseFloat(df) / (1 + (parseFloat(iv) / 100)));
	document.frm1.te_imp_iva.value =parseFloat(iva).toFixed(2);
}

//---------------------------------------------------------->
//-------------Operacion arrendamiento --------------------->
	//calcula el interes del enganche y a la inversa
	function enganche_arr(va){
		if (va == "1"){
			var can = document.frm1.t33.value;
			var eng = parseFloat(document.frm1.t23.value) * (can/100);
			document.frm1.tenganche.value = parseFloat(eng).toFixed(2);
		}else{
			var can = document.frm1.tenganche.value;
			var eng = (can*100)/parseFloat(document.frm1.t23.value);
			document.frm1.t33.value = parseFloat(eng).toFixed(2);
		}
		var fin = parseFloat(document.frm1.t23.value) - parseFloat(document.frm1.tenganche.value);
		document.frm1.finance.value = parseFloat(fin).toFixed(2);
		//monto neto
		var m = monto_neto();
		document.frm1.t32.value = parseFloat(m).toFixed(2);
		
	}
	// -- Desactiva residuales
	function des_residuales(){
		if(document.frm1.select.selectedIndex==0 ){
				
				document.frm1.t29.disabled = 0;
				document.frm1.t30.disabled = 0;
				document.frm1.t31.disabled = 0;
				document.frm1.t17.disabled = 0;
		}else{
				document.frm1.t29.disabled = 1;
				document.frm1.t29.value = "";
				document.frm1.t30.disabled = 1;
				document.frm1.t30.value = "";
				document.frm1.t31.disabled = 1;
				document.frm1.t31.value = "0";
				document.frm1.t17.disabled = 1;
				document.frm1.t17.value = "";
	
		}
	}
	//-- Monto neto
	function monto_neto(){
		var monto = parseFloat(document.frm1.finance.value) - parseFloat(document.frm1.t31.value) + parseFloat(document.frm1.tconafin.value);
		return monto;
	}
//----------------------------------------------------------<
//----------------------------------------------------------<

	//--DESABILITAR TODOS LOS CHECKBOX y suma las cantidades
  	function suma_bancos(va) {
		if(va.checked == true){
			document.frm1.te_impte.value = parseFloat(document.frm1.ttotal.value).toFixed(2);
		}else{
			document.frm1.te_impte.value = 0;
		}
		document.frm1.te_imp_iva.value = parseFloat(document.frm1.te_impte.value-(document.frm1.te_impte.value/1.15)).toFixed(2);
	}

// PRODUCCION
// -->verificar la cantidad
  function validar_PRO(va){

	  	var frm = document.frm1;
		//var ncan =  frm.tcheca1.value - frm.tcheca.value;
		var linea=new String(va.name);
		var sac = linea.substr(3);
		//alert (sac);
		var pp=new String("tcheca"+sac);
		//var gg=new String("tcheca1"+sac);
		//var tt=new String("tcheca2"+sac);
		//var uu=new String("tcheca2"+sac);
		//alert (pp);
		var t1 = document.getElementById(pp).value;
		//var t2 = document.getElementById(gg).value;
		//var t3 = document.getElementById(tt).value;
		//alert (t1);
		//alert (t2);
		//alert (t3);
		//var ncan =  t2 - t1;
		//alert (va.value);
		//alert (frm.tcheca.value);
	  	if (parseFloat(t1) < parseFloat(va.value)){
			
			alert('la cantidad es mayor a lo posible');
			document.getElementById(va.name).value = parseFloat(t1).toFixed(0);	
		}
		//moneda extranjera
		//if (t4 == "E"){
			
		//}
  }
  
function exportToXL(eTableSrc) {
	var oExcel; 
	var oExcelSheet; 
	var oWkBooks;
	var cols; 
	var eSrc;
	eSrc=document.getElementById(eTableSrc);
	oExcel = new ActiveXObject('Excel.Application');
	oWkBooks = oExcel.Workbooks.Add;
	oExcelSheet = oWkBooks.Worksheets(1);
	oExcelSheet.Activate();
	if (eSrc.tagName != 'TABLE') {
		alert('No ha sido posible exportar la tabla a excell');
		return false;
	}
	cols = Math.ceil(eSrc.cells.length / eSrc.rows.length);
	for (var i = 0; i < eSrc.cells.length; i ++)
	{
		var c, r;
		r = Math.ceil((i+1) / cols);
		c = (i+1)-((r-1)*cols)
		if (eSrc.cells(i).tagName == 'TH') { 
			oExcel.ActiveSheet.Cells(r,c).Font.Bold = true;
			oExcel.ActiveSheet.Cells(r,c).Interior.Color = 14474460; 
		}
		if (eSrc.cells(i).childNodes.length > 0 && eSrc.cells(i).childNodes(0).tagName == "B") 
			oExcel.ActiveSheet.Cells(r,c).Font.Bold = true;
		oExcel.ActiveSheet.Cells(r,c).Value = eSrc.cells(i).innerText;
	}
	oExcelSheet.Application.Visible = true;
}
  
  var _getType = function( inp ) {
        var type = typeof inp, match;
        var key;
        if (type == 'object' && !inp) {
            return 'null';
        }
        if (type == "object") {
            if (!inp.constructor) {
                return 'object';
            }
            var cons = inp.constructor.toString();
            if (match = cons.match(/(\w+)\(/)) {
                cons = match[1].toLowerCase();
            }
            var types = ["boolean", "number", "string", "array"];
            for (key in types) {
                if (cons == types[key]) {
                    type = types[key];
                    break;
                }
            }
        }
        return type;
    }; 
	

/**********************************/
/*      FUNCIONES CARGAR CAPAS    */
/*    Y OTRAS VARIAS PARA MANEJO  */
/*  DE BUSQUEDAS DE CLIENTES PROV */
/**********************************/

//carga contenido en una capa requiere JQUERY
function loadOnLayer(arrData,arrDataPost){
	arrDataPost.layerToLoad=arrData.idLayer;
	$.post(arrData.action,
		arrDataPost,
		function(datos){
			document.getElementById(arrData.idLayer).style.display='';
			if(typeof arrData.width!='undefined' && typeof arrData.height!='undefined')
				resLay(arrData);
			document.getElementById(arrData.idLayer).innerHTML=datos;
		}
	);
}


//Nos da el valor del input radio que este chequeado en ese nomento
function getValRadChe(nameRadio){
	var objRadio=document.getElementsByName(nameRadio);
	var i;
	if(objRadio!=null){
		for(i=0;i<objRadio.length;i++){
			if(objRadio[i].checked)
				return objRadio[i].value;
		}
		return 'notSelected';
	}
	else{
		return 'noValidRadio';
	}
}

function checkRadio(nameRadio,valor){
	var objRadio=document.getElementsByName(nameRadio);
	var i;
	if(objRadio!=null){
		for(i=0;i<objRadio.length;i++){
			if(objRadio[i].value==valor)
				objRadio[i].checked=true;
		}
	}
	else{
		alert('noValidRadio');
	}
}
//Cambia tamaño de una capa
function resLay(arrData){
	var objCapa=document.getElementById(arrData.idLayer);
	objCapa.style.width=arrData.width;
	objCapa.style.height=arrData.height;
}

//abre una nueva ventana
function openWindow(dataGen,valores){
	var objDate=new Date();
	var getVars='',getVarsAux,distPage='';
	var idVentana;
	for(getVarsAux in valores){
		getVars +='&'+getVarsAux+'='+valores[getVarsAux];
		//alert(valores[getVarsAux]);
	}
	if(typeof dataGen.width=='undefined') dataGen.width='800';
	if(typeof dataGen.height=='undefined') dataGen.height='600';
	if(typeof dataGen.resize=='undefined') dataGen.resize='no';
	else if(dataGen.resize){ dataGen.resize='yes';}
	else{ dataGen.resize='no';}
	if(typeof dataGen.scroll=='undefined') dataGen.scroll='no';
	else if(dataGen.scroll){ dataGen.scroll='yes';}
	else{ dataGen.scroll='no';}
	distPage='?tmr='+objDate.getHours()+objDate.getMinutes()+objDate.getSeconds()+objDate.getDay()+objDate.getMonth()+objDate.getYear();
	idVentana=window.open(dataGen.action+distPage+getVars,dataGen.name,'width='+dataGen.width+',height='+dataGen.height+',top=100,left=50,scrollbars=yes,menubar=no,status=yes,toolbar=no,location=no,copyhistory=no,menubar=no,scrollbars=yes'+dataGen.scroll+',resizable='+dataGen.resize);
	return idVentana;
}

//copia al vuelo en otro texto o lo que tenga atributo value

function cpyAtTime(objIdOri,objIdDes){
	objOri=document.getElementById(objIdOri);
	objDes=document.getElementById(objIdDes);
	objDes.value=objOri.value;
}


//Hecho especificamente para cerrar(ocultando) capas  y copiar valores si es necesario
function cloLayAndCpy(arrData,arrDataCpy){
	var objLayer=document.getElementById(arrData.idLayer);
	var objForm;
	cpyValText(arrDataCpy);
	objLayer.innerHTML='';
	objLayer.style.display='none';
	if(typeof arrData.width!='undefined' && typeof arrData.height!='undefined')
		resLay(arrData);
	if((typeof arrData.refOnClose!='undefined' && arrData.refOnClose=='1') && (typeof arrData.idForm!='undefined') && (objForm=document.getElementById(arrData.idForm))!=null){
		if(typeof arrData.actForm!='undefined')
			objForm.action=arrData.actForm;
		if(typeof arrData.tarForm!='undefined')	
			objForm.target=arrData.tarForm;
		objForm.submit();
	}
}

//copia cadenas de texto a objetos que lo soporten tales como text, text area
function cpyValText(arrData){
	var id;
	for(id in arrData)
		document.getElementById(id).value=arrData[id];
}

//Carga Datos en Capa si tecla pulsada
function loadOnLayerByKey(arrData,arrDataPost) { 
	tecla = (document.all) ? event.keyCode : event.which; 
	if(tecla==arrData.accKey){
		loadOnLayer(arrData,arrDataPost);
		return false;
	}
}

//
function esBackSpace(evt) { 
    evt = (evt) ? evt : event; 
    var tecla = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
	//alert(tecla);
	if(tecla==8) 
    	return true;
	else
		return false;
 }
 
 function toggleCheckBox(idForm,idChecker,nameGroup){
	if(typeof arguments[3]!='undefined') var onlyEnable=true;
	else var onlyEnable=false;
	var formulario=document.getElementById(idForm),i;
	var elementos=document.getElementsByName(nameGroup);
	var esCheck=document.getElementById(idChecker).checked;
	if(elementos.length>0){
		for(i=0;i<elementos.length;i++){
			if((onlyEnable && !elementos[i].disabled) || !onlyEnable)
			elementos[i].checked=esCheck;	
		}	
	}
}
/********************/
		
  //-->FIN