function ShowError(){
  //return true;
}
//window.onerror=ShowError;

function abrirventana(pagina,titulo){
w=660;
h=530;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}
function abrirventanapop(pagina,titulo){
w=660;
h=530;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}
function abrirventanac(pagina){
w=660;
h=530;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}

function abrirventanac2(pagina,w,h){
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=no,resizable=no');
win.moveTo(t,l);
win.focus();
}
function abrirventanadatos(pagina,titulo){
w=320;
h=260;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}

function abrirventanaconvenio(pagina,titulo){
w=800;
h=600;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}
function abrirventanamodos(pagina,titulo){
w=340;
h=500;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}


function abrirventana2(pagina){
w=525;
h=150;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=no,resizable=no');
win.moveTo(t,l);
win.focus();
}

function abrirventana3(pagina){
w=660;
h=530;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=no,resizable=no');
win.moveTo(t,l);
win.focus();
}

function openapp(extra){
 titextra='';
 if(extra) titextra='2';
 abrirventana('attel.php'+extra,'attel'+titextra);
}
//var calWin;
var calObject;
function abreCalendario(object){
w=225;
h=270;
l=(screen.width-w)/2;
t=(screen.height-h)/2-33;
  calObject=object;
  calWin=window.open('calendario/cal.php','cal','width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=no,resizable=no');
  calwin.moveTo(t,l);
  calwin.focus();
}
function abreCalendariotomas(object){
w=850;
h=580;
l=(screen.width-w)/2;
t=(screen.height-h)/2-33;
  calObject=object;
  calWin=window.open('index.php?Pagina=caltomas&modo=caltomas2','cal','width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=yes,resizable=yes');
  calwin.moveTo(t,l);
  calwin.focus();
}
function cierraCalendario(dia,mes,anno){
  if (calObject=='fechaini') {
     document.getElementById('fechainidia').value=dia;
     document.getElementById('frmbuscar2').fechainimes.value=mes;
     document.getElementById('frmbuscar2').fechainianno.value=anno;
  } else if(calObject=='fechafin') {
     document.getElementById('frmbuscar2').fechafindia.value=dia;
     document.getElementById('frmbuscar2').fechafinmes.value=mes;
     document.getElementById('frmbuscar2').fechafinanno.value=anno;
  }else if(calObject=='fechamin') {
     document.forms[0].fechamindia.value=dia;
     document.forms[0].fechaminmes.value=mes;
     document.forms[0].fechaminanno.value=anno;
  }
}
function ObtenerObjeto(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=ObtenerObjeto(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function descuento(precio){
mult=document.getElementById('color_paquetes-descuento').value*precio*1;
porcentaje=mult/100;
result=precio-porcentaje;
if(isNaN(result)) return;
//result=round(result*100)/100;
document.getElementById('color_paquetes-costototal').value=result;
document.getElementById('color_paquetes-preciocombofinal').value=result;
}

function costototal(preciodolar){
var precio1=document.getElementById('color_utilerias-costocaja').value;
var precio2=document.getElementById('color_utilerias-costologistica').value;
var precio3=document.getElementById('color_utilerias-otroscostos').value;
	if(document.getElementById('usdcostocaja').checked==true) {precio1=precio1*preciodolar;}
        if(document.getElementById('usdcostologistica').checked==true) precio2=precio2*preciodolar;
           if(document.getElementById('usdotroscostos').checked==true) precio3=precio3*preciodolar;
	total=precio1*1+precio2*1+precio3*1;

	total=Math.round(total*100)/100;
        if(isNaN(total)) { document.getElementById('color_utilerias-costototal').value=0;return;}
	document.getElementById('color_utilerias-costototal').value=total;
	if(document.getElementById('color_utilerias-cantidadcaja').value=="") document.getElementById('color_utilerias-cantidadcaja').value=0;
	if(document.getElementById('color_utilerias-cantidadcaja').value<=0) {
	document.getElementById('color_utilerias-costounitariototal').value=0;
	return;}
	totalcostounitario=total*1/document.getElementById('color_utilerias-cantidadcaja').value*1;
	totalcostounitario=Math.round(totalcostounitario*100)/100;
	if(isNaN(totalcostounitario)) return;
	document.getElementById('color_utilerias-costounitariototal').value=totalcostounitario;
	}
function preciototal(){
preciofinal=document.getElementById('color_preciosarticulos-cantidadutilizado').value*document.getElementById('color_preciosarticulos-costounitario').value;
preciofinal=Math.round(preciofinal*100)/100;
document.getElementById('color_preciosarticulos-costototal').value=preciofinal;
}
function preciopaquetes(){
preciofinal=document.getElementById('color_prodpaquetes-cantidad').value*document.getElementById('color_prodpaquetes-costo').value;
preciofinal=Math.round(preciofinal*100)/100;
document.getElementById('color_prodpaquetes-costototal').value=preciofinal;
}


var nav4 = window.Event ? true : false;
function acceptNum(evt,obj1,objeto2,lmaxima){
  var key = nav4 ? evt.which : evt.keyCode;
  if (key >= 48 && key <= 57 && objeto2!=''){
    obj2=ObtenerObjeto(objeto2);
    if(obj1.value.length>=lmaxima) obj2.focus();
  }
  return (key <= 13 || (key >= 48 && key <= 57));
}

function validarNumero(evt){
  var key = nav4 ? evt.which : evt.keyCode;
  return (key <= 13 || (key >= 48 && key <= 57) || key == 45 || key == 32 || key == 46);
}
function actualizaSaldos(event){
 with(document.forms[0]){

    if(event.keyCode == 190 || event.keyCode == 110) return;
    if(isNaN(Cantidad.value)) return;
    if(isNaN(costoU.value)) return;
	var costo=costoU.value*1;
	var cantidad=Cantidad.value*1;
	var importe=cantidad*costo;
	btnimporte.value=importe;
 }
}
function recordar(){
w=380;
h=180;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open('recordar.php','','width='+w+',height='+h+',scrollbars=no,resizable=no');
win.moveTo(t,l);
win.focus();
}
function vermenu(obj,status,activo){
if(activo=="imagen2") status=1;
if(status==1) 
{
obj.style.backgroundImage='url(images/btnprueba2.png)';
obj.style.backgroundRepeat='no-repeat';
}
if(status==2)
{
obj.style.backgroundImage='url(images/btnprueba.png)';
obj.style.backgroundRepeat='no-repeat';
}
}

function checapag(chkpag){
  if(chkpag=="pag1"){
    document.forms[0].nompag.value=chkpag;
    document.forms[0].submit();
  }	else if((document.getElementById("unic2_proceso-IDauto").value!="")&&(chkpag=="pag2")){
    document.forms[0].nompag.value=chkpag;
    document.forms[0].submit();
  }else{
    alert("Falta seleccionar un vehiculo");
  }
}
