// JavaScript Document
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='';

    // Este codigo se deja, que aunque es similar a la propiedad del validador SetFocusOnError="True",
    // No funciona en todos los casos
	if ((eFocus != null) && (eFocus != "nofocus")) {
	    // Establece Foco
	    if (document.getElementById(eFocus) != null)
	        document.getElementById(eFocus).focus();
	    else
	        if (document.getElementById(eContenedor.replace("_cont", "")) != null)
	        document.getElementById(eContenedor.replace("_cont", "")).focus();
	    else
	        document.getElementById(eContenedor).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_otros'), false);
    ok('ok_otros','otrosck_cont','error_otros');
}

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_otros'), false);
	ok('ok_otros','otrosck_cont','error_otros');
}

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;
		break;
		
		default:
		oCntrl.value = "?";
		oCntrl.disabled= false;
		document.getElementById('dia').value = 0;
		document.getElementById('mes').value = 0;
		document.getElementById('ano').value = 0;
		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','sinick_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','sinick_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() {

    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) {
			        error('ok_fecha', 'fecha_cont', 'error_fecha');
				} else {
				    ok('ok_fecha', 'fecha_cont', 'error_fecha');
				}
			} else {
			if (document.getElementById('VHExpirationPreviousPolicyDateMonth').value == 2 && document.getElementById('VHExpirationPreviousPolicyDateDay').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 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 validateradiootros(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+'ck_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) || (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 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; // avance pagina 
    }
    
}

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; // 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 validateTextNumeric( 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');
		for ( i = 0; i < tabla.rows.length; i++ )
		{
			if (tabla.rows[i].cells[1].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[0].style.backgroundColor = "";
			}
		}
		if(navigator.userAgent.indexOf("Firefox")!=-1){ i=1
		}else{i=0}
		obj.childNodes[i+1].style.backgroundColor="#AFAFAF";
		obj.childNodes[i+2].style.backgroundColor="#AFAFAF";
		obj.childNodes[i+3].style.backgroundColor="#AFAFAF";
		obj.childNodes[i].style.backgroundColor="#AFAFAF";
	};
}
/***********************************************************************/
/******************* Funciones para dato_seguro.aspx *******************/

function showAntecedentsOptions(tipo, habilitar) {

    if (tipo == "CarSecured") {
        document.getElementById('CarSecuredck_cont').style.display = "";
        ok('ok_CarSecured', 'CarSecuredck_cont', 'error_CarSecured');
    }
    else {
        document.getElementById('ExistPreviousContractck_cont').style.display = "";
        ok('ok_ExistPreviousContract', 'ExistPreviousContractck_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() {
    if (document.datos_frm.CompanyPreviousPolicy.value == '10730') {
        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;
    }
}

function ValidateTravel() {

    if (document.getElementById('numsocio').value == "") {
        error('ok_travel', 'travel_cont', 'error_travel');
        return;
    }
    
    if (!containNumeric(document.getElementById('numsocio').value)) {
        error('ok_travel', 'travel_cont', 'error_travel');
        return;
    }
    
    if (document.getElementById('numsocio2').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){
        if (document.getElementById('pago').value==1)
        {    document.getElementById('pago_tr').innerHTML='Semestral';
        }else{
            document.getElementById('pago_tr').innerHTML='Anual';
        }
        formapago=document.getElementById('pago').value
    }else{
         document.getElementById('pago_tr').innerHTML='Anual';
         formapago=0;
    }
    if (document.getElementById('cambio').value==4)
    {    document.getElementById('franq_tr').innerHTML=document.getElementById('sinfranq_desc').value;}
    if (document.getElementById('cambio').value==8)
    {    document.getElementById('franq_tr').innerHTML=document.getElementById('franqA_desc').value;}
    if (document.getElementById('cambio').value==7)
    {    document.getElementById('franq_tr').innerHTML=document.getElementById('franqB_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];}
}
function RecargaTA(){
    if (document.getElementById('pagoTA').value==1)
    {    document.getElementById('pago_ta').innerHTML='Semestral';
    }else{
        document.getElementById('pago_ta').innerHTML='Anual';
    }
    document.getElementById('precio_ta').innerHTML=prima[1][document.getElementById('pagoTA').value];
}

// 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();

    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 muestraTextoError(errorText)
{
    Footer1_TextoError.style.visibility = '';
    Footer1_lTextoError.innerText = errorText;

    Footer1_TextoError.style.position = 'absolute';
    Footer1_TextoError.style.width='200px';
    Footer1_TextoError.style.height='200px';
    Footer1_TextoError.style.top='50%';
    Footer1_TextoError.style.left='50%';
}
*/
