﻿//==================================================================
//
// INICIO (Inicio.js)
// Criado por: Danilo Araujo
// Alterado por: Roger da Silva Leite 10/10/2008
// Info: Métodos de inicialização da aplicação web
//
//==================================================================

var tpl;
var isNacOrInt;
var Aereo = {
    //Monta o html geral do site
    init : function(isMasterPricer)
    {
       //Carrega o template Geral
       tpl = new Template('Aereo');
       
       //alert(isMasterPricer);
      // setTimeout('Aereo.LayoutGeral.init(isMasterPricer);', 100);
       
       Aereo.LayoutGeral.init(isMasterPricer);

       //Verifica se e Disponibilidade ou MasterPrice
       isNacOrInt = isMasterPricer;
       //============================================

       if(isMasterPricer == true)
       {
            $('conteudoGeral').innerHTML = tpl.geralMasterPrice.getHtml();
       }
       else
       {
            ScreenProtector(false);
            $('conteudoGeral').innerHTML = tpl.geral.getHtml();
       };       

        //============================================================
        Aereo.LayoutGeral.ParseTopo();        
            
        Aereo.LayoutGeral.ParseRodape();
        //alert('tester');
        
        Aereo.startCarregando();
        
        if(isMasterPricer)
        {
            $('conteudoGeral').style.display = "block";
            setTimeout('Aereo.LayoutGeral.ParseMasterPricer()',80);
        }    
        else
        { 
            ScreenProtector(true);
            setTimeout('Aereo.LayoutGeral.ParseResultadoVoo()',1000);
        };
        var t1 = new Template("Aereo");
            
        // Monta o MainMenu
        $('divMainMenu').innerHTML = t1.MainMenu.externo.getHtml();
            
    },
    startCarregando: function()
    {
        //Esconde a div de Conteudo
        if(isNacOrInt == true)
        {
            $(tpl.geralMasterPrice.idConteudo).hide();
            $(tpl.geralMasterPrice.idLoadingInicio).show();
        }
        else
        {
            $(tpl.geral.idConteudo).hide();
            $(tpl.geral.idLoadingInicio).show();
        };

        //overlay();
    },
    stopCarregando: function()
    {
        //Esconde a div de Conteudo
        if(isNacOrInt == true)
        {
            $(tpl.geralMasterPrice.idConteudo).show();
            $(tpl.geralMasterPrice.idLoadingInicio).hide();
        }
        else
        {
            $(tpl.geral.idConteudo).show();
            $(tpl.geral.idLoadingInicio).hide();
        };

        //hideOverlay();
    },
    onResize: function(event)
    {
        var scrollXY = getScrollXY();
        if(document.documentElement.clientHeight)
        {            
            $(tpl.geral.idTextoLoading).style.height = (document.documentElement.clientHeight + scrollXY[1]) + "px";
            $(tpl.geral.idTrancaTela).style.height = (document.documentElement.clientHeight + scrollXY[1])  + "px";
            $(tpl.geral.idBoxLoading).style.marginTop = ((document.documentElement.clientHeight * 0.45 ) + scrollXY[1]) + "px"; 
        }
        else
        {
            $(tpl.geral.idTextoLoading).style.heigth = (document.body.clientHeight + scrollXY[1]) + "px";
            $(tpl.geral.idTrancaTela).style.heigth = (document.body.clientHeight + scrollXY[1]) + "px";
            $(tpl.geral.idBoxLoading).style.marginTop = ((document.body.clientHeight * 0.45 ) + scrollXY[1]) + "px";
        };
    }
};





