var arrPartidas=new Array();var intContaPartidas=0;var objectAgregoProducto=null;var MuestraPuntos=0;var MuestraVNegocio=0;var miClassPrecargar="0";var contador=0;var DialogMicompra;var textVistaDetalle="<div id=miProductoClave>::DESCRIPCION::<BR>::ROTULOCANTIDAD:: ::CANTIDAD::<BR>::ROTULOIMPORTE:: ::IMPORTE::</div>";var rotuloCantidad="_CANTIDAD";var rotuloImporte="_IMPORTE";var objSelOfertas=null;var objSeleccionaOfertas=null;var idioma=1;var tieneAutocompra=0;var direccionValidaText="";var direccionValidaInt="";var contadorPartida=1;var SoloDireccionFacturacion=false;var autosuma=false;var inicioSesion=0;var muestraflete=0;var camposDirFact="";var camposDirEnvio="";dojo.require("dojox.widget.FisheyeLite");dojo.require("dijit.form.NumberSpinner");function despuesdeCargar(){setTimeout("obtenerProductosAJAX(miClassPrecargar,null,null,true);",4000);if(tieneAutocompra==1){setTimeout("cargapPeriodicidad()",8000)}terminaEspera()}function delayCargapPeriodicidad(a){if(a){setTimeout("cargapPeriodicidad(true)",8000)}else{setTimeout("cargapPeriodicidad(false)",8000)}terminaEspera()}function obtenerProductosAJAX(h,b,f,d,e){try{verSeleccionProductos();if(d==null){d=false}if(f!=null){f.selectedIndex=0}if(h!="0"){if(b==null){b=1}var g=document.getElementById("miClasif");if(h==null){if(g.value!=0){h=g.value}else{alert("error");return}}else{if(g.value=="0"){g.value=h}}esperaMientras("");dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=MUESTRAPRODUCTOS",load:function(j){terminaEspera();j=trim(j);if(!d){if(document.getElementById("PRODUCTSELECTEDID")!=null){document.getElementById("PRODUCTSELECTEDID").value="0"}if(document.getElementById("seleccionClave")!=null){document.getElementById("seleccionClave").value=""}if(document.getElementById("seleccionDescripcion")!=null){document.getElementById("seleccionDescripcion").value=""}if(document.getElementById("seleccionPuntos")!=null){document.getElementById("seleccionPuntos").value="0"}if(document.getElementById("seleccionNegocio")!=null){document.getElementById("seleccionNegocio").value="0"}if(document.getElementById("seleccionPrecio")!=null){document.getElementById("seleccionPrecio").value="0.0"}if(document.getElementById("BTN_SELECT_AGREGAR")!=null){document.getElementById("BTN_SELECT_AGREGAR").disabled=true}if(document.getElementById("divProductSelected")!=null){document.getElementById("divProductSelected").innerHTML=""}if(document.getElementById("divProductList")!=null){document.getElementById("divProductList").style.display="block"}if(document.getElementById("divProductList")!=null){document.getElementById("divProductList").innerHTML=j}}if(j.substring(0,5)!="ERROR"){if(document.getElementById("divProductList")!=null){document.getElementById("divProductList").style.display="block"}if(document.getElementById("divProductList")!=null){document.getElementById("divProductList").innerHTML=j}}else{}setTimeout("document.location.href = '#INICIO' ",200)},error:function(j){alert(j)},timeout:80000,content:{ID:h,PAGINA:b,ESECOMMERCE:d,CLIENTE:document.getElementById("CLIENTE").value,ORIGENPEDIDOVENTA:document.getElementById("ORIGENPEDIDOVENTA").value,BUSQUEDA:e,IDIOMA:idioma}})}}catch(c){var a="obtenerProductosAJAX\nThere was an error on this page.\n\n";a+="Error description: "+c.description+"\n\n";a+="Click OK to continue.\n"+c+"\n";alert(a)}terminaEspera()}function despues(){document.getElementById("divAdicionalPanel5").style.display="none";terminaEspera()}function creaFilaenMisproductosBySelect(){var a=document.getElementById("PRODUCTSELECTEDCANTIDAD");var b=document.getElementById("seleccionClave");if(parseInt(a.value)>0){creaFilaenMisproductos(b.value,a.value)}}function creaFilaenMisproductosBySet(){var b=document.getElementById("SET_CLAVE");var a=document.getElementById("SET_CANTIDAD");if(b.value!=""&&parseInt(a.value)>0){creaFilaenMisproductos(b.value,a.value);objSelectedCantidad=b}}function creaFilaenMisproductosDeta(k,d,g,e){if(document.getElementById("divMiCompra")!=null){document.getElementById("divMiCompra").style.display="block";var f=parseInt(document.getElementById("Decimales").value);var l=document.getElementById("tablaMiCompraTop").getElementsByTagName("tbody")[0];var b=existeProductoDeta(k);if(b!=null){g=parseFloat(g);var h=buscarElemento(b.parentNode.parentNode,"INPUT","CANTIDAD");h.value=parseFloat(e);buscarElemento(b.parentNode.parentNode,"div","miProductoClave").innerHTML=textVistaDetalle.replace("::DESCRIPCION::",d).replace("::IMPORTE::",FormatNumber(g,f,true,false,true)).replace("::CANTIDAD::",h.value).replace("::ROTULOIMPORTE::",rotuloImporte).replace("::ROTULOCANTIDAD::",rotuloCantidad)}else{contador++;var c=document.createElement("TR");var j=document.createElement("TD");var a=document.createElement("TD");a.appendChild(creaHidden("CLAVE"+k,k));a.appendChild(creaHidden("CANTIDAD"+k,e));j.innerHTML=textVistaDetalle.replace("::DESCRIPCION::",d).replace("::IMPORTE::",FormatNumber(g,f,true,false,true)).replace("::CANTIDAD::",e).replace("::ROTULOIMPORTE::",rotuloImporte).replace("::ROTULOCANTIDAD::",rotuloCantidad);c.appendChild(a);c.appendChild(j);l.appendChild(c)}}}function existeProductoDeta(b){var c=document.getElementById("tablaMiCompraTop").getElementsByTagName("input");for(var a=0;a<c.length;a++){if(c[a].value==b){return c[a]}}return null}function cargapPeriodicidad(a){if(document.getElementById("ORIGENPEDIDOVENTA").value=="1"){esperaMientras("");dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=CARGARPERIODICIDAD",load:function(c){c=trim(c);if(c.length>0){try{var d=c.split("{}");if(d.length>0){IniVar(Dias,Meses,Periodos,Titulo1,Titulo2,Titulo3,Titulo4,Titulo5,Titulo6,Titulo7,Titulo8,Titulo9,Titulo10);document.getElementById("PERIODICIDAD").value=d[0];document.getElementById("PERIODICIDAD").onchange();switch(parseInt(d[0])){case 1:document.getElementById("PER_FECHA").value=d[1];break;case 2:document.getElementById("PER_EVERY").value=d[2];document.getElementById("PER_FECHA").value=d[3];break;case 3:document.getElementById("PER_EVERY").value=d[4];document.getElementById("PER_FECHA").value=d[3];if(d[5]=="1"){document.getElementById("PER_DIA1").checked=true}if(d[12]=="1"){document.getElementById("PER_DIA2").checked=true}if(d[13]=="1"){document.getElementById("PER_DIA3").checked=true}if(d[14]=="1"){document.getElementById("PER_DIA4").checked=true}if(d[15]=="1"){document.getElementById("PER_DIA5").checked=true}if(d[16]=="1"){document.getElementById("PER_DIA6").checked=true}if(d[17]=="1"){document.getElementById("PER_DIA7").checked=true}break;case 4:document.getElementById("PER_FECHA").value=d[3];if(document.getElementById("PER_TIPO_MES1")!=null){document.getElementById("PER_TIPO_MES1").value=d[6]}document.getElementById("PER_EVERY").value=d[7];document.getElementById("PER_ORD").value=d[8];document.getElementById("PER_DIA").value=d[9];break;case 5:document.getElementById("PER_FECHA").value=d[3];document.getElementById("PER_EVERY").value=d[10];document.getElementById("PER_MES").value=d[11];break}}}catch(b){terminaEspera();alert(b)}try{if(a){cargaFilaenMisproductos()}else{terminaEspera()}}catch(b){terminaEspera();alert(b)}}else{}},error:function(c,b){alert("ERROR:"+c+"\n"+b.args)},timeout:80000,content:{CLIENTE:document.getElementById("CLIENTE").value}});terminaEspera()}}function cargaFilaenMisproductos(){dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=CARGARPRODUCTOS",load:function(L){L=trim(L);if(L.length>0){var n=L.split("|");for(var C=0;C<n.length;C++){if(n[C].length>1){var z=n[C].split("{}");var E=z[1];var G=z[2];var K=z[3];var s=z[4];var M=z[5];var h=z[6];var b=z[7];var J=z[8];var H=z[9];var p=z[10];var v=z[11];var c=z[12];var y=z[13];var f=z[14];var a=z[18];var O=z[19];var N=z[20];var w=z[21];var B=z[22];var k=z[23];var j=z[24];var I=z[25];var x=z[26];var A=z[27];var t=z[28];var r=z[29];var q=z[30];var e=z[31];var o=z[32];var g=document.getElementById("PorDescuento").value;var u=f;var d=2;var l=parseFloat(u)*parseFloat(s);k=FormatNumber(k,d,true,false,true);k=k.replace(",","");u=FormatNumber(u,d,true,false,true);u=u.replace(",","");f=FormatNumber(f,d,true,false,true);f=f.replace(",","");var m=new PartidaVenta(contadorPartida,E,G,K,s,M,h,b,J,H,p,v,c,y,f,g,u,l,a,O,N,w,B,k,j,I,x,A,t,r,q,e,o);document.getElementById("COTIZACION").value=z[0];contadorPartida++;m.OcultarDisponibles();m.OcultarApartados();m.OcultarExistencia();m.OcultarCreditos();m.OcultarNoSerie();m.MostrarBotonEditar();var D=document.getElementById("cont");D.setAttribute("value",parseInt(D.value,0)+1);var F=document.getElementById("PARTIDAS").getElementsByTagName("tbody")[0];m.GeneraPartida(F);intContaPartidas++;arrPartidas[intContaPartidas]=m}}if(document.getElementById("TIPOPANTALLA")=="COTIZACION"){ObtenFlete()}else{ObtenOfertas()}m.CalculaPrecio()}else{}terminaEspera()},error:function(b,a){terminaEspera();alert("ERROR::(3)"+b+"::"+a.args)},timeout:80000,content:{CLIENTE:document.getElementById("CLIENTE").value}})}function creaFilaenMisproductos(d,c,a,b){if(a==null){a=false}if(b==null){b=false}esperaMientras("");dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=BUSCARPRODUCTO_FIN",load:function(U){terminaEspera();U=trim(U);if(U.indexOf("ERROR")!="0"){var Y=U.split(",");var o=Y[0];var K=Y[1];var J=Y[2];var V=Y[4];var C=parseFloat(Y[6]);var G=parseFloat(Y[7]);var R=parseInt(Y[8]);var z=parseInt(Y[10]);var y=parseInt(Y[11]);var x=parseInt(Y[12]);var N=parseInt(Y[13]);var k=parseFloat(Y[14]);var X=parseFloat(Y[15]);var f=parseFloat(Y[16]);var n=parseFloat(Y[17]);var g=parseFloat(Y[18]);var v=parseFloat(Y[19]);var W=parseFloat(Y[20]);var Q=parseFloat(Y[21]);var L=parseInt(Y[22]);var u=parseInt(Y[23]);var B=parseInt(Y[24]);var h=parseInt(Y[25]);var E=parseInt(Y[26]);var q=parseFloat(Y[27]);var p=parseFloat(Y[28]);var O=parseFloat(Y[29]);var D=parseFloat(Y[30]);var F=parseFloat(Y[31]);var e=Y[32];var P=document.getElementById("ORIGENPEDIDOVENTA");if(P.value=="2"||P.value=="3"){k=n;q=n}var m=document.getElementById("PorDescuento").value;var T="";var A=k;var j=2;var r=parseFloat(A);if(!b){r=parseFloat(A)*parseFloat(c)}A=FormatNumber(A,j,true,false,true);k=FormatNumber(k,j,true,false,true);var t=BuscarCodigoenLista(o,"",false);var s=null;if(t!=null){t.objExist.setValor(C);t.objApartados.setValor(G);var M=C-G;var w=parseFloat(t.objCantidad.strValor);if(!b){w=parseFloat(t.objCantidad.strValor)+parseFloat(c)}if(b){t.objPrecio.setValor(k);t.objPrecioNeto.setValor(A);t.objPrecioReal.setValor(q)}var l=parseFloat(t.objPrecio.strValor)*w;if(N==1){if(M>=w){t.objCantidad.setValor(w);t.objImport.setValor(l)}else{muestraMensajeError("FALTA EXISTENCIA PARA PODER VENDER EL PRODUCTO");return}}else{t.objCantidad.setValor(w);t.objImport.setValor(l)}bitDuplicado=true}else{var S=0;if(document.getElementById("AUTOCOMPRA"+d)!=null){S=(document.getElementById("AUTOCOMPRA"+d).checked?"1":"0")}s=new PartidaVenta(contadorPartida,d,J,T,c,V,n,g,Q,L,u,B,h,E,k,m,A,r,f,X,W,C,G,q,p,O,D,F,z,y,x,MuestraPuntos,MuestraVNegocio,S);contadorPartida++;s.OcultarDisponibles();s.OcultarApartados();s.OcultarExistencia();s.OcultarCreditos();s.OcultarNoSerie();if(tieneAutocompra=="1"){s.MostrarAutocompra()}var H=document.getElementById("cont");H.setAttribute("value",parseInt(H.value,0)+1);var I=document.getElementById("PARTIDAS").getElementsByTagName("tbody")[0];s.GeneraPartida(I);intContaPartidas++;arrPartidas[intContaPartidas]=s}if(document.getElementById("TIPOPANTALLA")=="COTIZACION"){ObtenFlete()}else{ObtenOfertas()}if(P.value=="1"){if(s!=null){s.dblDescCliente=m;s.AsignaMotDescuento(1);s.CalculaPrecio()}else{if(t!=null){t.dblDescCliente=m;t.AsignaMotDescuento(1);t.CalculaPrecio()}}}}else{muestraMensajeError(U)}},error:function(f,e){alert("ERROR::(2)"+f+"::"+e.args)},timeout:80000,content:{CLAVE:d,CANTIDAD:c}})}function BuscarCodigoenLista(b,c,j){var g=false;var a=null;if(arrPartidas.length>0){for(var d=1;d<arrPartidas.length;d++){var f=arrPartidas[d];if(f.Eliminada==false&&f.objEsRegalo.strValor=="0"){try{if(f.objCve.strValor==b){g=true;a=f}}catch(e){txt="There was an error on this page.\n\n";txt+="Error description: "+e.description+"\n\n";txt+="Click OK to continue.\n\n"}}}}if(j==true){return g}else{return a}}function obtenerInfoproductoBySet(a){esperaMientras("");dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=MUESTRAINFOPRODUCTBYSET",load:function(e){terminaEspera();e=trim(e);if(e.substring(0,5)!="ERROR"){var b=e.split(",");creFilaMisproductos(b[0],b[1],b[2],b[5],document.getElementById("SET_CANTIDAD").value,b[3],b[4])}else{muestramensajeError(e)}var d=document.getElementById("SET_CLAVE");var c=document.getElementById("SET_CANTIDAD");c.value="1";d.value="";d.focus()},error:function(b){alert(b)},timeout:80000,content:{CLAVE:a}})}function obtenerInfoproductoBySelect(c,d){esperaMientras("");var b=document.getElementById("divProductSelected");b.innerHTML="";var a=document.createElement("IMG");a.setAttribute("src",c.src);b.appendChild(a);dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=MUESTRAINFOPRODUCT",load:function(f){f=trim(f);if(f.substring(0,5)!="ERROR"){var e=f.split(",");terminaEspera();document.getElementById("PRODUCTSELECTEDID").value=d;document.getElementById("seleccionClave").value=e[0];document.getElementById("seleccionDescripcion").value=e[1];document.getElementById("seleccionPuntos").value=e[2];document.getElementById("seleccionNegocio").value=e[3];document.getElementById("seleccionPrecio").value=e[4];document.getElementById("PRODUCTSELECTEDCANTIDAD").select();document.getElementById("PRODUCTSELECTEDCANTIDAD").focus();document.getElementById("BTN_SELECT_AGREGAR").disabled=false}else{alert(f)}},error:function(e){alert(e)},timeout:80000,content:{ID:d}})}function onKeyUpCreaFilaenMisproductosBySelect(a){if(a.keyCode==13&&!document.getElementById("BTN_SELECT_AGREGAR").disabled){if(IsNumeric(document.getElementById("PRODUCTSELECTEDCANTIDAD").value)){creaFilaenMisproductosBySelect()}}}function buscaClaveRepetida(l,h){var c=document.getElementById("PARTIDAS").getElementsByTagName("INPUT");for(var d=0;d<c.length;d++){if(c[d].id.indexOf("partidaClave")==0){if(c[d].value==l){var f=buscarElemento(c[d].parentNode.parentNode,"input","partidaCantidad");var g=buscarElemento(c[d].parentNode.parentNode,"input","partidaPrecio");var e=buscarElemento(c[d].parentNode.parentNode,"input","partidaTotal");var m=buscarElemento(c[d].parentNode.parentNode,"input","partidaTotalShow");var b=buscarElemento(c[d].parentNode.parentNode,"input","partidaCantidadShow");var j=parseFloat(f.value)+parseFloat(h);f.value=j;b.value=j;var a=parseFloat(j)*parseFloat(g.value);e.value=a;m.value=a;return true}}}return false}function buscarElemento(f,d,e){var b=f.getElementsByTagName(d);for(i=0;i<b.length;i++){var a=e+"*";var c=new RegExp(a);if(c.test(b[i].id)){return b[i]}}return null}function PasarOtroCampo(b,a){if(b.keyCode==13){var c=document.getElementById(a);c.select();c.focus()}}function esperaMientras(b){try{var a=dijit.byId("espera");if(a!=null){a.show()}}catch(c){}}function terminaEspera(){var a=dijit.byId("espera");if(a!=null){a.hide()}}function SumatoriaPartidas(){var o=0;var g=0;var A=0;var m=0;var ad=0;var O=0;var u=0;var f=0;var H=0;var E=0;var C=0;var ac=parseFloat(document.getElementById("Impuesto1").value);var aa=parseFloat(document.getElementById("Impuesto2").value);var Z=parseFloat(document.getElementById("Impuesto3").value);var U=parseInt(document.getElementById("NoTax").value);var I=parseInt(document.getElementById("Imp2_suma1").value);var K=parseInt(document.getElementById("Imp3_suma1").value);var J=parseInt(document.getElementById("Imp3_suma2").value);var k=parseInt(document.getElementById("Decimales").value);var ag=parseFloat(document.getElementById("ImporteFletes").value.replace(",",""));var G=parseFloat(document.getElementById("FleteImpuesto1").value.replace(",",""));var D=parseFloat(document.getElementById("FleteImpuesto2").value.replace(",",""));var B=parseFloat(document.getElementById("FleteImpuesto3").value.replace(",",""));var ab=0;if(k==0){ab=1}for(var af=1;af<arrPartidas.length;af++){var p=arrPartidas[af];if(p.Eliminada==false){try{o+=parseFloat(p.objCantidad.strValor);g+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecioNeto.strValor.replace(/,/g,"")));A+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPuntos.strValor));m+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objNegocio.strValor));ad+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objCreditos.strValor));O+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPublico.strValor));u+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPublicoReal.strValor));f+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPesoPromo.strValor));var n=parseFloat(p.objCantidad.strValor);var z=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecio.strValor.replace(/,/g,"")));var M=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPuntos.strValor));var x=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objNegocio.strValor));var a=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objCreditos.strValor));var y=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPublico.strValor));var l=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPublicoReal.strValor));var q=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPesoPromo.strValor));var W=0;var e=0;var Y=0;if(parseInt(p.objNoTax1.strValor)==0){H+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecioNeto.strValor.replace(/,/g,"")));W=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecio.strValor.replace(/,/g,"")))}if(parseInt(p.objNoTax2.strValor)==0){E+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecioNeto.strValor.replace(/,/g,"")));e=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecio.strValor.replace(/,/g,"")))}if(parseInt(p.objNoTax3.strValor)==0){C+=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecioNeto.strValor.replace(/,/g,"")));Y=(parseFloat(p.objCantidad.strValor)*parseFloat(p.objPrecio.strValor.replace(/,/g,"")))}var c=z;var v=p.objCve.strValor;var N=p.objConc.strValor;if(document.getElementById("VISTAIMPORTEMASIVA").value=="1"){var X=CalculaImpuesto(W,e,Y,y,ac,aa,Z,U,ab,I,K,J);c+=(X[0]+X[1]+X[2])}creaFilaenMisproductosDeta(v,N,c,n)}catch(ae){txt="There was an error on this page.\n\n";txt+="Error description: "+ae.description+"\n\n";txt+="Click OK to continue.\n\n";alert(txt)}}}var R=document.getElementById("TOTPZAS");var L=document.getElementById("TOTAL");var t=document.getElementById("TOTIMPUESTO1");var s=document.getElementById("TOTIMPUESTO2");var r=document.getElementById("TOTIMPUESTO3");var b=document.getElementById("TOTALIMPORTE");var Q=document.getElementById("TOTALIMPORTESINFLETE");var F=document.getElementById("TOTALPUNTOS");var P=document.getElementById("TOTALNEGOCIO");var w=document.getElementById("TOTALCREDITOS");var j=document.getElementById("TOTALPUBLICO");var V=document.getElementById("TOTALPUBLICOREAL");var S=document.getElementById("TOTPESOPROM");R.value=FormatNumber(o,0,true,false,true);Q.value=FormatNumber(g,k,true,false,true);g+=ag;b.value=FormatNumber(g,k,true,false,true);F.value=FormatNumber(A,k,true,false,true);P.value=FormatNumber(m,k,true,false,true);w.value=FormatNumber(ad,k,true,false,true);j.value=FormatNumber(O,k,true,false,true);V.value=FormatNumber(u,k,true,false,true);S.value=FormatNumber(f,k,true,false,true);try{var T=CalculaImpuesto(H,E,C,O,ac,aa,Z,U,ab,I,K,J);T[0]+=G;T[1]+=D;T[2]+=B;t.value=FormatNumber(T[0],k,true,false,true);s.value=FormatNumber(T[1],k,true,false,true);r.value=FormatNumber(T[2],k,true,false,true);var d=g+T[0]+T[1]+T[2];L.value=FormatNumber(d,k,true,false,true)}catch(ae){txt="There was an error on this page.\n\n";txt+="Error description: "+ae.description+"\n\n";txt+="Click OK to continue.\n\n";alert(txt)}if(parseFloat(document.getElementById("TOTPZAS").value)==0){verSeleccionProductos();document.getElementById("divMiCompra").style.display="none"}if(autosuma){document.getElementById("totalMiCompraTop").innerHTML=" "+document.getElementById("TOTAL").value}if(muestraflete=="1"){document.getElementById("fleteMiCompraTop").innerHTML=" "+document.getElementById("ImporteFletes").value}}function setPagoFormapago(d){var b=document.getElementById("TABLAFORMAPAGO").getElementsByTagName("input");var a=0;for(var c=0;c<b.length;c++){if(b[c].id.indexOf("VALORPAGO")>=0){a=parseFloat(a)+parseFloat(b[c].value)}}d=parseFloat(d)-parseFloat(a);document.getElementById("VALORPAGO1").value=parseFloat(document.getElementById("VALORPAGO1").value)+parseFloat(d);AjustaFormaPago()}function ObtenFlete(){var B="";var n=parseInt(document.getElementById("CobrarFlete").value);if(n==1){var l=true;var e=document.CapturaPartidas.FLETES;var p=e.length;if(p!=undefined){if(document.CapturaPartidas.FLETES[1].checked==false){l=false}}if(l==true){var C=document.getElementById("SUCURSAL");var y=document.getElementById("CLIENTE");var g=document.getElementById("TipoFlete").value;var a=document.getElementById("SELFLETE");var u=a.value+"";var b=parseInt(document.getElementById("Decimales").value);var s=document.getElementById("TOTPZAS");var j=document.getElementById("TOTALIMPORTE").value;var c=document.getElementById("TOTALPUNTOS").value;var f=document.getElementById("TOTALNEGOCIO").value;var h=document.getElementById("TOTALCREDITOS").value;var k=document.getElementById("TOTALPUBLICO").value;var A=document.getElementById("TOTPESOPROM");var x=parseFloat(document.getElementById("Impuesto1").value);var w=parseFloat(document.getElementById("Impuesto2").value);var v=parseFloat(document.getElementById("Impuesto3").value);var d=parseInt(document.getElementById("Imp2_suma1").value);var r=parseInt(document.getElementById("Imp3_suma1").value);var q=parseInt(document.getElementById("Imp3_suma2").value);var m=document.getElementById("TIPOPANTALLA").value;var t=GeneraListaPartidas();var z=0;if(document.getElementById("DIE_DI_ESTADO")!=null){z=document.getElementById("DIE_DI_ESTADO").value}dojo.xhrGet({url:"VentasFletes.jsp",load:function(D){ProcesaFlete(D);if(bolErrorNoAlmacenar==false){}},error:function o(){alert("ERROR: AL CALCULAR LOS FLETES")},timeout:80000,content:{cliente:y.value,Decimales:b,TotalCantidad:s.value,TotalImporte:j,TotalNegocio:f,TotalPuntos:c,TotalPublico:k,TotalCredito:h,TotalPesoPromo:A.value,Impuesto1:x,Impuesto2:w,Impuesto3:v,Imp2_Suma1:d,Imp3_Suma1:r,Imp3_Suma2:q,LstProductos:t,TipoFlete:g,ValorSeleccionFlete:u,almacen:C.value,id:m,FUERZAVENTAS:true,ADICIONAL1:z}})}else{document.getElementById("ImporteFletes").value=0;document.getElementById("FleteImpuesto1").value=0;document.getElementById("FleteImpuesto2").value=0;document.getElementById("FleteImpuesto3").value=0;SumatoriaPartidas()}}else{document.getElementById("ImporteFletes").value=0;document.getElementById("FleteImpuesto1").value=0;document.getElementById("FleteImpuesto2").value=0;document.getElementById("FleteImpuesto3").value=0;SumatoriaPartidas()}return B}function GeneraListaPartidas(){var c=new String("");for(var a=1;a<arrPartidas.length;a++){var b=arrPartidas[a];if(b.Eliminada==false&&b.objEsRegalo.strValor=="0"){c+=b.objCve.strValor+","+b.objCantidad.strValor+","+b.objPrecioNeto.strValor+","+b.objPuntos.strValor+","+b.objNegocio.strValor+","+b.objPublico.strValor+","+b.objPesoPromo.strValor+"|"}}if(c.length>0){c=c.substring(0,c.length-1)}return c}function ProcesaFlete(f){f=trim(f);var h=parseInt(document.getElementById("Decimales").value);var b=document.getElementById("ImporteFletes");var e=document.getElementById("FleteImpuesto1");var c=document.getElementById("FleteImpuesto2");var a=document.getElementById("FleteImpuesto3");if(f.substr(0,5)!="ERROR"&&f!=""){var k=f.split(",");var j=parseFloat(k[0]);var d=parseFloat(k[1]);var g=parseFloat(k[2]);var l=parseFloat(k[3]);b.value=FormatNumber(j,h,true,false,true);e.value=FormatNumber(d,h,true,false,true);c.value=FormatNumber(g,h,true,false,true);a.value=FormatNumber(l,h,true,false,true)}SumatoriaPartidas()}function habilitarBotonesBorrar(){var b=document.getElementById("PARTIDAS").getElementsByTagName("INPUT");for(var a=0;a<b.length;a++){if(b[a].type=="button"){b[a].disabled=false}}}function deshabilitarBotonesBorrar(){var b=document.getElementById("PARTIDAS").getElementsByTagName("INPUT");for(var a=0;a<b.length;a++){if(b[a].type=="button"){b[a].disabled=true}}}var selectEdit="";var selectPartida="";function editarFilaMas(a,b){selectEdit=b.objCve.strValor;selectPartida=b;editarFila2(1)}function editarFilaMenos(a,b){selectEdit=b.objCve.strValor;selectPartida=b;editarFila2(-1)}function editarFila(a,b){selectEdit=b.objCve.strValor;selectPartida=b;dijit.byId("dialogoSumarCantidad").show()}function editarFila2(b){var d=BuscarCodigoenLista(selectEdit,"",false);var c=null;if(d!=null){var a=parseFloat(d.objCantidad.strValor)+parseFloat(b);var e=parseFloat(d.objPrecio.strValor)*a;if(a==0){borrarFila(d.botonElimina,d,false)}else{d.objCantidad.setValor(a);d.objImport.setValor(e);ObtenFlete()}}}function borrarFila(a,c,b){borrarFilaDetalle(a,c,b);var d=a.parentNode.parentNode;var e=document.getElementById("PARTIDAS").getElementsByTagName("tbody")[0];e.removeChild(d);c.Eliminada=true;delete c;if(b==true){ObtenOfertas()}SumatoriaPartidas()}function borrarFilaDetalle(b,d,c){if(document.getElementById("divMiCompra")!=null){var a=buscarElemento(b.parentNode.parentNode,"input","codigo");var f=document.getElementById("tablaMiCompraTop").getElementsByTagName("input");var e=null;for(bf=0;bf<f.length;bf++){if(f[bf].id=="CLAVE"+a.value){e=f[bf]}}e.parentNode.parentNode.parentNode.removeChild(e.parentNode.parentNode)}}function vistaDesplegadoSelecciona(){habilitarBotonesBorrar();document.getElementById("imagenEstadoCompra").src="IMAGENES/INGRESAPEDIDO1.jpg";document.getElementById("divAdicionalPanel1").style.display="block";if(document.getElementById("divAdicionalPanel2")!=null){document.getElementById("divAdicionalPanel2").style.display="block"}document.getElementById("divAdicionalPanel3").style.dyplay="block";document.getElementById("divAdicionalPanel4").style.display="block";document.getElementById("divAdicionalPanel5").style.display="none";document.getElementById("divAdicionalPanel6").style.display="none";document.getElementById("ANTERIOR").onclick=function(){};document.getElementById("ANTERIOR").disabled=true;document.getElementById("SIGUIENTE").onclick=function(){vistaDesplegadoEnvio()}}function vistaDesplegadoEnvio(){document.getElementById("imagenEstadoCompra").src="IMAGENES/INGRESAPEDIDO2.jpg";deshabilitarBotonesBorrar();if(arrPartidas.length>0){document.getElementById("divAdicionalPanel1").style.display="none";if(document.getElementById("divAdicionalPanel2")!=null){document.getElementById("divAdicionalPanel2").style.display="none"}document.getElementById("divAdicionalPanel3").style.dyplay="block";document.getElementById("divAdicionalPanel4").style.display="none";document.getElementById("divAdicionalPanel5").style.display="block";document.getElementById("divAdicionalPanel6").style.display="none";document.getElementById("ANTERIOR").onclick=function(){vistaDesplegadoSelecciona()};document.getElementById("ANTERIOR").disabled=false;document.getElementById("SIGUIENTE").onclick=function(){vistaDesplegadoFormaPago()};document.getElementById("SIGUIENTE").disabled=false;document.getElementById("ALMACENAR").disabled=false}else{muestraMensajeError("ERROR: DEBE CAPTURAR UN MINIMO DE UN PRODUCTO")}}function vistaDesplegadoFormaPago(){document.getElementById("imagenEstadoCompra").src="IMAGENES/INGRESAPEDIDO3.jpg";if(document.getElementById("miDireccionEnvioId").value!="-1"){document.getElementById("divAdicionalPanel1").style.display="none";if(document.getElementById("divAdicionalPanel2")!=null){document.getElementById("divAdicionalPanel2").style.display="none"}document.getElementById("divAdicionalPanel3").style.dyplay="block";document.getElementById("divAdicionalPanel4").style.display="none";document.getElementById("divAdicionalPanel5").style.display="none";document.getElementById("divAdicionalPanel6").style.display="block";document.getElementById("ANTERIOR").onclick=function(){vistaDesplegadoEnvio()};document.getElementById("ANTERIOR").disabled=false;document.getElementById("SIGUIENTE").onclick=function(){};document.getElementById("SIGUIENTE").disabled=true;document.getElementById("ALMACENAR").disabled=false}else{muestraMensajeError("ERROR: DEBE SELECCIONAR UNA DIRECCION DE ENVIO")}}function muestraMensajeError(c,a){var b=dijit.byId("dialogoGenerico");if(b!=null){if(a!=null){b.title=a}else{b.title="ERROR"}document.getElementById("divDialogGenerico").innerHTML=c;b.show()}}function validaNuevaDireccionEnvio(){if(document.getElementById("NEW_DI_NOMBRE").value.length>0){if(document.getElementById("NEW_DI_DIRECCION1").value.length>0||document.getElementById("NEW_DI_DIRECCION2").value.length>0||document.getElementById("NEW_DI_DIRECCION3").value.length>0||document.getElementById("NEW_DI_DIRECCION4").value.length>0){if(document.getElementById("NEW_DI_DIRECCION1").value!="0"){defineComoDireccionenvio("0",document.getElementById("NEW_DI_NOMBRE").value)}else{muestraMensajeError("seleccione esl estado")}}else{muestraMensajeError("CAPTURE AL MENOS UNA DIRERECCION")}}else{muestraMensajeError("CAPTURE EL NOMBRE")}}function establecerDireccionDesdeCheck(a){alert(a);alert(a.value)}function defineComoDireccionenvio(b,a){document.getElementById("miDireccionEnvioId").value=b}function obtenerParidad(d,b){var c=document.getElementById("MonedaBase").value;var a=document.getElementById(b);espera.show();dojo.xhrGet({url:"ValidacionAjax.jsp?ACCION=PARIDAD",load:function(e){e=trim(e);if(e.substr(0,5)!="ERROR"){a.value=e;AjustaFormaPago()}else{alert(e)}},error:function(e){alert(e)},timeout:80000,content:{LOCAL:c,FORANEA:d.value}})}function AjustaFormaPago(){var b=parseInt(document.getElementById("AplicaPagos").value);var g=document.getElementById("TIPOPANTALLA").value;if(b==1){var f=parseFloat(document.getElementById("TOTAL").value.replace(",",""));var c=document.getElementById("VALORPAGOTOTAL");var k=document.getElementById("MonedaBase").value;var e=0;for(var h=1;h<=3;h++){var n=document.getElementById("FORMAPAGO"+h);var l=document.getElementById("DIVISAPAGO"+h);var d=document.getElementById("VALORPAGO"+h);var a=document.getElementById("PAGOMOSTRADAENVIAR"+h);var m=document.getElementById("VALORDIVISAMOSTRADA"+h);if(k!=l.value){a.value=parseFloat(d.value)*parseFloat(m.value)}else{a.value=d.value}e+=parseFloat(a.value)}if(g=="VENTAS"){var j=f-e;if(j>0.9){for(h=1;h<=2;h++){l=document.getElementById("DIVISAPAGO"+h);d=document.getElementById("VALORPAGO"+h);a=document.getElementById("PAGOMOSTRADAENVIAR"+h);if(parseFloat(d.value)==0){d.value=j;a.value=j;if(parseInt(l.value)!=parseInt(k)){l.value=k;m.value=1}e+=j}}}}c.value=FormatNumber(e,intNumDecimales,true,false,true)}}var intNumDecimales=2;function EnviaFormulario(){var c=direccionValidaText+","+direccionValidaInt;var b=c.split(",");if(c.length>1){for(var a=0;a<b.length;a++){if(trim(b[a])>0){var d=document.getElementById(b[a]);if(d!=null){d.disabled=false}else{alert("error: has not elemt to "+b[a]);return}}}}esperaMientras("LA OPERACION SE ESTA EJECUTANDO");dojo.xhrPost({url:"Ventas3.jsp?FUERZAVENTAS=1",load:ProcesaEnvioForm,error:function(f){if(c.length>1){for(var e=0;e<b.length;e++){if(trim(b[e])>0){var g=document.getElementById(b[e]);if(g!=null){g.disabled=true}else{alert("error: has not elemt to "+b[e]);return}}}}terminaEspera();alert(f)},form:"CapturaPartidas"})}function Confirma(){var a=dijit.byId("Confirmacion");a.show()}function ValidayAlmacena(){var c=document.getElementById("filas");var a=document.getElementById("cont");var b=document.getElementById("ALMACENAR");if(parseInt(a.value)>0){c.value=a.value;EnviaFormulario()}else{b.disabled=false}}function verPaginaPago(c,b){var d=document.getElementById("filas");var a=document.getElementById("cont");d.value=a.value;esperaMientras("EJECUTANDO VENTANA EXTERNA");setTimeout("verpagina('"+c+"','"+b+"');",1000)}function verpagina(b,a){window.open(b+"?"+a,"_blank","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=805,height=605")}function respuesta(a){document.getElementById("VALORPAGO1").value=document.getElementById("TOTAL").value;document.getElementById("PAGOMOSTRADAENVIAR1").value=document.getElementById("TOTAL").value;document.getElementById("VALORPAGOTOTAL").value=document.getElementById("TOTAL").value;EnviaFormulario()}function respuestaError(a){terminaEspera()}function ProcesaEnvioForm(c,a){terminaEspera();c=trim(c);if(startsWith(c,"ERROR:")==true){alert(c);var b=document.getElementById("ALMACENAR");b.disabled=false}else{document.getElementsByTagName("CENTER")[0].innerHTML=c}}function ValidarFormadePago(){var b=true;var a=parseInt(document.getElementById("AplicaPagos").value);var e=document.getElementById("TIPOPANTALLA").value;if(a==1){AjustaFormaPago();var c=parseFloat(document.getElementById("VALORPAGOTOTAL").value.replace(",",""));var g=parseFloat(document.getElementById("TOTAL").value.replace(",",""));var j=g-c;if(e=="VENTAS"){if(Math.abs(j)>=0.1){b=false;alert("EL IMPORTE A PAGAR ES DIFERENTE AL TOTAL DE LA VENTA")}}else{if(c>g){b=false;alert("EL IMPORTE A PAGAR ES DIFERENTE AL TOTAL DE LA VENTA>")}}for(var f=1;f<=3;f++){var k=document.getElementById("FORMAPAGO"+f);var d=document.getElementById("VALORPAGO"+f);var h=document.getElementById("DIVISAPAGO"+f);if(parseFloat(d.value)!=0){if(k.value==""){alert("FALTA SELECCIONAR LA FORMA DE PAGO");k.focus();b=false}if(h.value==0){alert("FALTA SELECCIONAR EL TIPO DE MONEDA");h.focus();b=false}}}}return b}function esperaventana(){document.getElementById("divCancela").style.visibility="visible"}function creaHidden(c,b){var a=document.createElement("input");a.setAttribute("type","hidden");a.setAttribute("name",c);a.setAttribute("id",c);a.setAttribute("value",b);return a}function verSeleccionProductos(){document.getElementById("miDireccionEnvio").style.display="none";document.getElementById("misPartidas").style.display="none";document.getElementById("misProductosSeleccion").style.display="block";document.getElementById("imgLineaCarrito1").src="IMAGENES/CARRO1.jpg";document.getElementById("imgLineaCarrito2").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito3").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito4").src="IMAGENES/CARRO2.jpg";if(parseFloat(document.getElementById("TOTPZAS").value)!=0){document.getElementById("divMiCompra").style.display="BLOCK"}}function verDireccionEnvio(){if(inicioSesion=="1"){abreDialogoSesion()}document.getElementById("imgLineaCarrito1").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito2").src="IMAGENES/CARRO1.jpg";document.getElementById("imgLineaCarrito3").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito4").src="IMAGENES/CARRO2.jpg";document.getElementById("misProductosSeleccion").style.display="none";document.getElementById("miDireccionEnvio").style.display="block";if(SoloDireccionFacturacion){document.getElementById("ESTABLECER").style.display="none";document.getElementById("TITULO0").style.display="none";document.getElementById("DIRECCION0").style.display="none"}document.getElementById("misPartidas").style.display="none";document.getElementById("divMiCompra").style.display="block"}function verMiCompra(){document.getElementById("imgLineaCarrito1").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito2").src="IMAGENES/CARRO2.jpg";document.getElementById("imgLineaCarrito3").src="IMAGENES/CARRO1.jpg";document.getElementById("imgLineaCarrito4").src="IMAGENES/CARRO2.jpg";document.getElementById("divMiCompra").style.display="none";document.getElementById("misProductosSeleccion").style.display="none";document.getElementById("miDireccionEnvio").style.display="none";document.getElementById("misPartidas").style.display="block";ObtenFlete();mostrarDireccionesTexto()}function verMiDireccionEnvio(){dijit.byId("miDireccionEnvio").show()}function mostrarDescripcionProducto(a){}function muestraDireccion(a){var c=0;do{var b=document.getElementById("DIRECCION"+c);if(b!=null){b.style.display="none"}else{break}c++}while(true);document.getElementById("DIRECCION"+a).style.display="block"}function migrarValoresaDireccionEnvio(){var c=document.getElementById("tablaDirFact").getElementsByTagName("INPUT");for(var d=0;d<c.length;d++){var b=c[d];var a=document.getElementById("DIE_DI"+b.id.replace(/DIF_CL/,""));if(a!=null){a.value=b.value}}}function resetPanel(b){var a=document.getElementById("DIRECCION"+b).getElementsByTagName("input");for(var c=0;c<a.length;c++){if(a[c].type=="text"){a[c].value=""}}}function getCheckedValue(b){if(!b){return"-1"}var c=b.length;alert(c);if(c==undefined){if(b.checked){return b.value}else{return"-2"}}for(var a=0;a<c;a++){if(b[a].checked){return b[a].value}}return"-3"}function validaDireccionEnvio(){if(SoloDireccionFacturacion){migrarValoresaDireccionEnvio()}try{var c=direccionValidaText.split(",");var g=direccionValidaInt.split(",");for(e=0;e<c.length;e++){errorCampoObligatorioLiberar(c[e])}for(e=0;e<g.length;e++){errorCampoObligatorioLiberar(g[e])}var j=0;if(direccionValidaText.length>0){for(var e=0;e<c.length;e++){var d=document.getElementById(c[e]);var f=document.getElementsByName(c[e]);if(d.type=="radio"){var a=false;for(var k=0;k<f.length;k++){if(f[k].checked){a=true}}if(!a){j++;errorCampoObligatorio(c[e])}}if(!d.value.length>0){j++;errorCampoObligatorio(c[e])}}}if(direccionValidaInt.length>0){for(var e=0;e<g.length;e++){var b=document.getElementById(g[e]);if(b.type=="radio"){alert(b.length)}if(b.value=="0"){j++;errorCampoObligatorio(g[e])}}}if(j>0){document.getElementById("ERRORLLENADO2").style.display="block"}else{verMiCompra()}}catch(h){alert(h)}}function mostrarDireccionesTexto(){var c=direccionValidaText+","+direccionValidaInt;var b=c.split(",");if(c.length>1){for(var a=0;a<b.length;a++){var e=document.getElementById("TEXT_"+b[a]);var d=document.getElementById(b[a]);if(e!=null&&d!=null){e.innerHTML=d.value}else{}}}}function errorCampoObligatorioLiberar(b){var a=document.getElementById(b);if(a!=null){a.setAttribute("class","TextBlur");a.setAttribute("className","TextBlur")}}function errorCampoObligatorio(b){var a=document.getElementById(b);a.setAttribute("class","TextError");a.setAttribute("className","TextError")}function cargaDireccion(b,a,j,h,g,f,c,d,e){document.getElementById("NEW_DI_NOMBRE").value=a;document.getElementById("NEW_DI_DIRECCION1").value=j;document.getElementById("NEW_DI_DIRECCION2").value=h;document.getElementById("NEW_DI_DIRECCION3").value=g;document.getElementById("NEW_DI_DIRECCION4").value=f;document.getElementById("NEW_DI_ESTADO").value=c;document.getElementById("NEW_DI_TELEFONO1").value=d;document.getElementById("NEW_DI_CORREO1").value=e;defineComoDireccionenvio(b)}function selPeriodicidad(a){if(a.checked){document.getElementById("panelAutoCompra").style.display="block"}else{document.getElementById("panelAutoCompra").style.display="none"}}function muestraTipoPeriodicidad(b){var a=document.getElementById("PERIODICIDAD");GeneraOptPeriodicidad(a)}function ObtenOfertas(){var s="";var d=document.getElementById("ALMACENAR");var t=document.getElementById("SUCURSAL");var q=document.getElementById("CLIENTE");var j=document.getElementById("LISTAPRECIO");d.disabled=true;var o=document.getElementById("TOTPZAS");LimpiaOfertas();var f=document.getElementById("SU_DESCARGA");var b=document.getElementById("SU_DESCARGAEXT");var n=document.getElementById("SU_EXTERNA1");var m=document.getElementById("SU_EXTERNA1");var l=document.getElementById("SU_EXTERNA1");var g=document.getElementById("TOTALIMPORTE").value;var a=document.getElementById("TOTALPUNTOS").value;var c=document.getElementById("TOTALNEGOCIO").value;var e=document.getElementById("TOTALCREDITOS").value;var h=document.getElementById("TOTALPUBLICO").value;var r=document.getElementById("TOTPESOPROM");var p=GeneraListaPartidas();dojo.xhrPost({url:"VentasOfertas.jsp?id=COTIZACION",load:function(u){ProcesaOfertas(u);if(bolErrorNoAlmacenar==false){d.disabled=false}},error:function k(u){alert("Hubo un error "+ioArgs.args+" "+u)},timeout:80000,content:{cliente:q.value,listaprecios:j.value,TotalCantidad:o.value,TotalImporte:g,TotalNegocio:c,TotalPuntos:a,TotalPublico:h,TotalCredito:e,TotalPesoPromo:r.value,LstProductos:p,SU_DESCARGA:f.value,SU_DESCARGAEXT:b.value,SU_EXTERNA1:n.value,SU_EXTERNA2:m.value,SU_EXTERNA3:l.value,almacen:t.value,FUERZAVENTAS:true}});return s}function LimpiaOfertas(){document.getElementById("OfertaDiv").innerHTML="";for(var a=1;a<arrPartidas.length;a++){var b=arrPartidas[a];if(b.Eliminada==false){if(b.objEsRegalo.strValor=="1"&&b.objIdRegaManual.strValor=="0"){borrarFila(b.botonElimina,b,false)}}}if(objSelOfertas!=null){objSelOfertas.Limpiar()}if(objSeleccionaOfertas!=null){objSeleccionaOfertas.BorraFilas()}ObtenTotalesReales()}function ObtenTotalesReales(){for(var a=1;a<arrPartidas.length;a++){var c=arrPartidas[a];if(c.Eliminada==false&&c.objEsRegalo.strValor=="0"){try{if(c.objDescUsuario.strValor!="1"){c.objDescuento.setValor("0")}c.AppPtp=0;c.AppVn=0;c.AppPrec=0;c.AppCred=0;c.dblIncr=0;c.CalculaPrecio();c.objlstOfertas.setValor("0")}catch(b){txt="There was an error on this page.\n\n";txt+="Error description: "+b.description+"\n\n";txt+="Click OK to continue.2\n\n";alert(txt)}}}SumatoriaPartidas()}function ProcesaOfertas(d){d=trim(d);bolErrorNoAlmacenar=false;ofertas=new OfertasRegalos();ofertas.OfertasRega(d);for(var b=0;b<ofertas.lstOfertas.length-1;b++){var e=ofertas.lstOfertas[b];try{var a=document.createElement("div");a.innerHTML=e.strDescripcion;document.getElementById("OfertaDiv").appendChild(a);e.arrPartidasVenta=arrPartidas;bolErrorNoAlmacenar=e.AplicaOferta()}catch(c){txt="There was an error on this page.\n\n";txt+="Error description: "+c.description+"\n\n";txt+="Click OK to continue1.\n\n";alert(txt)}}if(objSelOfertas!=null){objSelOfertas.SeleccionaTodo(true)}ObtenFlete()}function misClasificacionesVista(c,b){var a=1;while(true){if(parseInt(a)==parseInt(b)){document.getElementById("divClasif"+a).style.display="block"}else{if(document.getElementById("divClasif"+a)!=null){document.getElementById("divClasif"+a).style.display="none"}else{status=false;break}}a++;if(a>12){break}}}function keyBusqueda(a){if(a.keyCode==13){document.getElementById("BUSQUEDA").onclick()}}function ConfirmaAnular(){try{var a=dijit.byId("ConfirmaAnular");if(a!=null){a.show()}}catch(b){}}function ConfirmaAnularEjecutar(){dojo.xhrPost({url:"CotiAnul2.jsp",load:function(b){b=trim(b);document.getElementsByTagName("CENTER")[0].innerHTML=b},error:function a(b){alert("Hubo un error "+ioArgs.args+" "+b)},timeout:80000,content:{COT_ID:document.getElementById("COTIZACION").value,FUERZAVENTAS:true}})}var Dias="LUNES,MARTES,MIERCOLES,JUEVES,VIERNES,SABADO,DOMINGO";var Meses="ENERO,FEBRERO,MARZO,ABRIL,MAYO,JUNIO,JULIO,AGOSTO,SEPTIEMBRE,OCTUBRE,NOVIEMBRE,DICIEMBRE";var Periodos="PRIMER,SEGUNDO,TERCERO,CUARTO,ULTIMO";var Titulo1="FECHA DE FACTURA";var Titulo2="�REPETIR CADA CUANTOS DIAS?";var Titulo3="HASTA QUE FECHA";var Titulo4="�REPETIR CADA CUANTAS SEMANAS?";var Titulo5="EL DIA:";var Titulo6="�EL DIA?";var Titulo7="DEL MES";var Titulo8="EL";var Titulo9="EL DIA";var Titulo10="DEL MES DE ";function IniVarX(h,f,k,e,d,c,b,a,n,m,l,j,g){Dias=h;Meses=f;Periodos=k;Titulo1=e;Titulo2=d;Titulo3=c;Titulo4=b;Titulo5=a;Titulo6=n;Titulo7=m;Titulo8=l;Titulo9=j;Titulo10=g}function abreDialogoSesion(){var a=document.getElementById("ORIGENPEDIDOVENTA");if(a.value=="2"||a.value=="3"){dijit.byId("dialogoSesion").show()}}function cierraDialogoSesion(){dijit.byId("dialogoSesion").hide()}function validaUser(){esperaMientras("");var d=document.getElementById("DECUENTOCLIENTE");var c=document.getElementById("SESION_USER");var e=document.getElementById("SESION_PASS");var b=document.getElementById("IDIOMA");var a=document.getElementById("regresarsesion");a.innerHTML="PROCESANDO SOLICITUD";c.disabled=true;e.disabled=true;dojo.xhrPost({url:"ValidacionSesion.jsp",load:function(A){c.value="";e.value="";c.disabled=false;e.disabled=false;terminaEspera();A=trim(A);if(A.indexOf("ERROR")>=0){a.innerHTML=A}else{if(d!=null){d.style.display="block"}a.innerHTML="OK";var y=A.split(",");var m=y[0];var n=y[1];var j=y[1];var g=y[3];var x=y[4];var w=y[5];var v=y[6];var u=y[7];var t=y[8];var s=y[9];var z=y[10];var l=y[11];var k=y[12];var h=y[13];var o=y[14];var f=y[15];var r=y[16];var q=y[17];var p=y[18];document.getElementById("CLIENTE").value=m;document.getElementById("PorDescuento").value=n;document.getElementById("DiasCredito").value=g;document.getElementById("Impuesto1").value=x;document.getElementById("Impuesto2").value=w;document.getElementById("Impuesto3").value=v;document.getElementById("Desglosa1").value=u;document.getElementById("Desglosa2").value=t;document.getElementById("Desglosa3").value=s;document.getElementById("Imp2_suma1").value=z;document.getElementById("Imp3_suma1").value=l;document.getElementById("Imp3_suma2").value=k;document.getElementById("NoTax").value=h;document.getElementById("MonedaBase").value=o;document.getElementById("ORIGENPEDIDOVENTA").value="1";reclculaFilaenMisproductos();dijit.byId("dialogoSesion").hide();obtenerDirecciones()}},error:function(f){alert(f)},timeout:80000,content:{LOGIN:c.value,PASSWORD:e.value,IDIOMA:b.value}})}function obtenerDirecciones(){dojo.xhrPost({url:"FV_ValidacionAjax.jsp?ACCION=OBTENERDIRECCIONES",load:function(c){terminaEspera();c=trim(c);if(c.indexOf("ERROR")>=0){msgSesion.innerHTML=c}else{var b=c.split("|");for(var a=0;a<b.length;a++){var e=b[a].split("{}");if(e.length==2){var d=document.getElementById(trim(e[0]));if(d!=null){d.value=trim(e[1])}}}dijit.byId("dialogoSesion").hide()}},error:function(a){alert(a)},timeout:80000,content:{}})}function reclculaFilaenMisproductos(){for(var b=1;b<arrPartidas.length;b++){var a=arrPartidas[b];if(a.Eliminada==false){try{creaFilaenMisproductos(a.objCve.strValor,1,true,true)}catch(c){}}}};