// JavaScript Document
var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();

function activarCapa(capa) {
    document.getElementById(capa).style.display = '';
}

function desactivarCapa(capa) {
    document.getElementById(capa).style.display = 'none';
}

function error(eOK, eContenedor, eError, eFocus) {
    document.getElementById(eOK).style.display = 'none';
    document.getElementById(eContenedor).style.background = '#F7E0E0'
    document.getElementById(eError).style.display = '';

    if (!((eFocus != null) && (eFocus == "nofocus"))) {
        var fd = null;

        if (document.getElementById(eFocus) != null)
            fd = document.getElementById(eFocus);
        else
            if (document.getElementById(eContenedor.replace("_cont", "")) != null)
            fd = document.getElementById(eContenedor.replace("_cont", ""));
        else
            fd = document.getElementById(eContenedor);

        if (fd != null)
            if ((fd.style.display != 'none') && (fd.disabled != true))
            if (fd.parentNode != null)
            if ((fd.parentNode.style.display != 'none') && (fd.parentNode.disabled != true))
            fd.focus();
    }
}

function ok(eOK, eContenedor, eError, abrir) {
    document.getElementById(eOK).style.display = '';
    document.getElementById(eContenedor).style.background = '#F7F7F7'
    document.getElementById(eError).style.display = 'none';
}

function Cok1(eOK, eContenedor, eError, abrir) {
    document.getElementById(eOK).style.display = '';
    document.getElementById(eContenedor).style.background = 'none'
    document.getElementById(eError).style.display = 'none';
}

function addOpt(oCntrl, iPos, sTxt, sVal) {
    var selOpcion = new Option(sTxt, sVal);
    eval(oCntrl.options[iPos] = selOpcion);
}

function MotrosConductores() {
    document.getElementById('otros_cont').style.display = "";
    ValidatorEnable(document.getElementById('Validator_otrosck'), false);
    ok('ok_otrosck', 'otrosck_cont', 'error_otrosck');
}

function OotrosConductores() {

    document.getElementById('otros_cont').style.display = "none";
    document.datos_frm.conyuge.checked = false;
    document.datos_frm.menosde25.checked = false;
    document.datos_frm.masde25.checked = false;
    document.datos_frm.otrosmenores25.checked = false;
    document.datos_frm.otrosmayores25.checked = false;
    ValidatorEnable(document.getElementById('Validator_otrosck'), false);
    ok('ok_otrosck', 'otrosck_cont', 'error_otrosck');
}

function bloqueaMatricula(oCntrl) {


    
    
       
    switch (document.datos_frm.nuevo.value) {
        case "4":
            oCntrl.value = "europea";
            oCntrl.disabled = true;
            var fecha = new Date();
            var diames = fecha.getDate();
            var mes = fecha.getMonth() + 1;
            var ano = fecha.getFullYear();
            document.getElementById('dia').value = diames;
            document.getElementById('mes').value = mes;
            document.getElementById('ano').value = ano;
            document.getElementById('matricula_cont').style.display = "none";
            document.getElementById('fecha_cont').style.display = "none";
            break;

        default:
            oCntrl.value = "?";
            oCntrl.disabled = false;
            document.getElementById('dia').value = 0;
            document.getElementById('mes').value = 0;
            document.getElementById('ano').value = 0;
            document.getElementById('fecha_cont').style.display = "";
            document.getElementById('matricula_cont').style.display = "none";
            break;
    }
}

function desMatricula(oCntrl) {
    if (oCntrl.disabled == true) {
        oCntrl.value = "?";
        oCntrl.disabled = false;

        document.getElementById('dia').disabled = false;
        document.getElementById('mes').disabled = false;
        document.getElementById('ano').disabled = false;
    }
}

function partesShow() {
    document.getElementById('sinsiniestros_div').style.display = "none";
    document.getElementById('siniestros_cont').style.display = "";
    ValidatorEnable(document.getElementById('Validator_sini'), false);
    ValidatorEnable(document.getElementById('Validator_sinsiniestros'), false);
    ValidatorEnable(document.getElementById('Validator_sintercero'), true);
    ValidatorEnable(document.getElementById('Validator_contercero'), true);
    ValidatorEnable(document.getElementById('Validator_conterceroculpable'), true);
    ok('ok_sini', 'sini_cont', 'error_sini');
}

function partesHide() {
    document.getElementById('sinsiniestros_div').style.display = "";
    document.getElementById('siniestros_cont').style.display = "none";
    ValidatorEnable(document.getElementById('Validator_sini'), false);
    ValidatorEnable(document.getElementById('Validator_sinsiniestros'), true);
    ValidatorEnable(document.getElementById('Validator_sintercero'), false);
    ValidatorEnable(document.getElementById('Validator_contercero'), false);
    ValidatorEnable(document.getElementById('Validator_conterceroculpable'), false);
    ok('ok_sini', 'sini_cont', 'error_sini');
}

function partesG() {

    if (document.getElementById('conterceroculpable').value == 0) {
        document.getElementById('sinsiniestros_div').style.display = "";
        ValidatorEnable(document.getElementById('Validator_sinsiniestros'), true);
    } else {
        document.getElementById('sinsiniestros_div').style.display = "none";
        ValidatorEnable(document.getElementById('Validator_sinsiniestros'), false);
    }

}

var nav4 = window.Event ? true : false;
function acceptNum(evt) {
    // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
    var key = nav4 ? evt.which : evt.keyCode;
    return (key <= 13 || (key >= 48 && key <= 57));
}

var text = "";
function getActiveText(e) {

    // Sets text MSIE or Netscape active 
    // text based on browser, puts text in form
    text = (document.all) ? document.selection.createRange().text : document.getSelection();

    document.theform.text.value = text;
    return true;
}

