function validaForm(campo, tipo, nome)
{             
    for(var i = 0; i < campo.length; i++)
    {
        var tipos = tipo[i].split(',');
        
        var el = document.getElementById(''+campo[i]+'');
        if(tipos[0] == 'vazio')
        {
            if(el.value == "")
            {
                alert("Campo "+nome[i]+" nao pode ser vazio.");
                return false;
            }
        }
        
        if(tipos[1] == "numero")
        {
            er = "^\\d{0,}$";
            result = new RegExp(er);
            var pof = el.value;
            var retorno = pof.search(result);            
            if(retorno == -1)
            {
                alert("Campo "+nome[i]+" só aceita numeros.");
                return false;
            }    
        }       
    }    
      
    if(document.all)
    {
        document.fdados.submit();
    } 
    else
    {
        document.getElementById('fdados').submit();    
    }    
    return true;
}

function confirmaEnvioQuest()
{
    var answer = confirm(unescape("Antes de prosseguir certifique-se de que inseriu todas as informações sobre suas Matrizes e filiais.\nPara adicionar uma filial basta clicar no botão 'Adicionar Filial', ou uma Matriz clicando no botão 'Adicionar Matriz'.\nVocê deseja continuar?"));
    
	if (answer)
    {		
		document.getElementById('fdados').submit();
	}
}

function validaPagina3(inputs)
{
    for(var i = 0; i < inputs.length; i++)
    {
        var selecionado = false;
        radio = document.fdados[inputs[i]];                
        for(var x = 0; x < radio.length; x++)
        {            
            if(radio[x].checked == true)
            {                
                selecionado = true;                
            }            
        }
        
        if(!selecionado)
        {
            alert("Todos os campo são mandatórios.")
            return false;
        }
    }    
        
    var selecionado = false;
    for(var y = 0; y < document.fdados.base_emp.length; y++)
    {              
        if(document.fdados.base_emp[y].checked == true)
        {     
            selecionado = true;
        }        
    }    
           
    if(selecionado == false)
    {
        alert("Selecione pelo menos uma base de dados.")
        return false;
    }    
    
    if(document.all)
    {
        document.fdados.submit();
    } 
    else
    {
        document.getElementById('fdados').submit();    
    }    
    return true;
}

function validaPagina4(inputs)
{
    for(var i = 0; i < inputs.length; i++)
    {
        var selecionado = false;
        radio = document.fdados[inputs[i]];
        if(radio.name == "desc_sla")
        {
            if(radio.value == "")
            {
                alert("Descreva o SLA do suporte.");
                return false;
            }    
        }
        else
        {            
            for(var x = 0; x < radio.length; x++)
            {            
                if(radio[x].checked == true)
                {                
                    selecionado = true;                
                }            
            }
            
            if(!selecionado)
            {
                alert("Todos os campo são mandatórios."+radio.name);            
                return false;
            }    
        }          
    }
    
    selecionado = false;
    for(var y = 0; y < document.fdados.tp_pacote.length; y++)
    {              
        if(document.fdados.tp_pacote[y].checked == true)
        {     
            selecionado = true;
        }        
    }
    
    if(selecionado == false)
    {
        alert("Selecione pelo menos um módulo de interesse.")
        return false;
    }
       
    
    if(document.all)
    {
        document.fdados.submit();
    } 
    else
    {
        document.getElementById('fdados').submit();    
    }    
    return true;
}