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 abrirdetalles(pagina,titulo){
w=800;
h=220;
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.forms[0].fechainidia.value=dia;
document.forms[0].fechainimes.value=mes;
document.forms[0].fechainianno.value=anno;
var dia2=(dia*1)+1;
if(dia==31) { mes=mes*1+1; dia2=1;}
if(mes==13) { mes=1; anno=anno*1+1;}
document.forms[0].fechafindia.value=dia2;
document.forms[0].fechafinmes.value=mes;
document.forms[0].fechafinanno.value=anno;

} else if(calObject=='fechafin') {
document.forms[0].fechafindia.value=dia;
document.forms[0].fechafinmes.value=mes;
document.forms[0].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 ajustarfecha(){
dia=document.forms[0].fechainidia.value;
mes=document.forms[0].fechainimes.value;
anno=document.forms[0].fechainianno.value;
var dia2=(dia*1)+1;
if(dia==31) { mes=mes*1+1; dia2=1;}
if(mes==13) { mes=1; anno=anno*1+1;}
document.forms[0].fechafindia.value=dia2;
document.forms[0].fechafinmes.value=mes;
document.forms[0].fechafinanno.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 compararFecha(fecha, fecha2)
{
var xMonth=fecha.substring(3, 5);
var xDay=fecha.substring(0, 2);
var xYear=fecha.substring(6,10);
var yMonth=fecha2.substring(3, 5);
var yDay=fecha2.substring(0, 2);
var yYear=fecha2.substring(6,10);
if (xYear> yYear)
{
return(true);
}
else
{
if (xYear == yYear)
{
if (xMonth> yMonth)
{
return(true);
}
else
{
if (xMonth == yMonth)
{
if (xDay> yDay){
return(true);
}
else{
	numdias=yDay-xDay;
	if(numdias<1) {return(true);}
return(false);}
}
else
return(false);
}
}
else
return(false);
}
}
function hoy()
{
var fechaActual = new Date();

diab = fechaActual.getDate();
mesb = fechaActual.getMonth() +1;
annob = fechaActual.getFullYear();
diab=diab+1;
if (diab <10) diab =diab;
if (mesb <10) mesb =mesb;

if(diab<10) diab='0'+diab;
if(mesb<10) mesb='0'+mesb;
fechaHoy = diab + "-" + mesb + "-" + annob;

return fechaHoy;
}

function checapag(chkpag){
annoi=document.getElementById('fechainianno').value;
mesi=document.getElementById('fechainimes').value;
diai=document.getElementById('fechainidia').value;

annof=document.getElementById('fechafinanno').value;
mesf=document.getElementById('fechafinmes').value;
diaf=document.getElementById('fechafindia').value;

if(diai<10) diai='0'+diai;
if(mesi<10) mesi='0'+mesi;
if(diaf<10) diaf='0'+diaf;
if(mesf<10) mesf='0'+mesf;


var Hdia=hoy();
if(compararFecha(Hdia,diai+'-'+mesi+'-'+annoi)){ alert("Para reservar por internet es necesario hacerlo 48 horas antes de la renta"); return;}
if(compararFecha(diai+'-'+mesi+'-'+annoi,diaf+'-'+mesf+'-'+annof)){   alert("Fecha de devolucion debe ser mayor a fecha de entrega"); return;}


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");
}
}

function DelDir(sep){
document.getElementById(sep+'CP').value='';
document.getElementById(sep+'LocalidadID').selectedIndex=0;
document.getElementById(sep+'CiudadID').selectedIndex=0;
document.getElementById(sep+'MunicipioID').selectedIndex=0;
document.getElementById(sep+'EstadoID').selectedIndex=0;
document.forms[0].submit();
}

function borrardir(sep){
document.getElementById('CP'+sep).value='';
document.getElementById('LocalidadID'+sep).selectedIndex=0;
document.getElementById('CiudadID'+sep).selectedIndex=0;
document.getElementById('MunicipioID'+sep).selectedIndex=0;
document.getElementById('EstadoID'+sep).selectedIndex=0;
document.forms[0].submit();
}

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();
}


