﻿//=====================voosSelecionados=============================================
//
// LayoutGeral (LayoutGeral.js)
// Criado por: Danilo Araujo
// Info: Classe LayoutGeral que contém os métodos principais
//       para montagem do layout
//
//==================================================================

Aereo.LayoutGeral = 
{
    isMasterPricer: null,

    //Inicializa o template Geral com suas Divs
    init: function(isMasterPricer)
    {
        Aereo.LayoutGeral.isMasterPricer = isMasterPricer;
        tpl.geral.idResultadoVoo = 'divResultadoVoo';
        tpl.geral.idFiltro = 'divFiltro';
        tpl.geral.idMelhorPreco = 'divMelhorPreco';
        tpl.geral.idVoosSelecionados = 'tblResultadoBusca';
        if (isMasterPricer) {
            tpl.geral.Cabecalho = tpl.MasterPricer.topMenuCabecalho.getHtml();
            tpl.geral.voosSelecionados = tpl.MasterPricer.voosSelecionados.getHtml();
            tpl.geral.LimparFiltros = 'javascript:Aereo.FiltroMasterPricer.ExibirTodosVoos()';
            tpl.geral.LinkVoosEscolhidos = 'javascript:Aereo.MasterPricer.exibeSelecionados()';
        } else {
            tpl.geral.Cabecalho = tpl.Disponibilidade.topMenuCabecalho.getHtml();
            tpl.geral.voosSelecionados = tpl.Disponibilidade.voosSelecionados.getHtml();
            tpl.geral.LimparFiltros = 'javascript:Aereo.FiltroVoo.exibirTodosVoos()';
            tpl.geral.LinkVoosEscolhidos = 'javascript:Aereo.Disponibilidade.exibeSelecionados()';
        }
    },
    
    ParseResultadoVoo: function()
    {
        Aereo.Disponibilidade.getDisponibilidade();
        
    },
    
    ParseMasterPricer: function()
    {
        Aereo.MasterPricer.getMasterPricer();
    },
    
    ParseFiltro:function()
    {
        Aereo.FiltroVoo.init();
    },
    
    MelhorPrecoPagAtual:1,
    
    ParseMelhoresPrecos: function(naoMudarPagina)
    {
        //debugger;
        
        if(!naoMudarPagina)
        {
            Aereo.LayoutGeral.MelhorPrecoPagAtual = (Aereo.LayoutGeral.MelhorPrecoPagAtual == 2 ? 1 : 2);
        }
        //invertendo a página
        
        if(Aereo.LayoutGeral.isMasterPricer)
            $(tpl.geral.idMelhorPreco).innerHTML = montaMelhorPrecoReduzidaMasterPricer
                                                            (Aereo.LayoutGeral.MelhorPrecoPagAtual);
        else
            $(tpl.geral.idMelhorPreco).innerHTML = montaMelhorPrecoReduzida(
                                                        tpl.Disponibilidade.MelhorPreco,
                                                        (Aereo.Disponibilidade.Modo-1),
                                                        Aereo.LayoutGeral.MelhorPrecoPagAtual);
    }
};