function Vnacimiento() {
    if (document.getElementById('anonaci').value != 'AAAA') {
        var fecha = new Date();
        var diames = fecha.getDate();
        var mes = fecha.getMonth() + 1;
        var ano = fecha.getFullYear();
        if (document.getElementById('anonaci').value.length == 4) {
            if ((ano - document.getElementById('anonaci').value) > 18 && document.getElementById('anonaci').value != 0) {
                if ((document.getElementById('anonaci').value % 4 == 0) && ((document.getElementById('anonaci').value % 100 != 0) || (document.getElementById('anonaci').value % 400 == 0))) {
                    if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 29) {
                        error('ok_fechan', 'fechan_cont', 'error_fechan');
                    } else {
                        ok('ok_fechan', 'fechan_cont', 'error_fechan');
                    }
                } else {
                    if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 28) {
                        error('ok_fechan', 'fechan_cont', 'error_fechan');
                    } else {
                        ok('ok_fechan', 'fechan_cont', 'error_fechan');
                    }
                }

            } else if ((ano - document.getElementById('anonaci').value) == 18) {
                if (mes > document.getElementById('mesnac').value && document.getElementById('mesnac').value != 0) {

                    if ((document.getElementById('anonaci').value % 4 == 0) && ((document.getElementById('anonaci').value % 100 != 0) || (document.getElementById('anonaci').value % 400 == 0))) {
                        if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 29) {
                            error('ok_fechan', 'fechan_cont', 'error_fechan');
                        } else {
                            ok('ok_fechan', 'fechan_cont', 'error_fechan');
                        }
                    } else {
                        if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 28) {
                            error('ok_fechan', 'fechan_cont', 'error_fechan');
                        } else {
                            ok('ok_fechan', 'fechan_cont', 'error_fechan');
                        }
                    }

                } else if (mes > document.getElementById('mesnac').value) {
                    if (dia >= document.getElementById('dianac').value && document.getElementById('dianac').value != 0) {

                        if ((document.getElementById('anonaci').value % 4 == 0) && ((document.getElementById('anonaci').value % 100 != 0) || (document.getElementById('anonaci').value % 400 == 0))) {
                            if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 29) {
                                error('ok_fechan', 'fechan_cont', 'error_fechan');
                            } else {
                                ok('ok_fechan', 'fechan_cont', 'error_fechan');
                            }
                        } else {
                            if (document.getElementById('mesnac').value == 2 && document.getElementById('dianac').value > 28) {
                                error('ok_fechan', 'fechan_cont', 'error_fechan');
                            } else {
                                ok('ok_fechan', 'fechan_cont', 'error_fechan');
                            }
                        }


                    } else {

                        error('ok_fechan', 'fechan_cont', 'error_fechan');

                    }
                } else {

                    error('ok_fechan', 'fechan_cont', 'error_fechan');

                }
            } else {
                error('ok_fechan', 'fechan_cont', 'error_fechan');
            }

        }
    }
}

function Vcarnet() {
    if (document.getElementById('ano').value != 'AAAA') {
        if (document.getElementById('anonaci').value.length == 4 && document.getElementById('mesnac').value != 0 && document.getElementById('dianac').value != 0) {

            var diames = parseInt(document.getElementById('dianac').value);
            var mes = parseInt(document.getElementById('mesnac').value);
            var ano = parseInt(document.getElementById('anonaci').value);


            if ((ano + 18) < document.getElementById('ano').value && document.getElementById('ano').value != 0) {
                ok('ok_fecha', 'fecha_cont', 'error_fecha');
            } else if ((ano + 18) == document.getElementById('ano').value) {
                if (mes <= document.getElementById('mes').value && document.getElementById('mes').value != 0) {
                    ok('ok_fecha', 'fecha_cont', 'error_fecha');
                } else {

                    error('ok_fecha', 'fecha_cont', 'error_fecha');

                }
            } else {

                error('ok_fecha', 'fecha_cont', 'error_fecha');

            }

        } else {

            error('ok_fecha', 'fecha_cont', 'error_fecha');
            error('ok_fechan', 'fechan_cont', 'error_fechan');

        }
    }
}

function Vfecha(src, arg) {

    var esValidado = true;

    if (document.getElementById('VHExpirationPreviousPolicyDateYear').value != 0 && document.getElementById('VHExpirationPreviousPolicyDateMonth').value != 0 && document.getElementById('VHExpirationPreviousPolicyDateDay').value != 0) {

        if ((document.getElementById('VHExpirationPreviousPolicyDateYear').value % 4 == 0) && ((document.getElementById('VHExpirationPreviousPolicyDateYear').value % 100 != 0) || (document.getElementById('VHExpirationPreviousPolicyDateYear').value % 400 == 0))) {
            if (document.getElementById('VHExpirationPreviousPolicyDateMonth').value == 2 && document.getElementById('VHExpirationPreviousPolicyDateDay').value > 29) {
                esValidado = false;
            } else {
                esValidado = true;
            }
        } else {
            if (document.getElementById('VHExpirationPreviousPolicyDateMonth').value == 2 && document.getElementById('VHExpirationPreviousPolicyDateDay').value > 28) {
                esValidado = false;
            } else {
                esValidado = true;
            }
        }

    } else {
        esValidado = false;
    }

    if (arg == null)
        ValidatorEnable(document.getElementById('Validator_fecha'), esValidado);

    if (esValidado)
        ok('ok_fecha', 'fecha_cont', 'error_fecha');
    else
        error('ok_fecha', 'fecha_cont', 'error_fecha');



}

function Vdate() {

    if (document.getElementById('ano').value != 0 && document.getElementById('mes').value != 0 && document.getElementById('dia').value != 0) {

        if ((document.getElementById('ano').value % 4 == 0) && ((document.getElementById('ano').value % 100 != 0) || (document.getElementById('ano').value % 400 == 0))) {
            if (document.getElementById('mes').value == 2 && document.getElementById('dia').value > 29) {
                error('ok_fecha', 'fecha_cont', 'error_fecha');
            } else {
                ok('ok_fecha', 'fecha_cont', 'error_fecha');
            }
        } else {
            if (document.getElementById('mes').value == 2 && document.getElementById('dia').value > 28) {
                error('ok_fecha', 'fecha_cont', 'error_fecha');
            } else {
                ok('ok_fecha', 'fecha_cont', 'error_fecha');
            }
        }

    } else {

        error('ok_fecha', 'fecha_cont', 'error_fecha');
        //error('ok_fechan', 'fecha_cont', 'error_fechan');

    }
}

