String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
//
function fEditar(lpIndex){
	var hw=document.getElementById("TxtHW").value;
	OpenWin("ventas_editar.php?I="+lpIndex+"&H="+hw,570,220);	
}
function CboTar_KeyPress(e){
	var k;
	k=(document.all) ? e.keyCode :e.which; 
	if(k==219){
		return false;
	}else{
		if(k==13){
			if(document.getElementById("CboBancos").disabled==false){
				document.getElementById("CboBancos").focus();
			}
		}
	}
}
//
function fLoad(){
	document.getElementById("TxtAc").value="UP";
	document.getElementById("Frm").submit();
}
//
function CboBan_KeyPress(e){
	var k;
	k=(document.all) ? e.keyCode :e.which; 
	if(k==219){
		return false;
	}else{
		if(k==13){
				document.getElementById("TxtOpe").focus();
		}
	}
}
//
function ChN_BAR_OnChange(){
	document.getElementById('TxtHora').value=0;
	jFocus("TxtCod");
}
//
function TxtCod_OnKeyUp(){
	if(document.getElementById("ChN_BAR").checked==false){
		document.getElementById('TxtHora').value=GetHora();
	}else{
		document.getElementById('TxtHora').value=0;
	}
}
function LSoloTextoEx(e,Sig){	
	var k;
	k=(document.all) ? e.keyCode :e.which; 
	if(k==219){
		return false;
	}else{
		if(k==13){
			if(document.getElementById("ChN_BAR").checked==false){
				document.getElementById(Sig).focus();
			}else{
				if(jLen(document.getElementById("TxtCod").value)==0){
					document.getElementById(Sig).focus();
				}else{
					var R=AjBuscar();
					if(R=="NR"){						
						alert("Codigo de producto no registrado");
						jFocus("TxtCod");
						document.getElementById("TxtCod").select();
					}else{
						document.getElementById("DivDatosProd").innerHTML=R;
						SetValores();
						if(document.getElementById("ChN_AUT").checked==true){
							document.getElementById("CmdAdd").click();
							
						}
					}
				}
			}
			return true;
		}
		return true;
	}
}
//
function CboTdp_KeyPress(e){	
	var k;
	k=(document.all) ? e.keyCode :e.which; 
	if(k==219){
		return false;
	}else{
		if(k==13){
			var StrTdp=document.getElementById("CboTdp").value;
			if(StrTdp=="CONTADO"){				
				document.getElementById("CboTar").value="";
				document.getElementById("CboTar").disabled=true;
				document.getElementById("CboBancos").value="";
				document.getElementById("CboBancos").disabled=true;
				document.getElementById("TxtPagarCon").disabled=false;
				document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
				document.getElementById("CboMon").disabled=false;
				document.getElementById("CboMon").value="SOLES";							
				document.getElementById("TxtPagarCon").focus();
			}
			if(StrTdp=="CREDITO"){
				document.getElementById("CboTar").value="";
				document.getElementById("CboTar").disabled=true;
				document.getElementById("CboBancos").value="";
				document.getElementById("CboBancos").disabled=true;
				document.getElementById("TxtPagarCon").disabled=false;
				document.getElementById("CboMon").disabled=false;
				document.getElementById("CboMon").value="SOLES";							
				document.getElementById("CmdB").focus();				
			}
			if(StrTdp=="TARJETA"){
				document.getElementById("CboTar").value="";
				document.getElementById("CboTar").disabled=false;
				document.getElementById("CboBancos").value="";
				document.getElementById("CboBancos").disabled=false;
				document.getElementById("TxtPagarCon").disabled=true;
				document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
				document.getElementById("CboMon").disabled=true;
				document.getElementById("CboMon").value="SOLES";											
				document.getElementById("CboTar").focus();
			}
			if(StrTdp=="DEPOSITO"){
				document.getElementById("CboTar").value="";
				document.getElementById("CboTar").disabled=true;
				document.getElementById("CboBancos").value="";
				document.getElementById("CboBancos").disabled=false;
				document.getElementById("TxtPagarCon").disabled=true;
				document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
				document.getElementById("CboMon").disabled=true;
				document.getElementById("CboMon").value="SOLES";											
				document.getElementById("CboBancos").focus();
			}
			return true;
		}
		return true;
	}
}

