﻿// Archivo JScript
<!--
function select_evento() {
    var theform = get_form();
    theform.elements["ctl04$ctl01$lblMesAño"].value = theform.elements["ctl04$ctl01$ddlAdjudicacion"][theform.elements["ctl04$ctl01$ddlAdjudicacion"].selectedIndex].value;
}
function select_e() {
    var theform = get_form();   
    theform.elements["ctl04$ctl01$lblAñoE"].value = theform.elements["ctl04$ctl01$ddlEventos"][theform.elements["ctl04$ctl01$ddlEventos"].selectedIndex].value;
}
function select_p() {
    var theform = get_form();
    theform.elements["ctl04$ctl01$lblIDPromocion"].value = theform.elements["ctl04$ctl01$ddlP"][theform.elements["ctl04$ctl01$ddlP"].selectedIndex].value;
}
function get_form() {
    var theform;
    if( window.navigator.appName.toLowerCase().indexOf("microsoft") > -1 )
	    theform = document.frmInicio;
    else
	    theform = document.forms["frmInicio"];
    if( !theform )
    {
	    alert("ERROR: No se encuentra el formulario");
	    return;
    }
    return theform;
}
function select_totalp() 
{
    var theform = get_form2();    
    if (document.getElementById('ctl05_txtCuotasAnticipar').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticipar').value = "0";
    }    
    document.getElementById('ctl05_txtMontoPagar').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticipar').value);
    document.getElementById('ctl05_txtTotal').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagar').value);
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagar').value);    
    document.getElementById('ctl05_txtMontoPagar').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotal').value);
    document.getElementById('ctl05_txtTotal').innerHTML = numero2.formato(2, true);
}
function select_totalp2() 
{
    var theform = get_form2();
    if (document.getElementById('ctl05_txtCuotasAnticipar2').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticipar2').value = "0";
    }   
    document.getElementById('ctl05_txtMontoPagar2').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticipar2').value);
    document.getElementById('ctl05_txtTotal2').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagar2').value);
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagar2').value);
    document.getElementById('ctl05_txtMontoPagar2').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotal2').value );
    document.getElementById('ctl05_txtTotal2').innerHTML = numero2.formato(2, true);
}
function select_totalp3() 
{
    var theform = get_form2();
    if (document.getElementById('ctl05_txtCuotasAnticiparBanamex').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticiparBanamex').value = "0";
    }   
    document.getElementById('ctl05_txtMontoPagarBanamex').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticiparBanamex').value);    
    document.getElementById('ctl05_txtTotalBanamex').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagarBanamex').value);   
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagarBanamex').value);
    document.getElementById('ctl05_txtMontoPagarBanamex').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotalBanamex').value);
    document.getElementById('ctl05_txtTotalBanamex').innerHTML = numero2.formato(2, true);    
}
function select_totalp4() 
{
    var theform = get_form2();
    if (document.getElementById('ctl05_txtCuotasAnticiparBancomer').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticiparBancomer').value = "0";
    }   
    document.getElementById('ctl05_txtMontoPagarBancomer').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticiparBancomer').value);
    document.getElementById('ctl05_txtTotalBancomer').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagarBancomer').value);   
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagarBancomer').value);
    document.getElementById('ctl05_txtMontoPagarBancomer').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotalBancomer').value);
    document.getElementById('ctl05_txtTotalBancomer').innerHTML = numero2.formato(2, true);
}
function select_totalp5() 
{
    var theform = get_form2();
    if (document.getElementById('ctl05_txtCuotasAnticiparScotia').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticiparScotia').value = "0";
    }   
    document.getElementById('ctl05_txtMontoPagarScotia').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticiparScotia').value);
    document.getElementById('ctl05_txtTotalScotia').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagarScotia').value);   
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagarScotia').value);
    document.getElementById('ctl05_txtMontoPagarScotia').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotalScotia').value);
    document.getElementById('ctl05_txtTotalScotia').innerHTML = numero2.formato(2, true);
}
function select_totalp6() 
{
    var theform = get_form2();
    if (document.getElementById('ctl05_txtCuotasAnticiparBanorte').value == "")
    {
        document.getElementById('ctl05_txtCuotasAnticiparBanorte').value = "0";
    }   
    document.getElementById('ctl05_txtMontoPagarBanorte').value = parseFloat(theform.elements["ctl05$montopagar"].value) * parseFloat(document.getElementById('ctl05_txtCuotasAnticiparBanorte').value);
    document.getElementById('ctl05_txtTotalBanorte').value = parseFloat(theform.elements["ctl05$cuotamensual"].value) + parseFloat(theform.elements["ctl05$otroscargos"].value) + parseFloat(document.getElementById('ctl05_txtMontoPagarBanorte').value);   
    var numero = new oNumero(document.getElementById('ctl05_txtMontoPagarBanorte').value);
    document.getElementById('ctl05_txtMontoPagarBanorte').innerHTML = numero.formato(2, true);
    var numero2 = new oNumero(document.getElementById('ctl05_txtTotalBanorte').value);
    document.getElementById('ctl05_txtTotalBanorte').innerHTML = numero2.formato(2, true);
}
function select_evento2() {
    var theform = get_form2();
    theform.elements["ctl05$ctl01$lblMesAño"].value = theform.elements["ctl05$ctl01$ddlAdjudicacion"][theform.elements["ctl05$ctl01$ddlAdjudicacion"].selectedIndex].value;
}
function select_e2() {
    var theform = get_form2();   
    theform.elements["ctl05$ctl01$lblAñoE"].value = theform.elements["ctl05$ctl01$ddlEventos"][theform.elements["ctl05$ctl01$ddlEventos"].selectedIndex].value;
}
function select_p2() {
    var theform = get_form2();
    theform.elements["ctl05$ctl01$lblIDPromocion"].value = theform.elements["ctl05$ctl01$ddlP"][theform.elements["ctl05$ctl01$ddlP"].selectedIndex].value;
}
function get_form2() {
    var theform;
    if( window.navigator.appName.toLowerCase().indexOf("microsoft") > -1 ){   
	    theform = document.frmInicioClientes;}
    else{
	    theform = document.forms["frmInicioClientes"];}
    if( !theform )
    {
	    alert("ERROR: No se encuentra el formulario");
	    return;
    }
    return theform;
}
function pagaHSBC()
{
    var theform = get_form2();
    
    var cuenta = document.getElementById('ctl05_hfSucursal').value + document.getElementById('ctl05_hfCuenta').value + document.getElementById('ctl05_hfReferencia').value
    var servicio = document.getElementById('ctl05_hfServicio').value 
    var importe = document.getElementById('ctl05_txtPagarHSBC').value 
    
    window.open('PagaHSBC.aspx?cuenta=' + cuenta + '&servicio='+ servicio + '&importe=' + importe + '','PagaHSBC','');
}
////////////////
//Objeto oNumero
function oNumero(numero)
{
    //Propiedades 
    this.valor = numero || 0
    this.dec = -1;
    //Métodos 
    this.formato = numFormat;
    this.ponValor = ponValor;
    //Definición de los métodos 
    function ponValor(cad)
    {
        if (cad =='-' || cad=='+') return
        if (cad.length ==0) return
        if (cad.indexOf('.') >=0)
            this.valor = parseFloat(cad);
        else 
            this.valor = parseInt(cad);
    } 
    function numFormat(dec, miles)
    {
        var num = this.valor, signo=3, expr;
        var cad = ""+this.valor;
        var ceros = "", pos, pdec, i;
        for (i=0; i < dec; i++)
        ceros += '0';
        pos = cad.indexOf('.')
        if (pos < 0)
            cad = cad+"."+ceros;
        else
            {
                pdec = cad.length - pos -1;
                if (pdec <= dec)
                {
                    for (i=0; i< (dec-pdec); i++)
                        cad += '0';
                }
                else
                {
                    num = num*Math.pow(10, dec);
                    num = Math.round(num);
                    num = num/Math.pow(10, dec);
                    cad = new String(num);
                }
            }
        pos = cad.indexOf('.')
        if (pos < 0) pos = cad.lentgh
            if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
                signo = 4;
        if (miles && pos > signo)
            do
            {
                expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
                cad.match(expr)
                cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
            }
            while (cad.indexOf(',') > signo)
        if (dec<0) 
            cad = cad.replace(/\./,'')
        return cad;
    }
}//Fin del objeto oNumero:

//-->