function validatelogin(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    var Valor = eval("document.all." + chkControlId + ".value");
    arg.IsValid = false;
    arg.IsValid = (arg.Value != '');
    if (!arg.IsValid) error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    if (arg.IsValid) Cok1('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);

}

function validatecombo(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    arg.IsValid = arg.Value != 0;
    if (!arg.IsValid) error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    if (arg.IsValid) ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
}
function validatecombonueve(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    arg.IsValid = arg.Value != 9;
    if (!arg.IsValid) error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    if (arg.IsValid) ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
}
function validatecombox(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    arg.IsValid = arg.Value != 'x';
    if (!arg.IsValid) error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    if (arg.IsValid) ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
}
function validatenaci(src, arg) {
    Vnacimiento();
    arg.IsValid = document.getElementById('ok_fechan').style.display == '';
}
function validatecarnet(src, arg) {
    Vcarnet();
    arg.IsValid = document.getElementById('ok_fecha').style.display == '';
}
function validatefecha(src, arg) {
    Vdate();
    arg.IsValid = document.getElementById('ok_fecha').style.display == '';
}

function validateFechaEfecto(src, arg) {
    if ((parseInt(document.getElementById('ano').value) != 0)
        ||
        (src.id == 'Validator_fechaAno')) {
        var fHoy = new Date();
        var nHoy = Date.UTC(fHoy.getFullYear(), fHoy.getMonth(), fHoy.getDate(), 0, 0, 0, 0);

        var nEfecto = Date.UTC(parseInt(document.getElementById('ano').value),
                              (parseInt(document.getElementById('mes').value) - 1),
                               parseInt(document.getElementById('dia').value), 1, 1, 1, 1);

        if (nEfecto < nHoy)
            error('ok_fecha', 'fecha_cont', 'error_fecha');
        else {
            Vdate();
        }

        arg.IsValid = document.getElementById('ok_fecha').style.display == '';
    }
}

function validateradio(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    if (document.getElementById(chkControlId + '1').checked == false && document.getElementById(chkControlId + '2').checked == false) {
        arg.IsValid = false;
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    }
    else {
        arg.IsValid = true;
    }
}


function validateCheckTrue(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (document.getElementById(chkControlId).checked == false) {
        arg.IsValid = false;
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
    }
    else {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }
}

function validateTextCaracter(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (containNumeric(arg.Value)) {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
    else {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }

}

function validateTextCaracterNoVacio(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if ( containNumeric(arg.Value) || (arg.Value == "") ) {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
    else {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }

}

function validateCCC(src, arg) {

    var check = (trim(document.getElementById('cccCuenta').value).length != 0);
    // Se valida cuando proceda del validador de cuentea o el campo cccCuenta tenga contenido
    if (check || src.id.replace("Validator_", "") == 'cccCuenta')
        if (checkBankCode(document.getElementById('cccEntidad').value)
          &&
          checkOfficeCode(document.getElementById('cccSucursal').value)
          &&
          checkControlDigit(document.getElementById('cccDC').value)
          &&
          checkAccountNumber(document.getElementById('cccCuenta').value)) {
        ok('ok_ccc', 'ccc_cont', 'error_ccc', 1);
        arg.IsValid = true; // avance pagina 
    }
    else {
        error('ok_ccc', 'ccc_cont', 'error_ccc', 'cccEntidad');
        //error('ok_ccc','ccc_cont','error_ccc');
        arg.IsValid = false;
    }
}


function validateTrue(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
    arg.IsValid = true; // avance pagina 
}

function validateTextNumericPoliza(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if ( !(isNaN(arg.Value) )  ) {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }
    else {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
}

function validateTextNumeric(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (!(isNaN(arg.Value))) {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }
    else {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
}

function validateTextNumericNoVacio(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if ( !(isNaN(arg.Value)) && (arg.Value != "") ) {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina 
    }
    else {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
}

// Valida NIF, CIF, NIE  
function validateTextNif(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (checkCIF(arg.Value) || checkNIE(arg.Value) || checkNIF(arg.Value)) {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true; // avance pagina
    }
    else {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }

}


function SeleccionarVersion(obj, num) {
    if (obj.childNodes[1].style.backgroundColor == "") {
        document.getElementById('seleccionado').value = num;
        document.getElementById('versiones_modelos').style.background = '#F7F7F7'
        document.getElementById('error_version').style.display = 'none';
        var tabla = document.getElementById('GridView1');
        var j;

        for (i = 0; i < tabla.rows.length; i++) {
            if (tabla.rows[i].cells[1].style.backgroundColor != "") {
                tabla.rows[i].cells[0].style.backgroundColor = "";
                tabla.rows[i].cells[1].style.backgroundColor = "";
                tabla.rows[i].cells[2].style.backgroundColor = "";
                tabla.rows[i].cells[3].style.backgroundColor = "";
                tabla.rows[i].cells[4].style.backgroundColor = "";
            }

            j = (i + 2);
            if (j <= 9) { j = '0' + j; }

            if (j != num + 2)
                document.getElementById('GridView1_ctl' + j + '_RowSelector').checked = false;
            else
                document.getElementById('GridView1_ctl' + j + '_RowSelector').checked = true;
        }

        if (navigator.userAgent.indexOf("Firefox") != -1) {
            i = 1
        } else { i = 0 }
        obj.childNodes[i].style.backgroundColor = "#AFAFAF";
        obj.childNodes[i + 1].style.backgroundColor = "#AFAFAF";
        obj.childNodes[i + 2].style.backgroundColor = "#AFAFAF";
        obj.childNodes[i + 3].style.backgroundColor = "#AFAFAF";
        obj.childNodes[i + 4].style.backgroundColor = "#AFAFAF";

        document.getElementById('divBtnSiguiente').style.display = "";

    };
}
/***********************************************************************/
/******************* Funciones para dato_seguro.aspx *******************/

function showAntecedentsOptions(tipo, habilitar) {

    if (tipo == "CarSecured") {
        document.getElementById('CarSecured_cont').style.display = "";
        ok('ok_CarSecured', 'CarSecured_cont', 'error_CarSecured');
    }
    else {
        document.getElementById('ExistPreviousContract_cont').style.display = "";
        ok('ok_ExistPreviousContract', 'ExistPreviousContract_cont', 'error_ExistPreviousContract');
    }

    if (document.getElementById('medio_cont').style.display != "none")
        ValidatorEnable(document.getElementById('Validator_medio'), true);
    else
        ValidatorEnable(document.getElementById('Validator_medio'), false);

    ValidatorEnable(document.getElementById('Validator_ExistPreviousContract'), false);
    ValidatorEnable(document.getElementById('Validator_CarSecured'), false);

    if (habilitar) {
        document.getElementById('opciones_comunes').style.display = '';

        //Habilitamos la validaciones.
        ValidatorEnable(document.getElementById('Validator_TypePreviousPolicy'), true);
        ValidatorEnable(document.getElementById('Validator_CompanyPreviousPolicy'), true);
        ValidatorEnable(document.getElementById('Validator_YearsInPreviousPolicyCompany'), true);

        if (tipo == "CarSecured") {
            //Habilitamos las opciones de antecedentes por coche.
            document.getElementById('Suscriptor_cont').style.display = '';
            ValidatorEnable(document.getElementById('Validator_Suscriptor'), true);
        }
        else {
            document.getElementById('Suscriptor_cont').style.display = 'none';
        }
    }
    else {
        //Deshabilitamos las validaciones de los campos.
        ValidatorEnable(document.getElementById('Validator_TypePreviousPolicy'), false);
        ValidatorEnable(document.getElementById('Validator_CompanyPreviousPolicy'), false);
        ValidatorEnable(document.getElementById('Validator_YearsInPreviousPolicyCompany'), false);
        ValidatorEnable(document.getElementById('Validator_Suscriptor'), false);
        ValidatorEnable(document.getElementById('Validator_CarSecured'), false);

        document.getElementById('opciones_comunes').style.display = 'none';
        document.getElementById('Suscriptor_cont').style.display = 'none';
    }
}

function previousCompany() {

    var ctrl = document.getElementById('pol_ant');
    
    var combo = document.getElementById('CompanyPreviousPolicy');
    
    
     if((ctrl!=null) &&(combo!=null))
      {  
          if((combo.options[combo.selectedIndex].attributes['tirea']!=null && 
          combo.options[combo.selectedIndex].attributes['tirea'].value=='1'))
          {  
             ctrl.style.display = '';
             
              
          }else
          {
          
            
            ctrl.style.display = 'none'; 
            
           
          }
         
      }
      
    if (document.datos_frm.CompanyPreviousPolicy.value == '10730') {
    
     if(ctrl!=null) 
      {  
        ctrl.style.display = 'none';
        }
        document.getElementById('BonicacionDirect_cont').style.display = '';
        document.getElementById('YearsInPreviousPolicyCompany_cont').style.display = 'none';
        ValidatorEnable(document.getElementById('Validator_YearsInPreviousPolicyCompany'), false);
        ValidatorEnable(document.getElementById('Validator_BonicacionDirect'), true);
    } 
    else {
    
      
      
        document.getElementById('BonicacionDirect_cont').style.display = 'none';
        document.getElementById('YearsInPreviousPolicyCompany_cont').style.display = '';
        ValidatorEnable(document.getElementById('Validator_YearsInPreviousPolicyCompany'), true);
        ValidatorEnable(document.getElementById('Validator_BonicacionDirect'), false);
        document.getElementById('YearsInPreviousPolicyCompany').value = 0; 
        document.datos_frm.YearsInPreviousPolicyCompany.value = 0;
        
        
         var ctrlPoliza = document.getElementById('txtNumPoliza');
            var ctrNif  = document.getElementById('condNif');
            if((ctrlPoliza!=null)&&(ctrNif!=null))
            {   
         
                ctrlPoliza.value = '';
                ctrNif.value = '';
                
            }
    }
}

function ValidateTravel() {

    if (document.getElementById('numsocio').value != "" || document.getElementById('numsocio2').value != "") {
        if (!containNumeric(document.getElementById('numsocio').value)) {
            error('ok_travel', 'travel_cont', 'error_travel');
            return;
        }
        if (!containNumeric(document.getElementById('numsocio2').value)) {
            error('ok_travel', 'travel_cont', 'error_travel');
            return;
        }
    }
    ok('ok_travel', 'travel_cont', 'error_travel');

}

/******************* Fin Funciones para dato_seguro.aspx *******************/
/***************************************************************************/

function RecargaTr() {
    var formapago;
    if (document.getElementById('pago') != null) {
        formapago = document.getElementById('pago').value
    } else {
        formapago = 0;
    }
    if (document.getElementById('cambio').value == 4)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('sinfranq_desc').value; }
    if (document.getElementById('cambio').value == 7)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('franqA_desc').value; }
    if (document.getElementById('cambio').value == 8)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('franqB_desc').value; }
    if (document.getElementById('cambio').value == 10)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('franqC_desc').value; }
    if (document.getElementById('cambio').value == 11)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('franqD_desc').value; }
    if (document.getElementById('cambio').value == 12)
    { document.getElementById('franq_tr').innerHTML = document.getElementById('franqE_desc').value; }
    if (prima[document.getElementById('cambio').value][formapago] == 0) {
        alert('Esta combinacion de importe de franquicia y modo de pago no es posible. Por favor seleccione alguna otra opcion.');
        document.getElementById('precio_tr').innerHTML = '-- ';
    } else {
        document.getElementById('precio_tr').innerHTML = prima[document.getElementById('cambio').value][formapago];
    }
    if (document.getElementById('precio_tr2') != null) {
        document.getElementById('precio_tr2').innerHTML = document.getElementById('precio_tr').innerHTML;
    }

    if (document.getElementById('pago').value == 1) {
        document.getElementById('FpagoTR').innerHTML = "Semestral";
    }
    else {
        document.getElementById('FpagoTR').innerHTML = "Anual";
    }

    document.forms[0].hprecio_tr.value = document.getElementById('precio_tr2').innerHTML;
    document.forms[0].hfranq_tr.value = document.getElementById('franq_tr').innerHTML;
}
function RecargaTA() {
    document.getElementById('precio_ta').innerHTML = prima[1][document.getElementById('pagoTA').value];
    if (document.getElementById('precio_ta2') != null) {
        document.getElementById('precio_ta2').innerHTML = document.getElementById('precio_ta').innerHTML;
    }

    if (document.getElementById('pagoTA').value == 1) {
        document.getElementById('FpagoTA').innerHTML = "Semestral";
    }
    else {
        document.getElementById('FpagoTA').innerHTML = "Anual";
    }
    
    document.forms[0].hprecio_ta.value = document.getElementById('precio_ta2').innerHTML;
}

// Funcion de Aceptación de condiciones pagina contratarDos.aspx y guardar.aspx
function chequear() {
    for (i = 0; i < document.forms[0].elements.length; i++) {
        if (document.forms[0].elements[i].id.substr(0, 6) == "nomail") {
            if (document.forms[0].estadoNomail.value != "S")
                document.forms[0].elements[i].checked = true;
            else
                document.forms[0].elements[i].checked = false;
        }
    }
    if (document.forms[0].estadoNomail.value != "S")
        document.forms[0].estadoNomail.value = "S";
    else
        document.forms[0].estadoNomail.value = "N";
}

// pagina contratarDos.aspx, sirve para mostrar ventana.
function continuar() {
    //document.getElementById('pag_cont').style.display='';
    document.getElementById('pag_cont').style.display = 'block';
    document.getElementById('msg_cont').style.display = 'none';

}

function validatefechaSegMano(src, arg) {

    Vdate();

    if (document.getElementById('fecha_cont').style.display = "none") {
        arg.IsValid = true;
        return;
    }

    checkFaMatriculacion_Integrity();

    arg.IsValid = document.getElementById('ok_fecha').style.display == '';
}

function PrintPage() {
    if (!window.print());
    else {
        //FIREFOX
        if (navigator.userAgent.indexOf("Firefox") == -1) {
            var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
            document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
            WebBrowser1.ExecWB(6, 2);
        }
    }
}

function checkFaMatriculacion_Integrity() {

    datosF = (document.layers) ? document.lycapa.document.datos_frm : document.datos_frm;

    cpt = datosF.nuevo.options[datosF.nuevo.selectedIndex].value;
    curDate = new Date;
    cDay = curDate.getDate();
    cMonth = curDate.getMonth();
    cYear = curDate.getFullYear();
    frtDate = new Date;

    frtDay = datosF.dia.options[datosF.dia.selectedIndex].value;
    frtMonth = datosF.mes.options[datosF.mes.selectedIndex].value - 1;
    frtYear = datosF.ano.options[datosF.ano.selectedIndex].value;
    frtDate.setFullYear(frtYear, frtMonth, frtDay)
    if (cpt == 4 &&  // Es nuevo
        frtDay != 0 && frtMonth >= 0 && frtYear != 0) {
        curDate.setFullYear(cYear, cMonth, cDay - 30)
        if (frtDate < curDate) {
            error('ok_fecha', 'fecha_cont', 'error_fecha', 'nofocus');

            Validator_fecha.innerHTML = 'por favor, revisa tus respuestas. has indicado que el vehiculo es nuevo y la fecha de primera matriculacion es superior a un mes.';

            return 1;
        }
    }

    if (cpt == 5 &&  //de 2ª mano
        frtDay != 0 && frtMonth >= 0 && frtYear != 0) {
        curDate.setFullYear(cYear, cMonth, cDay)
        if (curDate < frtDate) {
            error('ok_fecha', 'fecha_cont', 'error_fecha', 'nofocus');

            Validator_fecha.innerHTML = 'por favor, revisa tus respuestas. has indicado que el vehiculo es de segunda mano por lo que ya debe estar matriculado.';

            return 2;
        }
    }
    if (cpt == 6 &&  //Ya lo tenía
        frtDay != 0 && frtMonth >= 0 && frtYear != 0) {
        curDate.setFullYear(cYear, cMonth, cDay - 61)
        if (frtDate > curDate) {
            curDate.setFullYear(cYear, cMonth, cDay)
            {
                error('ok_fecha', 'fecha_cont', 'error_fecha', 'nofocus');
                if (curDate < frtDate) {

                    Validator_fecha.innerHTML = "por favor, revisa tus respuestas. has indicado que ya tienes el vehiculo por lo que ya debe estar matriculado.";

                    return 3;
                }
                else {

                    Validator_fecha.innerHTML = 'por favor, revisa tus respuestas. has indicado que compraste el vehiculo hace mas de 60 dias y la fecha de primera matriculacion es inferior a este periodo.';

                    return 3;
                }
            }
        }
    }
    if (frtDay != 0 && frtMonth >= 0 && frtYear != 0)
        ok('ok_fecha', 'fecha_cont', 'error_fecha');
    return 0;
}

function LanzarEncuesta() {
    var isClosed = false;  //(document.readyState == "complete");

    try {
        switch (BrowserDetect.browser) {
            case 'Firefox':
                isClosed = (self.innerWidth == 0) || (self.innerHeight == 0);
                break;

            case 'Explorer':
                isClosed = (self.document.readyState == "complete");
                break;
        }
    }
    catch (ex) {
        isClosed = true;
    }
    
    if (isClosed == true) {
        var rutaAbsoluta = window.location.href;
        var posicionUltimaBarra = rutaAbsoluta.lastIndexOf("/");
        var rutaRelativa = rutaAbsoluta.substring(posicionUltimaBarra + "/".length, rutaAbsoluta.length);
        var pathRuta = rutaAbsoluta.substring(0, posicionUltimaBarra + "/".length);
        pathRuta = pathRuta.replace('https://', 'http://');

        if ((rutaRelativa == "datos_vehiculo.aspx") || (rutaRelativa == "conductores.aspx") || (rutaRelativa == "dato_conductor.aspx") || (rutaRelativa == "dato_seguro.aspx")) {
            window.open(pathRuta + 'encuesta.aspx?id=2', 'EncuestaWindow', 'width=450, height=700,top=100,left=100,toolbar=no,menubar=no,menubar=no,scrollbars=no,resizeable=no,location=no,status=no');
            //window.open(pathRuta + 'encuesta.aspx?id=2', 'EncuestaWindow', 'width=450, height=700,top=100,left=100,toolbar=yes,menubar=yes,menubar=yes,scrollbars=yes,resizeable=yes,location=yes,status=yes');
        }
        if ((rutaRelativa == "resultadoskits.aspx")) {
            window.open(pathRuta + 'encuesta.aspx?id=1', 'EncuestaWindow', 'width=450, height=700,top=100,left=100,toolbar=no,menubar=no,menubar=no,scrollbars=no,resizeable=no,location=no,status=no');
        }
    }
    return false;
}

function focoversiones() {
/*
    if ((document.getElementById('versiones_modelos') != null) || (document.getElementById('versiones_modelos_notfound') != null)) {
        document.getElementById('Submit').focus();
    } else {
        setTimeout('focoversiones()', 300);
    }
    */
}

function validatecombo1(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");
    arg.IsValid = arg.Value != 0;
    if (!arg.IsValid) error('ok_' + chkControlId.replace("ctl00_Contenido_", ""), chkControlId.replace("ctl00_Contenido_", "") + '_cont', 'error_' + chkControlId.replace("ctl00_Contenido_", ""));
    if (arg.IsValid) ok('ok_' + chkControlId.replace("ctl00_Contenido_", ""), chkControlId.replace("ctl00_Contenido_", "") + '_cont', 'error_' + chkControlId.replace("ctl00_Contenido_", ""), 1);
}

function validateFechas(src, arg) {
    var chkControlId = src.id.replace("Validator_", "");

    DateInicio = new Date;
    DateFin = new Date;
    DateInicioMasDos = new Date;

    var sDateInicio = document.getElementById('ctl00_Contenido_t_fechaInicio').value;
    var sDateFin = document.getElementById('ctl00_Contenido_t_fechaFin').value;

    // Añado funcion quitarmes. Si se quita la función falla al validar el mes de diciembre.
    // El problema es que javascript al convertirlo a año, el mes 01 no lo considera enero, sino ferbrero
    // Y entonces hace cosas raras en el mes de diciembre

    DateInicio.setFullYear(sDateInicio.substr(6, 4), quitarmes(sDateInicio.substr(3, 2)), sDateInicio.substr(0, 2));
    DateFin.setFullYear(sDateFin.substr(6, 4), quitarmes(sDateFin.substr(3, 2)), sDateFin.substr(0, 2));
    DateInicioMasDos.setFullYear(sDateInicio.substr(6, 4), DateInicio.getMonth() + 2, sDateInicio.substr(0, 2));

    document.getElementById('ctl00_Contenido_Validator_t_fechaInicio').innerHTML = '';
    document.getElementById('ctl00_Contenido_Validator_t_fechaFin').innerHTML = '';

    if (DateInicio > DateFin) {

        if (chkControlId == 'ctl00_Contenido_t_fechaInicio') {
            error('ok_t_fechaInicio', 'ctl00_Contenido_t_fechaInicio_cont', 'error_t_fechaInicio')
            document.getElementById('ctl00_Contenido_Validator_t_fechaInicio').innerHTML = 'La fecha de inicio no puede ser mayor a la fecha de fin';
        }
        else {
            error('ok_t_fechaFin', 'ctl00_Contenido_t_fechaFin_cont', 'error_t_fechaFin')
            document.getElementById('ctl00_Contenido_Validator_t_fechaFin').innerHTML = 'La fecha de fin no puede ser menor a la fecha de inicio';
        }
        arg.IsValid = false;
        return;
    }

    if (DateFin > DateInicioMasDos) {
        if (chkControlId == 'ctl00_Contenido_t_fechaInicio') {
            error('ok_t_fechaInicio', 'ctl00_Contenido_t_fechaInicio_cont', 'error_t_fechaInicio')
            document.getElementById('ctl00_Contenido_Validator_t_fechaInicio').innerHTML = 'No puede haber mas de dos meses de diferencia entre fechas';
        }
        else {
            error('ok_t_fechaFin', 'ctl00_Contenido_t_fechaFin_cont', 'error_t_fechaFin')
            document.getElementById('ctl00_Contenido_Validator_t_fechaFin').innerHTML = 'No puede haber mas de dos meses de diferencia entre fechas';
        }
        arg.IsValid = false;
        return;
    }

    ok('ok_t_fechaFin', 'ctl00_Contenido_t_fechaFin_cont', 'error_t_fechaFin', "");
    ok('ok_t_fechaInicio', 'ctl00_Contenido_t_fechaInicio_cont', 'error_t_fechaInicio', "");
    arg.IsValid = true;
}

function quitarmes(mes) {
    switch (mes) {
        case "01": return "00";
            break;
        case "01": return "00";
            break;
        case "02": return "01";
            break;
        case "03": return "02";
            break;
        case "04": return "03";
            break;
        case "05": return "04";
            break;
        case "06": return "05";
            break;
        case "07": return "06";
            break;
        case "08": return "07";
            break;
        case "09": return "08";
            break;
        case "10": return "09";
            break;
        case "11": return "10";
            break;
        case "12": return "11";
            break;
        default:
            return mes;
            break;
    }
}

function mostrarProgreso(eliminar) 
{
    if (document.getElementById('div_tr') != null) {
        if (document.getElementById('div_tr').className == "activo") {
            document.getElementById('progresoTR').style.display = '';

            document.getElementById('precioSupTR').style.display = '';
            document.getElementById('precioSupTAInact').style.display = '';
            document.getElementById('precioSupTBInact').style.display = '';
        }
    }
    
    if (document.getElementById('div_ta') != null) {
        if (document.getElementById('div_ta').className == "activo") {
            document.getElementById('progresoTA').style.display = '';
            document.getElementById('precioSupTA').style.display = '';

            if (document.getElementById('div_tr') != null) document.getElementById('precioSupTRInact').style.display = '';
            if (document.getElementById('div_tb') != null) document.getElementById('precioSupTBInact').style.display = '';
        }
    }
    if (document.getElementById('div_tb') != null) {
        if (document.getElementById('div_tb').className == "activo") {
            document.getElementById('progresoTB').style.display = '';
            document.getElementById('precioSupTB').style.display = '';

            if (document.getElementById('div_tr') != null) document.getElementById('precioSupTRInact').style.display = '';
            if (document.getElementById('div_ta') != null) document.getElementById('precioSupTAInact').style.display = '';
        }
    }

    if (eliminar) {
        eliminarProgreso();    
    }
    
}

function eliminarProgreso() {
    setTimeout(quitarProgreso, 1000);         
}

function quitarProgreso(){
    if (document.getElementById('div_tr') != null) {
        if (document.getElementById('div_tr').className == "activo") {
            document.getElementById('progresoTR').style.display = 'none';

            document.getElementById('precioSupTR').style.display = 'none';
            document.getElementById('precioSupTAInact').style.display = 'none';
            document.getElementById('precioSupTBInact').style.display = 'none';
        }
    }

    if (document.getElementById('div_ta') != null) {
        if (document.getElementById('div_ta').className == "activo") {
            document.getElementById('progresoTA').style.display = 'none';
            document.getElementById('precioSupTA').style.display = 'none';

            if (document.getElementById('div_tr') != null) document.getElementById('precioSupTRInact').style.display = 'none';
            if (document.getElementById('div_tb') != null) document.getElementById('precioSupTBInact').style.display = 'none';
        }
    }
    if (document.getElementById('div_tb') != null) {
        if (document.getElementById('div_tb').className == "activo") {
            document.getElementById('progresoTB').style.display = 'none';
            document.getElementById('precioSupTB').style.display = 'none';

            if (document.getElementById('div_tr') != null) document.getElementById('precioSupTRInact').style.display = 'none';
            if (document.getElementById('div_ta') != null) document.getElementById('precioSupTAInact').style.display = 'none';
        }
    }    
}

function MostrarMasInfo(strEstilo) {
    document.getElementById(strEstilo).className = 'masInfoToolTip';
}

/*
$(document).ready(function() {

    $('#info_h1').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h1 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h1').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h1 span').attr('style', 'display: none;');
    });

    $('#info_h2').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h2 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h2').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h2 span').attr('style', 'display: none;');
    });

    $('#info_h3').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h3 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h3').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h3 span').attr('style', 'display: none;');
    });

    $('#info_h4').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h4 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h4').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h4 span').attr('style', 'display: none;');
    });

    $('#info_h5').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h5 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h5').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h5 span').attr('style', 'display: none;');
    });

    $('#info_h6').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h6 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h6').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h6 span').attr('style', 'display: none;');
    });

    $('#info_h7').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h7 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h7').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h7 span').attr('style', 'display: none;');
    });

    $('#info_h8').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h8 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h8').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h8 span').attr('style', 'display: none;');
    });

    $('#info_h9').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h9 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h9').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h9 span').attr('style', 'display: none;');
    });

    $('#info_h10').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h10 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h10').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h10 span').attr('style', 'display: none;');
    });

    $('#info_h11').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h11 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h11').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h11 span').attr('style', 'display: none;');
    });

    $('#info_h12').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h12 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h12').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h12 span').attr('style', 'display: none;');
    });

    $('#info_h13').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h13 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h13').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h13 span').attr('style', 'display: none;');
    });

    $('#info_h14').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h14 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h14').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h14 span').attr('style', 'display: none;');
    });

    $('#info_h15').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h15 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h15').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h15 span').attr('style', 'display: none;');
    });

    $('#info_h16').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h16 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h16').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h16 span').attr('style', 'display: none;');
    });

    $('#info_h17').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h17 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h17').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h17 span').attr('style', 'display: none;');
    });

    $('#info_h18').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h18 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h18').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h18 span').attr('style', 'display: none;');
    });

    $('#info_h19').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h19 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h19').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h19 span').attr('style', 'display: none;');
    });

    $('#info_h20').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h20 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h20').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h20 span').attr('style', 'display: none;');
    });

    $('#info_h21').click(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h21 span').attr('style', 'display: block !important; position: absolute; top: -5.5em; left: 4em; width: 17em; height:12em; background-image:url("./img/publica/bg-tooltip1.gif"); background-repeat:no-repeat; color: #2A6285;padding: 1.2em;font-size: 1.1em;text-align:left;');
    });

    $('#info_h21').mouseout(function() {
        $('#colIzq table .masInfo p.infooscuro a.info_h21 span').attr('style', 'display: none;');
    });
});
*/




//funciones que estaban en validations.js
function trim(strIn) {
    blnBeginning = true;
    blnInSpace = false;
    strOut = "";
    strSpace = "";

    for (iPos = 0; iPos < strIn.length; iPos++) {
        chr = strIn.charAt(iPos);

        if (chr == ' ' || chr == '\t' || chr == '\n') {
            if (!blnBeginning) {
                blnInSpace = true;
                strSpace += chr;
            }
        }
        else {
            if (blnBeginning) {
                blnBeginning = false;
            }
            else if (blnInSpace) {
                blnInSpace = false;
                strOut += strSpace;
                strSpace = "";
            }

            strOut += chr;
        }
    }

    return strOut;
}


function checkTextNotEmpty(strIn) {
    strTrimmed = trim(strIn);

    if (strTrimmed.length == 0) {
        return false;
    }
    else {
        return true;
    }
}


function checkNumber(strIn) {
    //@FG-01/10/2001 - begin
    //	var intValue = parseInt(strIn);
    //	return !(isNaN(intValue));
    //@FG-01/10/2001 - end
    return !(isNaN(strIn));
}

function checkNumberPositive(strIn) {
    var intValue = parseInt(strIn);
    if (checkNumber(intValue)) {
        return (intValue >= 0);
    }
    else {
        return false;
    }
}


function checkNIF(strNIF) {
    var nif, temp, number, letter, position;
    var character = "TRWAGMYFPDXBNJZSQVHLCKE";

    if (trim(strNIF).length < 4 || trim(strNIF).length > 9) {
        return false;
    }
    firstLetter = trim(strNIF).substring(0, 1).toUpperCase();
    if (firstLetter == "K" || firstLetter == "L" || firstLetter == "M")
        return checkNIF(trim(strNIF).substring(1, trim(strNIF).length));

    nif = trim(strNIF).toUpperCase();
    temp = trim(nif).substring(0, 1);
    //Se eliminan los ceros de la izda.
    if (temp == "0") {
        while (temp == "0") {
            nif = trim(nif).substring(1, trim(nif).length);
            temp = trim(nif).substring(0, 1);
        }
    }
    if (trim(nif).length < 4 || trim(nif).length > 9) {
        return false;
    }

    number = trim(nif).substring(0, trim(nif).length - 1);
    if (!checkNumber(number))
        return false;

    letter = trim(nif).substring(trim(nif).length - 1, trim(nif).length);
    if (!IsAlphaAnd(letter, false, ""))
        return false;

    position = number % 23;
    if (letter != character.substring(position, position + 1))
        return false;

    return true;

}

function checkNIE(strNIE) {
    var firstLetter, nif;

    firstLetter = trim(strNIE).substring(0, 1).toUpperCase();
    if (firstLetter != "X" && firstLetter != "Y" && firstLetter != "Z")
        return false;

    nif = trim(strNIE).substring(1, trim(strNIE).length);
    while (nif.length < 8)
        nif = "0" + nif;
    if (firstLetter == "Y")
        return checkNIF('1' + nif); ;
    if (firstLetter == "Z")
        return checkNIF('2' + nif); ;

    return checkNIF(nif);
}

function checkCIF(strCIF) {
    var number, firstLetter;
    var character = "ABCDEFGHPQSRJUVWT";

    firstLetter = trim(strCIF).substring(0, 1).toUpperCase();
    if (character.indexOf(firstLetter) == -1)
        return false;

    number = trim(strCIF).substring(1).toUpperCase();
    if (trim(number).length <= 8 && trim(number).length > 1 && checkNumber(trim(number)))
        return true;

    return false;
}

function checkBankCode(strBankCode) {
    if (checkNumber(trim(strBankCode)) && trim(strBankCode).length == 4)
        return true;

    return false;
}

function checkOfficeCode(strOfficeCode) {
    if (checkNumber(trim(strOfficeCode)) && trim(strOfficeCode).length == 4)
        return true;

    return false;
}

function checkControlDigit(strControlDigit) {
    if (checkNumber(trim(strControlDigit)) && trim(strControlDigit).length == 2)
        return true;

    return false;
}

function checkAccountNumber(strAccountNumber) {
    if (checkNumber(trim(strAccountNumber)) && trim(strAccountNumber).length == 10)
        return true;

    return false;
}

function isValidAccount(bankCode, officeCode, controlDigit, accountNumber) {
    if (!checkBankCode(bankCode) || !checkOfficeCode(officeCode) || !checkControlDigit(controlDigit) || !checkAccountNumber(accountNumber))
        return false;
    if (controlDigit == calculateControlDigit(bankCode + officeCode, accountNumber))
        return true;
    return false;
}

function calculateControlDigit(bank, account) {
    pesos = new Array(6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
    var result = "";
    var i = 0;

    for (var j = 0; j <= 7; j++) {
        i = i + bank.substr(7 - j, 1) * pesos[j];
    }

    result = 11 - i % 11;
    if (result > 9) {
        result = 1 - result % 10;
    }

    i = 0;
    for (var j = 0; j <= 9; j++) {
        i = i + account.substr(9 - j, 1) * pesos[j];
    }

    i = 11 - (i % 11);
    if (i > 9) {
        i = 1 - (i % 10);
    }

    result = result * 10 + i;

    return result;
}


function IsAlphaAnd(chaine, numeric, specialChars, blank) {
    var i = 0;
    var validate = true;

    var character_authorized = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÑñ";

    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! arreglar !!!!!!!!!!!!!!!!!!!!
    // Error en ejecución ??
    // character_authorized += "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞøßàáâãäåæçèéêëìíîïðñòóôõöùúûüýþ";

    character_authorized += specialChars;

    if (blank)
        character_authorized += " ";

    if (numeric)
        character_authorized += "0123456789";

    chaine = trim(chaine);

    if (chaine.length != 0) {
        while (validate && (i <= (chaine.length - 1))) {
            if (character_authorized.indexOf(chaine.charAt(i)) == -1) {
                validate = false;
            }
            i = i + 1;
        }
    }
    else {
        validate = false;
    }

    return validate;
}

function containNumeric(chaine) {
    var i = 0;
    var contain = false;
    var character_NoAuthorized = "0123456789";

    if (chaine.length != 0) {
        while (!contain && (i <= (chaine.length - 1))) {
            if (character_NoAuthorized.indexOf(chaine.charAt(i)) > -1) {
                contain = true;
            }
            i = i + 1;
        }
    }
    else {
        contain = false;
    }

    return contain;
}
//end funciones de validations.js


function validateCaracterSpecial(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (!IsAlphaAnd(arg.Value, true, "_-@.", false) || (arg.Value == "")) {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
    else {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true;
    }
}

function validateCaracterYNumeros(src, arg) {

    var chkControlId = src.id.replace("Validator_", "");

    if (!IsAlphaAnd(arg.Value, true, '', true) || (arg.Value == "")) {
        error('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId);
        arg.IsValid = false;
    }
    else {
        ok('ok_' + chkControlId, chkControlId + '_cont', 'error_' + chkControlId, 1);
        arg.IsValid = true;
    }
}