//**************************************************************************
function fFiltrar(){
	document.getElementById("TxtAc").value="F";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function VUELTO(){
	var StrTC=document.getElementById("TxtTC").value;
	var StrMon=document.getElementById("CboMon").value;
	var StrTot=document.getElementById("T_TO").value;
	var StrPag=document.getElementById("TxtPagarCon").value;
	if(StrPag.trim().length==0){
		StrPag="0";
	}
	StrTC=parseFloat(StrTC);
	StrTot=parseFloat(StrTot);
	StrPag=parseFloat(StrPag);
	if(StrMon=="DOLARES"){
		StrPag=StrPag * StrTC;
		StrPag=StrPag.toFixed(2);
	}
	var Vuelto=parseFloat("0");
	if(StrTot>StrPag){
		document.getElementById("TxtVuelto").value="0.0";
		return;
	}else{
		Vuelto=StrPag - StrTot;
	}
	Vuelto=Vuelto.toFixed(2);
	document.getElementById("TxtVuelto").value=Vuelto;
}
//**************************************************************************
function TDP(){
	var StrTdp=document.getElementById("CboTdp").value;
	document.getElementById("TxtOpe").value="";
	document.getElementById("TxtOpe").readOnly=true;
	//Habilitar / Deshabilitar
	if(StrTdp=="CONTADO"){				
		document.getElementById("CboTar").value="";
		document.getElementById("CboTar").disabled=true;
		document.getElementById("CboBancos").value="";
		document.getElementById("CboBancos").disabled=true;
		document.getElementById("TxtPagarCon").disabled=false;
		document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
		document.getElementById("CboMon").disabled=false;
		document.getElementById("CboMon").value="SOLES";							
	}
	if(StrTdp=="CREDITO"){
		document.getElementById("CboTar").value="";
		document.getElementById("CboTar").disabled=true;
		document.getElementById("CboBancos").value="";
		document.getElementById("CboBancos").disabled=true;
		document.getElementById("TxtPagarCon").disabled=false;
		document.getElementById("CboMon").disabled=false;
		document.getElementById("CboMon").value="SOLES";							
	}
	if(StrTdp=="TARJETA"){
		document.getElementById("CboTar").value="";
		document.getElementById("CboTar").disabled=false;
		document.getElementById("CboBancos").value="";
		document.getElementById("CboBancos").disabled=false;
		document.getElementById("TxtPagarCon").disabled=true;
		document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
		document.getElementById("CboMon").disabled=true;
		document.getElementById("CboMon").value="SOLES";											
	}
	if(StrTdp=="DEPOSITO"){
		document.getElementById("CboTar").value="";
		document.getElementById("CboTar").disabled=true;
		document.getElementById("CboBancos").value="";
		document.getElementById("CboBancos").disabled=false;
		document.getElementById("TxtPagarCon").disabled=true;
		document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
		document.getElementById("CboMon").disabled=true;
		document.getElementById("CboMon").value="SOLES";		
		document.getElementById("TxtOpe").readOnly=false;
								
	}
	//
	if(StrTdp=="CONTADO"){
		document.getElementById("TxtPagarCon").readOnly=false;
		document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;		
		document.getElementById("TxtVuelto").value="0.0";
		document.getElementById("CboMon").disabled=false;
	}else{
		document.getElementById("TxtPagarCon").readOnly=true;
		document.getElementById("TxtPagarCon").value="0.0";
		document.getElementById("CboMon").disabled=true;
	}
	
}
function AutoNumeracion(estado){
	document.getElementById("TxtSer").value="";
	document.getElementById("TxtNum").value="";
	var Plom=document.getElementById("TxtTC").style.backgroundColor;
	var Blan=document.getElementById("TxtCod").style.backgroundColor;
	if(estado>0){
		document.getElementById("TxtSer").readOnly=true;
		document.getElementById("TxtNum").readOnly=true;
		document.getElementById("TxtSer").style.backgroundColor=Plom;
		document.getElementById("TxtNum").style.backgroundColor=Plom;
		if(estado==1){
		document.getElementById("TxtCliente").focus();
		}
	}else{
		document.getElementById("TxtSer").readOnly=false;
		document.getElementById("TxtNum").readOnly=false;
		document.getElementById("TxtSer").style.backgroundColor=Blan;
		document.getElementById("TxtNum").style.backgroundColor=Blan;
		document.getElementById("TxtSer").focus();
	}
}
//**************************************************************************
function CalcularIMPORTE(){
	var Importe=document.getElementById("T_Importe").value;
	var stt=0;
	var igv=0;
	var tot=0;	
	var uno=0;
	if(Importe.trim().length==0) Importe="0";
	Importe=parseFloat(Importe);
	if(document.getElementById("ChN_INC").checked){
		stt=Importe;
		igv=stt * 0.18;
		igv=igv.toFixed(2);
		tot=parseFloat(stt) + parseFloat(igv);
	}else{
		uno=Importe / 118;
		//uno=uno.toFixed(2);
		igv=uno * 18;
		igv=igv.toFixed(2);
		stt=parseFloat(Importe) - parseFloat(igv);
		tot=parseFloat(stt)+parseFloat(igv);
	}
	document.getElementById("T_ST").value=formato_numero(stt,2,".");
	document.getElementById("T_IG").value=formato_numero(igv,2,".");
	document.getElementById("T_TO").value=formato_numero(tot,2,".");
	VUELTO();	
}
function fCls(){
	document.getElementById("TxtIdCliente").value="0";
	document.getElementById("TxtCliente").value="";
	document.getElementById("TxtDIR").value="";
	document.getElementById("TxtRuc").value="";
}
//**************************************************************************
function fImporte(){
	var Pre=document.getElementById("TxtPre").value;
	var Can=document.getElementById("TxtCant").value;
	var Importe=parseFloat("0");
	if(Pre.trim().length==0)Pre="0";
	if(Can.trim().length==0)Can="0";
	Pre=parseFloat(Pre);
	Can=parseFloat(Can);
	Importe=Pre * Can;
	Importe=Importe.toFixed(2);
	document.getElementById("TxtImp").value=Importe;
}
//**************************************************************************
function fKiller(lpIndex){
	document.getElementById("Pro_TxtId").value=lpIndex;
	document.getElementById("TxtAc").value="KILLER";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fGetTabla(){	
var Cod=document.getElementById("TxtCod").value;
var Des=document.getElementById("TxtDes").value;
var Mar=document.getElementById("TxtMarca").value;
var Alm=document.getElementById("CboAlm").value;
Cod=Cod.replace("+", "@");
Des=Des.replace("+", "@");
if(Des.trim().length>0 || Cod.trim().length>0 || Mar.trim().length>0){	
	DivDatos = document.getElementById("TAB_AJAX");
	DivCaption = document.getElementById("TAB_CAPTION");
	ajax=CreateAJAX();
var StrU="ajax_funciones.php?Cmd=VENTAS_PROD_FILTRAR&TxtPar="+Des+"&TxtPar2="+Alm+"&TxtPar3="+Mar+"&TxtPar4="+Cod;
	ajax.open("GET",StrU);	
	ajax.onreadystatechange=function() {
		   if (ajax.readyState==4) {
					var StrDatos=ajax.responseText;
					if(StrDatos.trim().length>0){			  
					   DivDatos.innerHTML = StrDatos;
					   DivCaption.style.visibility="visible";
					   DivDatos.style.visibility="visible";	
					   document.getElementById("TAB_AJAX").scrollTop=0;
					}else{
						DivCaption.style.visibility="hidden";
						DivDatos.style.visibility="hidden";	
					}
		   }
	}
	ajax.send(null);
}
//
}
function CerrarDIV(){
	DivDatos = document.getElementById("TAB_AJAX");
	DivCaption = document.getElementById("TAB_CAPTION");
	DivCaption.style.visibility="hidden";
	DivDatos.style.visibility="hidden";	
	document.getElementById("TxtDes").focus();
}
//**************************************************************************
function PP(Pre){
	var Mon=document.getElementById("CboMon").value;
	var Tca=document.getElementById("TxtTC").value;
	Mon=Mon.trim();Pre=Pre.trim();Tca=Tca.trim();
	if(Mon.length==0)Mon="SOLES";
	if(Pre.length==0)Pre="0";
	if(Tca.length==0)Tca="1";
	Pre=parseFloat(Pre);Tca=parseFloat(Tca);
	if(Mon=="DOLARES"){
		Pre=Pre / Tca;Pre=Pre.toFixed(2);		
	}	
	return Pre;
}
function fGetProdDatos_Id(lpStrId){
	if(lpStrId.trim().length>0){
	DivDatos = document.getElementById("DivDatosProd");
	ajax=CreateAJAX();
	ajax.open("GET", "ajax_funciones.php?Cmd=VEN_GET_PROD_DATOS_X_ID&TxtPar="+lpStrId);	
	ajax.onreadystatechange=function() {
	   if (ajax.readyState==4) {			  
		   DivDatos.innerHTML = ajax.responseText
		   var Des=document.getElementById("Pro_TxtDes").value;
		   if(Des.trim().length==0){
			   document.getElementById("Pro_TxtId").value="";
			   document.getElementById("Pro_TxtDes").value="";
			   document.getElementById("Pro_TxtCod").value="";
			   document.getElementById("Pro_TxtMarca").value="";
			   document.getElementById("Pro_TxtPre").value="";
			   document.getElementById("Pro_TxtPreM").value="";
			   document.getElementById("TxtDes").value="";
			   document.getElementById("TxtPre").value="";				   
			   document.getElementById("TxtPreM").innerHTML="0.00";
			   document.getElementById("TxtCant").value="";
			   document.getElementById("TxtImp").value="";
			   document.getElementById("TxtCod").value="";				   
			   alert("Codigo no registrado");
			   document.getElementById("TxtCod").focus();
		   }else{
			   document.getElementById("TxtCod").value=document.getElementById("Pro_TxtCod").value;
			   document.getElementById("TxtMarca").value=document.getElementById("Pro_TxtMarca").value;
			   document.getElementById("TxtDes").value=document.getElementById("Pro_TxtDes").value;
			   document.getElementById("TxtPre").value=PP(document.getElementById("Pro_TxtPre").value);
			   document.getElementById("TxtPreM").innerHTML=PP(document.getElementById("Pro_TxtPreM").value);
			   document.getElementById("TxtCant").value="1";
			   document.getElementById("TxtImp").value=document.getElementById("TxtPre").value;
			   document.getElementById("TxtPre").focus();				   
		   }
		   DivDatos = document.getElementById("TAB_AJAX");
		   DivCaption = document.getElementById("TAB_CAPTION");
		   DivCaption.style.visibility="hidden";
		   DivDatos.style.visibility="hidden";						   
	   }
	}
    ajax.send(null);
	}
}
//
function AjBuscar(){
	var cod=document.getElementById("TxtCod").value;
	cod=cod.replace("+", "@");		
	ajax=CreateAJAX();
	var Z="";
	Z="ajbar.php?C=V&P1="+cod;
	//alert(Z);
	ajax.open("GET",Z,false);	
	ajax.send(null);
	var StrHtml=ajax.responseText;
	return StrHtml.trim();
}
//
function z(lpStrId){
	if(lpStrId.trim().length>0){
	var Alm=document.getElementById("CboAlm").value;
	DivDatos = document.getElementById("DivDatosProd");
	ajax=CreateAJAX();
	var URL="ajax_funciones.php?Cmd="+
	        "VEN_GET_PROD_DATOS_X_ID&TxtPar="+lpStrId+"&TxtPar2="+Alm;
	ajax.open("GET", URL);	
	ajax.onreadystatechange=function() {
	   if (ajax.readyState==4) {			  
		   DivDatos.innerHTML = ajax.responseText
		   var Des=document.getElementById("Pro_TxtDes").value;
		   if(Des.trim().length==0){
			   document.getElementById("Pro_TxtId").value="";
			   document.getElementById("Pro_TxtDes").value="";
			   document.getElementById("Pro_TxtCod").value="";
			   document.getElementById("Pro_TxtMarca").value="";
			   document.getElementById("Pro_TxtPre").value="";
			   document.getElementById("Pro_TxtPreM").value="";
			   document.getElementById("TxtDes").value="";
			   document.getElementById("TxtPre").value="";				   
			   document.getElementById("TxtPreM").innerHTML="***";
			   document.getElementById("TxtCant").value="";
			   document.getElementById("TxtImp").value="";
			   document.getElementById("TxtCod").value="";
			   document.getElementById("TxtMarca").value="";
			   alert("Codigo no registrado");
			   document.getElementById("TxtCod").focus();
		   }else{
   			   SetValores();
		   }
		   DivDatos = document.getElementById("TAB_AJAX");
		   DivCaption = document.getElementById("TAB_CAPTION");
		   DivCaption.style.visibility="hidden";
		   DivDatos.style.visibility="hidden";
	   }
	}
    ajax.send(null);
	}
}
function ObtenerPrecio(){
	var k=jVal(gv("TxtCant"));
	var pxu=jVal(gv("TXT_PXU"));
	var pxc=jVal(gv("TXT_PXC"));
	var pxm=jVal(gv("TXT_PXM"));
	if(k<=99){
		sv("TxtPre",pxu);
	}else{
		if(k>=100 && k<=999){
			sv("TxtPre",pxc);
		}else{
			sv("TxtPre",pxm);
		}
	}
}
function SetValores(){
   document.getElementById("TxtCod").value=document.getElementById("Pro_TxtCod").value;
   document.getElementById("TxtDes").value=document.getElementById("Pro_TxtDes").value;
   document.getElementById("TxtMarca").value=document.getElementById("Pro_TxtMarca").value;   
   document.getElementById("TxtPre").value=gv("TXT_PXU");
   //
   var s="PxU:"+gv("TXT_PXU")+" /PxC:"+gv("TXT_PXC")+" /PxM:"+gv("TXT_PXM");
   //
   document.getElementById("TxtPreM").innerHTML=s;//PP(document.getElementById("Pro_TxtPreM").value);
   document.getElementById("TxtCant").value="1";
   document.getElementById("TxtImp").value=document.getElementById("TxtPre").value;
   document.getElementById("TxtPre").focus();	
}
//**************************************************************************
function fGetProdDatos(lpStrCod){
	if(lpStrCod.trim().length>0){
	DivDatos = document.getElementById("DivDatosProd");
	ajax=CreateAJAX();
	ajax.open("GET", "ajax_funciones.php?Cmd=VEN_GET_PROD_DATOS&TxtPar="+lpStrCod);	
	ajax.onreadystatechange=function() {
	   if (ajax.readyState==4) {			  
		   DivDatos.innerHTML = ajax.responseText
		   var Des=document.getElementById("Pro_TxtDes").value;
		   if(Des.trim().length==0){
			document.getElementById("Pro_TxtId").value="";
			document.getElementById("Pro_TxtDes").value="";
			document.getElementById("Pro_TxtMarca").value="";
			document.getElementById("Pro_TxtPreM").value="";
			document.getElementById("TxtDes").value="";
			document.getElementById("TxtPre").value="";
			document.getElementById("TxtPreM").innerHTML="***";
			document.getElementById("TxtCant").value="";
			document.getElementById("TxtImp").value="";
			document.getElementById("TxtCod").value="";
			document.getElementById("TxtMarca").value="";
			alert("Codigo no registrado");
			document.getElementById("TxtCod").focus();
		   }else{
			document.getElementById("TxtMarca").value=document.getElementById("Pro_TxtMarca").value;
			document.getElementById("TxtDes").value=document.getElementById("Pro_TxtDes").value;
			document.getElementById("TxtPre").value=PP(document.getElementById("Pro_TxtPre").value);
			document.getElementById("TxtPreM").innerHTML=PP(document.getElementById("Pro_TxtPreM").value);
			document.getElementById("TxtCant").value="1";
			document.getElementById("TxtImp").value=document.getElementById("TxtPre").value;
			document.getElementById("TxtPre").focus();
		   }
	   }
	}
    ajax.send(null);
	}
}
//**************************************************************************
function fGetRuc(lpStrPro,Obj){
	var StrProveedor=lpStrPro;
	ajax=CreateAJAX();
	ajax.open("GET", "ajax_funciones.php?Cmd=GET_RUC&TxtPar="+StrProveedor);	
	ajax.onreadystatechange=function() {
		   if (ajax.readyState==4) {			   	   
				   document.getElementById(Obj).value=ajax.responseText;
				   Obj=Obj+"_";
				   document.getElementById(Obj).value=ajax.responseText;
		   }
	}
    ajax.send(null);
}
//**************************************************************************
function fGetProveedor(lpStrRuc,Obj){
	var StrRucH=document.getElementById("TxtRuc_").value;
	var StrRuc=lpStrRuc;
	if(StrRuc!=StrRucH){
		ajax=CreateAJAX();
		ajax.open("GET", "ajax_funciones.php?Cmd=GET_PROVEEDOR&TxtPar="+StrRuc);	
		ajax.onreadystatechange=function() {
			   if (ajax.readyState==4) {
					   var StrPro=ajax.responseText;
					   if(StrPro.trim().length==0){
						   	alert("Numero de ruc no registrado");
						   	document.getElementById(Obj).value="";
						   	document.getElementById(Obj).focus();
					   }else{
							document.getElementById(Obj).value=StrPro;
					   }
			   }
		}
		ajax.send(null);
	}

}
//**************************************************************************
function fCancelarPHP(){	
	document.getElementById("TxtAc").value="C";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fCargar(){
	var A=document.getElementById("CboTemp").value;
	var B=document.getElementById("TxtTemp").value;
	if(A.trim().length==0){
		alert("Seleccione el comprobante correspondiente");
		document.getElementById("CboTemp").focus();
		return;
	}
	if(B.trim().length==0){
		alert("Ingrese la serie/numero correspondiente");
		document.getElementById("TxtTemp").focus();
		return;
	}
	document.getElementById("TxtAc").value="LOAD";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fAgregar(){
	var Pro_Id=document.getElementById("Pro_TxtId").value;
	var Pro_Cod=document.getElementById("Pro_TxtCod").value;
	var Pro_Des=document.getElementById("Pro_TxtDes").value;
	
	var Cod=document.getElementById("TxtCod").value;
	var Des=document.getElementById("TxtDes").value;
	var Pre=document.getElementById("TxtPre").value;
	var PreM=document.getElementById("TxtPreM").innerHTML;
	var Can=document.getElementById("TxtCant").value;
		
	Pro_Id=Pro_Id.trim().toUpperCase();
	Pro_Cod=Pro_Cod.trim().toUpperCase();
	Pro_Des=Pro_Des.trim().toUpperCase();
	
	Cod=Cod.trim().toUpperCase();
	Des=Des.trim().toUpperCase();
	
	if(Cod!=Pro_Cod){
		alert("El codigo del producto ha sido alterado");
		document.getElementById("TxtCod").focus();
		return;
	}
	if(Des!=Pro_Des){
		alert("La descripcion del producto ha sido alterada");
		document.getElementById("TxtDes").focus();
		return;
	}
	//
	Pre=Pre.trim();
	PreM=PreM.trim();
	if(Pre.length==0){
		alert("Ingrese el precio de venta");
		document.getElementById("TxtPre").focus();
		return;
	}
	if(Pre.length==0)Pre="0";
	if(PreM.length==0)PreM="0";
	Pre=parseFloat(Pre);
	PreM=parseFloat(PreM);
	if(PreM>Pre){
		var Rpta = confirm("El precio de venta ES MENOR al precio de venta minimo,¿Aun asi desea continuar?")		
		if (Rpta==false){
			document.getElementById("TxtPre").focus();
			return;
		}
	}
	//
	document.getElementById("TxtAc").value="ADD";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fGuardar(){
	var Alm=gv("CboAlm");
	var Fec=gv("TxtFec");
	var Cli=gv("TxtCliente");
	var Com=gv("CboCom");
	var Num=gv("TxtNum");
	var Ruc=gv("TxtRuc");
	var Ser=gv("TxtSer");
	var Tdp=gv("CboTdp");
	var Ban=gv("CboBancos");
	var Pagar=gv("TxtPagarCon");
	var Ope=gv("TxtOpe");
	
	if(Alm.trim().length==0){
		alert("Seleccione un almacen");
		document.getElementById("CboAlm").focus();
		return;
	}
	if(Fec.trim().length==0){
		alert("Ingrese una fecha");
		document.getElementById("TxtFec").focus();
		return;
	}
	if(EsFecha(Fec)==false){
		alert("Fecha no valida, la fecha debe ser ingresada segun el formato");
		document.getElementById("TxtFec").focus();
		return;
	}	
	if(Com.trim().length==0){
		alert("Seleccione un comprobante");
		document.getElementById("CboCom").focus();
		return;
	}
	if(document.getElementById("ChN_AUTO").checked==false){
		if(Ser.trim().length==0){
			alert("Ingrese la serie del comprobante.");
			document.getElementById("TxtSer").focus();
			return;
		}
		if(Num.trim().length==0){
			alert("Ingrese el numero de comprobante");
			document.getElementById("TxtNum").focus();
			return;
		}
	}		
	if(Tdp=="CONTADO"){		
		TOT=parseFloat(document.getElementById("T_TO").value);
		if(Pagar==0){
			//document.getElementById("TxtPagarCon").value=TOT;
			//alert("Ingrese un monto en *PAGAR CON*");
			document.getElementById("TxtPagarCon").value=TOT;
			//return;
		}		
		Pagar=parseFloat(document.getElementById("TxtPagarCon").value);
	
		if(Pagar<TOT){
			alert("El monto a pagar debe ser mayor o igual al TOTAL");
			document.getElementById("TxtPagarCon").focus();
			return;
		}
	}
	if(Tdp=="TARJETA"){		
		tar=document.getElementById("CboTar").value;
		if(jLen(Cli)==0){
			alert("Seleccione el cliente");
			jFocus("CmdSel");
			return;
		}
		if(tar.trim().length==0){
			alert("Seleccione la tarjeta correspondiente");
			document.getElementById("CboTar").focus();
			return;
		}
		ban=document.getElementById("CboBancos").value;
		if(ban.trim().length==0){
			alert("Seleccione el banco correspondiente");
			document.getElementById("CboBancos").focus();
			return;
		}
	}
	if(Tdp=="DEPOSITO"){	
		if(jLen(Cli)==0){
			alert("Seleccione el cliente");
			jFocus("CmdSel");
			return;
		}
		ban=document.getElementById("CboBancos").value;
		if(ban.trim().length==0){
			alert("Seleccione el banco correspondiente");
			document.getElementById("CboBancos").focus();
			return;
		}
		if(jLen(Ope)==0){
			alert("Ingrese el numero de operacion");
			jF("TxtOpe");
			return;
		}
	}
	if(Tdp=="CREDITO"){
		if(jLen(Cli)==0){
			alert("Seleccione el cliente");
			jFocus("CmdSel");
			return;
		}

	}
	if(Com=="FACTURA"){
		if(Ruc.trim().length==0){
		alert("Seleccione un cliente que tenga ruc");
		document.getElementById("CmdSel").focus();
		return;
		}
	}
	if(document.getElementById("CmdG").value=="Guardar"){
		var Rpta = confirm("Esta seguro que desea Guardar?")		
		if (Rpta==false){
			return;
		}
		document.getElementById("TxtAc").value="G";
	}else{
		var Rpta = confirm("Esta seguro que desea modificar?")		
		if (Rpta==false){
			return;
		}
		document.getElementById("TxtAc").value="M";
	}
	document.getElementById("Frm").submit();
}
/**************************************************************************
	onkeypress="return pulsar(event);"
**************************************************************************/
function pulsar(e) { 	
	var tecla = (document.all) ? e.keyCode :e.which; 
	var Obj=event.srcElement.name;	
	if(Obj=="TxtNom"){
		if(tecla==13){			
			document.getElementById('CmdG').click();			
		}
	}	
	return (tecla!=13); 
} 
//**************************************************************************
