﻿
//Drop api tipo docs (pasaporte)
function TipoDocAPIPasaporte(source,args)
{
    var TipoDocumento, Validator;
    var Valido, i;
    var Url = '';
    var Urlaux;
    
    Urlaux = source.id.split('_');
    
    for (i = 0; i < Urlaux.length - 1; i++)
    {
        Url += Urlaux[i] + '_';
    }

    if (source.tagName == 'SELECT')
    {
        TipoDocumento = source;
        
        Validator = $get(Url + 'RequiredTDoc1');
    }
 
    else
    {
        TipoDocumento = $get(Url + 'dropTipoDocumento1');
       
        Validator = source;
    }
    
    
        Valido = ComprobarDocumento2(TipoDocumento);
    
    
    if (args != null)
    {
        args.IsValid = Valido;        
    }
    else
    {
        Validator.isvalid = Valido;
    }
    
    if (Valido)
    {
        Validator.style.visibility = 'hidden';
    }
    else
    {
        Validator.style.visibility = 'visible';    
    }
        
    return;
}

function ComprobarDocumento2(TipoDocumento)
{
    if (TipoDocumento.value == 'I')
    {
        return true;
    }
    else
    {
      return false; 
    }
}
 //Fin Drop api tipo docs (pasaporte)   

//Drop api tipo docs (Genero)
function TipoDocAPIGenero(source,args)
{
var TipoDocumento, Validator;
    var Valido, i;
    var Url = '';
    var Urlaux;
    
    Urlaux = source.id.split('_');
    
    for (i = 0; i < Urlaux.length - 1; i++)
    {
        Url += Urlaux[i] + '_';
    }

    if (source.tagName == 'SELECT')
    {
        TipoDocumento = source;
        
        Validator = $get(Url + 'RequiredTDoc2');
    }
  
    else
    {
        TipoDocumento = $get(Url + 'dropGenero');
       
        Validator = source;
    }
    
    
        Valido = ComprobarDocumento3(TipoDocumento);
    
    
    if (args != null)
    {
        args.IsValid = Valido;        
    }
    else
    {
        Validator.isvalid = Valido;
    }
    
    if (Valido)
    {
        Validator.style.visibility = 'hidden';
    }
    else
    {
        Validator.style.visibility = 'visible';    
    }
        
    return;
}

function ComprobarDocumento3(TipoDocumento)
{
switch (TipoDocumento.value)
{
    case 'F': 
       return true;
        break;
    case 'M':
        return true;
        break;
    case 'MI':
     return true;
        break;
    case 'FI':
        return true;
        break;
    default:
        return false;
        break;
} 
}
 //Fin Drop api tipo docs (Genero)   

//Drop api tipo doco (visado)
function TipoDocAPIVisado(source,args)
{
var TipoDocumento, Validator;
    var Valido, i;
    var Url = '';
    var Urlaux;
    
    Urlaux = source.id.split('_');
    
    for (i = 0; i < Urlaux.length - 1; i++)
    {
        Url += Urlaux[i] + '_';
    }

    if (source.tagName == 'SELECT')
    {
        TipoDocumento = source;
        
        Validator = $get(Url + 'RequiredTDoc3');
    }
  
    else
    {
        TipoDocumento = $get(Url + 'dropDocumentoDoco');
       
        Validator = source;
    }
    
    
        Valido = ComprobarDocumento4(TipoDocumento);
    
    
    if (args != null)
    {
        args.IsValid = Valido;        
    }
    else
    {
        Validator.isvalid = Valido;
    }
    
    if (Valido)
    {
        Validator.style.visibility = 'hidden';
    }
    else
    {
        Validator.style.visibility = 'visible';    
    }
        
    return;
}

function ComprobarDocumento4(TipoDocumento)
{
   
   if (TipoDocumento.value=='V'){
   return true;
   }
   else{
   return false;
   }
}

 //Fin Drop api tipo doco(visado)  
 
 //Drop api tipo doca (Direccion)
function TipoDocAPIDireccion(source,args)
{
var TipoDocumento, Validator;
    var Valido, i;
    var Url = '';
    var Urlaux;
    
    Urlaux = source.id.split('_');
    
    for (i = 0; i < Urlaux.length - 1; i++)
    {
        Url += Urlaux[i] + '_';
    }

    if (source.tagName == 'SELECT')
    {
        TipoDocumento = source;
        
        Validator = $get(Url + 'RequiredTDoc5');
    }
  
    else
    {
        TipoDocumento = $get(Url + 'dropDireccion');
       
        Validator = source;
    }
    
    
        Valido = ComprobarDocumento5(TipoDocumento);
    
    
    if (args != null)
    {
        args.IsValid = Valido;        
    }
    else
    {
        Validator.isvalid = Valido;
    }
    
    if (Valido)
    {
        Validator.style.visibility = 'hidden';
    }
    else
    {
        Validator.style.visibility = 'visible';    
    }
        
    return;
}


function ComprobarDocumento5(TipoDocumento)
{
   
switch (TipoDocumento.value)
{
    case 'D': 
       return true;
        break;
    case 'R':
        return true;
        break;
   
    default:
        return false;
        break;
}   
}
 //Fin Drop api tipo doca (Direccion)   
 
function ComprobarDocumento1(TipoDocumento)
{
    if (TipoDocumento.value == 'Pasaporte')
    {
        return true;
    }
    else
    {
      return false; 
    }   
}

function TipoDocumento(source, args)
{
    var TipoDocumento, Validator;
    var Valido, i;
    var Url = '';
    var Urlaux;
    
    Urlaux = source.id.split('_');
    
    for (i = 0; i < Urlaux.length - 1; i++)
    {
        Url += Urlaux[i] + '_';
    }

    if (source.tagName == 'SELECT')
    {
        TipoDocumento = source;
        
        Validator = $get(Url + 'RequiredTDoc');
    }
    else
    {
        TipoDocumento = $get(Url + 'dropTipoDocumento');
       
        Validator = source;
    }    
    
    Valido = ComprobarDocumento1(TipoDocumento);    
    
    if (args != null)
    {
        args.IsValid = Valido;        
    }
    else
    {
        Validator.isvalid = Valido;
    }
    
    if (Valido)
    {
        Validator.style.visibility = 'hidden';
    }
    else
    {
        Validator.style.visibility = 'visible';    
    }
        
    return;
}