﻿/**
* @projectDescription MySabre Plus Brazil Suite
* @author Rafael Melo
* @email Rafael.Melo@Sabre.com
* @date 20090203
* @class MainControl
* @version 1.6.2
*/

function MainControl(){
	
	var t = new Template('scrs'),
		collections = {},
		codEmpresa = 0,
		nomeEmpresa = '',
		htm = new StringBuilder(),
		scope = {},
		history = new History(),
		codPed = 0,
		locVtp = '',
		availGDS = null,
		histPedidos = [],
		btnArea1 = {};
    
	var setPodMenuControls = function(idxHistPeds){
		podMenuControl.menu3.f3_default().idx = idxHistPeds;
		podMenuControl.menu3.f3_default().action = function(){
			if (isLogged()) {
				if (!histPedidos[podMenuControl.menu3.f3_default().idx].isRetrieved) {
					histPedidos[podMenuControl.menu3.f3_default().idx].isRetrieved = true;
					$('alerterIcon').src = images.get['loading_compass'].loading.src;
					$('alerterMessage').innerHTML = 'O sistema está procurando por ' +
						'informações atualizadas para: ' + locVtp;
					$('alerter').style.display = 'block';
					_Base.DoRetrieve(locVtp);
				};
				$('alerter').style.display = 'none';
				history.reg('scr=aereoRtrvIssue&codPed=' + codPed);
			}
			else {
				endEnv();
			};
		};
		podMenuControl.menu3.f3_default().refreshAction();
		
		podMenuControl.menu3.f4_default().action = function(){
			if (isLogged()) {
				history.reg('scr=hotelRtrv&codPed=' + codPed);
			}
			else{ 
				endEnv();
			};
		};
		podMenuControl.menu3.f4_default().refreshAction();
		
		podMenuControl.menu3.f11_default().action = function(){
			if (isLogged()) {
				history.reg('scr=mainHistorico&codPed=' + codPed);
			}
			else {
				endEnv();
			};
		};
		podMenuControl.menu3.f11_default().refreshAction();
	};

	var getEmpresasAtivas = function(){
	    codEmpresa = _Base.getCodEmpresa().value;
	    availGDS = _Base.getGDSList();
	    _Base.setCodEmpresa(codEmpresa);
	};
	
    var renderFilasPedidos = function(res){
        if (!res.value.tables.ERRO) {
            // Para Análise de Risco
            htm.clear();
            t.tables.tbl_fila_head_0.wdtC1 = 35;
            t.tables.tbl_fila_head_0.wdtC2 = 65;
            t.tables.tbl_fila_head_0.ttl1 = 'LOCVTP';
            t.tables.tbl_fila_head_0.ttl2 = 'Data Entrada';
            htm.append(t.tables.tbl_fila_head_0.getHtml());
            $('qtdPAR').innerHTML = res.value.tables.ParaAnaliseRisco.rows.length.toString();
            for (var i = 0; i < res.value.tables.ParaAnaliseRisco.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = 'mainControl.getPedido(' + res.value.tables.ParaAnaliseRisco.rows[i].CodPedido + ')';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.ParaAnaliseRisco.rows[i].LOCVTP;
                t.tables.tbl_cs2_cont.item2 = res.value.tables.ParaAnaliseRisco.rows[i].DataEntrada.toString('dd/MM/yy HH:mm:ss');
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('para_analise_risco').innerHTML = htm.toString();
            
            // Em Análise de Risco
            htm.clear();
            htm.append(t.tables.tbl_fila_head_0.getHtml());
            $('qtdEAR').innerHTML = res.value.tables.EmAnaliseRisco.rows.length.toString();
            for (var i = 0; i < res.value.tables.EmAnaliseRisco.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = 'mainControl.getPedido(' + res.value.tables.EmAnaliseRisco.rows[i].CodPedido + ')';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.EmAnaliseRisco.rows[i].LOCVTP;
                t.tables.tbl_cs2_cont.item2 = res.value.tables.EmAnaliseRisco.rows[i].DataEntrada.toString('dd/MM/yy HH:mm:ss');
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('em_analise_risco').innerHTML = htm.toString();
            
            // Retorno Análise de Risco
            htm.clear();
            htm.append(t.tables.tbl_fila_head_0.getHtml());
            $('qtdRAR').innerHTML = res.value.tables.RetornoAnaliseRisco.rows.length.toString();
            for (var i = 0; i < res.value.tables.RetornoAnaliseRisco.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = 'mainControl.getPedido(' + res.value.tables.RetornoAnaliseRisco.rows[i].CodPedido + ')';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.RetornoAnaliseRisco.rows[i].LOCVTP;
                t.tables.tbl_cs2_cont.item2 = res.value.tables.RetornoAnaliseRisco.rows[i].DataEntrada.toString('dd/MM/yy HH:mm:ss');
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('retorno_analise_risco').innerHTML = htm.toString();
            
            // Para Emissão Bilhetes
            htm.clear();
            htm.append(t.tables.tbl_fila_head_0.getHtml());
            $('qtdPEB').innerHTML = res.value.tables.UltimasReservas.rows.length.toString();
            for (var i = 0; i < res.value.tables.UltimasReservas.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = 'mainControl.getPedido(' + res.value.tables.UltimasReservas.rows[i].CodPedido + ')';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.UltimasReservas.rows[i].LOCVTP;
                t.tables.tbl_cs2_cont.item2 = res.value.tables.UltimasReservas.rows[i].DataEntrada.toString('dd/MM/yy HH:mm:ss');
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('para_emissao_aereo').innerHTML = htm.toString();
            
            // Bilhetes Emitidos
            htm.clear();
            t.tables.tbl_fila_head_1.wdtC1 = 25;
            t.tables.tbl_fila_head_1.wdtC2 = 65;
            t.tables.tbl_fila_head_1.wdtC3 = 10;
            t.tables.tbl_fila_head_1.ttl1 = 'LOCVTP';
            t.tables.tbl_fila_head_1.ttl2 = 'Data Entrada';
            t.tables.tbl_fila_head_1.ttl3 = 'Emit';
            htm.append(t.tables.tbl_fila_head_1.getHtml());
            $('qtdBE').innerHTML = res.value.tables.BilhetesEmitidos.rows.length.toString();
            for (var i = 0; i < res.value.tables.BilhetesEmitidos.rows.length; i++) {
                t.tables.tbl_cs3_cont.cmd = 'mainControl.getPedido(' + res.value.tables.BilhetesEmitidos.rows[i].CodPedido + ')';
                t.tables.tbl_cs3_cont.item1 = res.value.tables.BilhetesEmitidos.rows[i].LOCVTP;
                if (res.value.tables.BilhetesEmitidos.rows[i].DataSaida) {
					t.tables.tbl_cs3_cont.item2 = res.value.tables.BilhetesEmitidos.rows[i].DataSaida.toString('dd/MM/yy HH:mm:ss');
				};
                t.tables.tbl_cs3_cont.item3 = String.format('{0}/{1}', res.value.tables.BilhetesEmitidos.rows[i].Emitido, res.value.tables.BilhetesEmitidos.rows[i].TotalBilhetes);
                htm.append(t.tables.tbl_cs3_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('bilhetes_emitidos').innerHTML = htm.toString();
            
            // Erro Emissão Bilhetes
            htm.clear();
            t.tables.tbl_fila_head_1.ttl3 = 'Tkts';
            htm.append(t.tables.tbl_fila_head_1.getHtml());
            $('qtdEEB').innerHTML = res.value.tables.ErroEmissaoBilhetes.rows.length.toString();
            for (var i = 0; i < res.value.tables.ErroEmissaoBilhetes.rows.length; i++) {
                t.tables.tbl_cs3_cont.cmd = 'mainControl.getPedido(' + res.value.tables.ErroEmissaoBilhetes.rows[i].CodPedido + ')';
                t.tables.tbl_cs3_cont.item1 = res.value.tables.ErroEmissaoBilhetes.rows[i].LOCVTP;
                if (res.value.tables.ErroEmissaoBilhetes.rows[i].DataSaida) {
					t.tables.tbl_cs3_cont.item2 = res.value.tables.ErroEmissaoBilhetes.rows[i].DataSaida.toString('dd/MM/yy HH:mm:ss');
				};
                t.tables.tbl_cs3_cont.item3 = res.value.tables.ErroEmissaoBilhetes.rows[i].TotalBilhetes;
                htm.append(t.tables.tbl_cs3_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            $('erro_emissao_aereo').innerHTML = htm.toString();
            if (res.params[0]) {
				alert('Filas Atualizadas.');
			};
        };
  	};
    
    var getPedido = function(res){
        if (!res.value.tables.ERRO) {
            locVtp = res.value.tables.Geral.rows[0].LOCVTP;
            codPed = res.value.tables.Geral.rows[0].CodPedido;
            histPedidos.push(res);
            histPedidos[histPedidos.length - 1].isRetrieved = false;
            /*-------------------------------------------------------------------------------------------*/
            //podMenuControl.menu3.setMainTitle(locVtp);
            /*-------------------------------------------------------------------------------------------*/
            podMenuControl.showMenu.pedido();
            //podMenuControl.back();
            populatePodMenu(res);
            // Inicializa as ações do PodMenu
            setPodMenuControls(histPedidos.length - 1);
            // Adiciona botão pedido
            btnArea1Control.addBtnPedido(locVtp, (histPedidos.length - 1));
            //if(res.params[0])
            //	podMenuControl.moveTo('aereo');
        
        };
    };
    
    var getPedHistorico = function(res){
        scope = new MainHistorico(res);
    };
    
    var getAereoReserva = function(){
        scope = new AereoReserva();
    };
    
    var getAereoRtrvIssue = function(res){
        scope = new AirRtrvIssue(res);
    };
    
    var getHoteisMain = function(){
        scope = new HoteisMain();
    };
    
    var getHotelRtrv = function(res){
        scope = new HotelRtrv(res);
    };
    
    var populatePodMenu = function(res){
        if (!res.value.tables.ERRO) {
            var ADT_CHD_INF;
            //
            podMenuControl.menu3.setMainTitle(res.value.tables.Geral.rows[0].LOCVTP);
            //Main: Dados Gerais
            htm.clear();
            t.tables.tbl_cs2_head.wdtC1 = 25;
            t.tables.tbl_cs2_head.wdtC2 = 75;
            t.tables.tbl_cs2_head.ttl1 = 'Tipo';
            t.tables.tbl_cs2_head.ttl2 = 'Empresa';
            htm.append(t.tables.tbl_cs2_head.getHtml());
            t.tables.tbl_cs2_cont.cmd = '';
            t.tables.tbl_cs2_cont.item1 = 'UNI';
            t.tables.tbl_cs2_cont.item2 = res.value.tables.Geral.rows[0].Unidade;
            htm.append(t.tables.tbl_cs2_cont.getHtml());
            t.tables.tbl_cs2_cont.item1 = 'AGE';
            t.tables.tbl_cs2_cont.item2 = res.value.tables.Geral.rows[0].Agencia;
            htm.append(t.tables.tbl_cs2_cont.getHtml());
            t.tables.tbl_cs2_cont.item1 = 'CLI';
            t.tables.tbl_cs2_cont.item2 = res.value.tables.Geral.rows[0].Cliente;
            htm.append(t.tables.tbl_cs2_cont.getHtml());
            htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f1_default().content.put(htm.toString());
            //Main: PAXs
            htm.clear();
            t.tables.tbl_cs2_head.wdtC1 = 75;
            t.tables.tbl_cs2_head.wdtC2 = 25;
            t.tables.tbl_cs2_head.ttl1 = 'Passageiro';
            t.tables.tbl_cs2_head.ttl2 = 'Categ.';
            htm.append(t.tables.tbl_cs2_head.getHtml());
            for (var i = 0; i < res.value.tables.PAX.rows.length; i++) {
                var cntObj, obj;
                ADT_CHD_INF = res.value.tables.PAX.rows[i].ADT_CHD_INF;
                switch (ADT_CHD_INF) {
                    case 0:
                        ADT_CHD_INF = 'ADT';
                        break;
                    case 1:
                        ADT_CHD_INF = 'CHD';
                        break;
                    case 2:
                        ADT_CHD_INF = 'INF';
                        break;
                };
                t.tables.tbl_cs2_cont.cmd = '';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.PAX.rows[i].PrimeiroNome + ' ' +
                res.value.tables.PAX.rows[i].Sobrenome;
                t.tables.tbl_cs2_cont.item2 = ADT_CHD_INF;
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f2_default().content.put(htm.toString());
            //Main: Aéreo
            htm.clear();
            t.tables.tbl_cs4_head.wdtC1 = 25;
            t.tables.tbl_cs4_head.wdtC2 = 25;
            t.tables.tbl_cs4_head.wdtC2 = 25;
            t.tables.tbl_cs4_head.wdtC2 = 25;
            t.tables.tbl_cs4_head.ttl1 = 'Ori.';
            t.tables.tbl_cs4_head.ttl2 = 'Des.';
            t.tables.tbl_cs4_head.ttl3 = 'Cia.';
            t.tables.tbl_cs4_head.ttl4 = 'Data';
            htm.append(t.tables.tbl_cs4_head.getHtml());
            for (var i = 0; i < res.value.tables.Aereo.rows.length; i++) {
                t.tables.tbl_cs4_cont.cmd = '';
                t.tables.tbl_cs4_cont.item1 = res.value.tables.Aereo.rows[i].IATAOrigem;
                t.tables.tbl_cs4_cont.item2 = res.value.tables.Aereo.rows[i].IATADestino;
                t.tables.tbl_cs4_cont.item3 = res.value.tables.Aereo.rows[i].Sigla;
                t.tables.tbl_cs4_cont.item4 = res.value.tables.Aereo.rows[i].DataSaida.toString('dd/MM');
                htm.append(t.tables.tbl_cs4_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f3_default().content.put(htm.toString());
            //Main: Hotéis
            htm.clear();
            for (var i = 0; i < res.value.tables.Hoteis.rows.length; i++) {
                //t.tables.tbl_cs2_cont.cmd = '';
                //t.tables.tbl_cs2_cont.item1 = 'FOO';//res.value.tables.AnaliseRisco.rows[i].DataTransacao.toString('dd/MM/yy<br />HH:mm:ss');
                //t.tables.tbl_cs2_cont.item2 = 'FOO2';//res.value.tables.AnaliseRisco.rows[i].Nome;
                //htm.append(t.tables.tbl_cs2_cont.getHtml());
                htm.append(res.value.tables.Hoteis.rows[i].hotelName + ((i > 0) ? '<br />' : ''));
            };
            //htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f4_default().content.put(htm.toString());
            //Main: Anti Fraude
            htm.clear();
            t.tables.tbl_cs2_head.wdtC1 = 25;
            t.tables.tbl_cs2_head.wdtC2 = 75;
            t.tables.tbl_cs2_head.ttl1 = 'Data';
            t.tables.tbl_cs2_head.ttl2 = 'Msg.';
            htm.append(t.tables.tbl_cs2_head.getHtml());
            for (var i = 0; i < res.value.tables.AnaliseRisco.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = '';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.AnaliseRisco.rows[i].DataTransacao.toString('dd/MM/yy<br />HH:mm:ss');
                t.tables.tbl_cs2_cont.item2 = res.value.tables.AnaliseRisco.rows[i].Nome;
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f8_default().content.put(htm.toString());
            //Main: Histórico
            htm.clear();
            t.tables.tbl_cs2_head.wdtC1 = 25;
            t.tables.tbl_cs2_head.wdtC2 = 75;
            t.tables.tbl_cs2_head.ttl1 = 'Data';
            t.tables.tbl_cs2_head.ttl2 = 'Msg.';
            htm.append(t.tables.tbl_cs2_head.getHtml());
            for (var i = 0; i < res.value.tables.Historico.rows.length; i++) {
                t.tables.tbl_cs2_cont.cmd = '';
                t.tables.tbl_cs2_cont.item1 = res.value.tables.Historico.rows[i].Data.toString('dd/MM/yy<br />HH:mm:ss');
                t.tables.tbl_cs2_cont.item2 = res.value.tables.Historico.rows[i].Nome;
                htm.append(t.tables.tbl_cs2_cont.getHtml());
            };
            htm.append(t.tables.tbl_foot.getHtml());
            podMenuControl.menu3.f11_default().content.put(htm.toString());
            //podMenuControl.menu3.f1_default().content.close();
            //podMenuControl.menu3.f2_default().content.close();
            //podMenuControl.menu3.f3_default().content.close();
            //podMenuControl.menu3.f4_default().content.close();
            podMenuControl.menu3.f5_default().content.close();
            podMenuControl.menu3.f6_default().content.close();
            podMenuControl.menu3.f7_default().content.close();
            podMenuControl.menu3.f8_default().content.close();
            podMenuControl.menu3.f9_default().content.close();
            podMenuControl.menu3.f10_default().content.close();
            podMenuControl.menu3.f11_default().content.close();
            podMenuControl.menu3.f12_default().content.close();
            podMenuControl.menu3.f13_default().content.close();
        };
    };
    
    var doRetrieve = function(res){
        $('alerterIcon').src = images.get['loading_compass'].loaded.src;
		if (res.value) {
            $('alerterMessage').innerHTML = 'Os dados foram atualizados com sucesso.';
        }
        else {
            $('alerterMessage').innerHTML = 'O prazo para este pedido expirou ou o mesmo foi cancelado.';
        };
        _Base.getPedido(codPed, populatePodMenu);
    };
    
    var logon = function(res){
        if (res.value) {
			history.reg('scr=principal');
		}
		else {
			alert('login errado');
		};
    };
    
    var logoff = function(res){
        if (res.value) {
			endEnv();
		};
    };
    
    var isLogged = function(){
        return _Base.isLogged().value;
    };
    
    var startEnv = function(){
    	// Atribui métodos para controle do tamanho do conteúdo principal
        _Base.getEmpresasAtivas(getEmpresasAtivas);
       /*
	    // Limpa o conteúdo e inicia a tela principal
        if ($('cont_up').firstChild) {
			$('cont_up').removeChild($('cont_up').firstChild);
		};*/
		//alert("asdf");
        $('cont_up').innerHTML = t.cnt_principal.getHtml();
    };
    
	var endEnv = function(){
        // Remove o Alerter
        $('alerter').style.display = 'none';
        
        // Remove o menu principal (podMenu)
        $('frame1').removeChild($('_frame_menu'));
        $('frame1').removeChild($('_frame_pedidos'));
        $('frame1').removeChild($('_frame_pedido'));
        
        // Remove botões da esquerda
		$('btn_menu').innerHTML = '';
		$('btn_pedidos').innerHTML = '';
        $('btn_pedido').innerHTML = '';
		
        // Remove o menu secundário
        $('menu').innerHTML = '';
        
        // Substitui conteúdo principal pela tela de login
        //$('cont_up').innerHTML = t.login.getHtml();
        $('contents').grow();
		$('area1').style.display = 'none';
        $('area2').style.width = '100%';
		
		//Limpa historico de pedidos visualizados
		histPedidos = [];
		
		//Destructors
		images = null;
		btnArea1Control = null;
		podMenuControl = null;
    };
	
    var doCRetrieve = function(res){
        if (res.value > 0) {
            _Base.getPedido(res.value, getPedido, [true]);
            podMenuControl.hideAll();
            history.reg('scr=aereoRtrvIssue&codPed=' + res.value);
        }
        else {
            alert('Retrieve inexistente para o escopo!');
        };
        $('ico_load_CRetrieve').removeChild(images.get['ico_load_m']);
    };
    
    var refreshFilas = function(b){
        var showAlert = b || false;
        if (isLogged()) {
			_Base.getFilasPedidos(codEmpresa, renderFilasPedidos, [showAlert]);
		}
		else {
			endEnv();
		};
    };
    
    this.closePedido = function(arrPos, objID){
        $('btn_pedido').removeChild($(objID));
        histPedidos[arrPos] = null;
    };
    
    this.logon = function(u, p){
        _Base.logon(u, p, logon);
    };
    
    this.logoff = function(){
        if (isLogged()) {
			_Base.logoff(logoff);
		}
		else {
			endEnv();
		};
    };
    
    this.getPedido = function(i){
        if (isLogged()) {
			_Base.getPedido(i, getPedido, [false]);
		}
		else {
			endEnv();
		};
    };
    
    this.resetContents = function(){
        $('cont_up').removeChild($('cont_up').firstChild);
        $('cont_up').innerHTML = t.cnt_principal.getHtml();
        var sel = $('sel_cust_retrieve');
        sel.onchange = function(){
            if (this.value != 'false') {
                $('lbl_loc_custom_retrieve').innerHTML = 'LOCCIA';
            }
            else {
                $('lbl_loc_custom_retrieve').innerHTML = 'LOCVTP';
            };
        };
        sel.options.length = 0;
        sel.options[0] = new Option(nomeEmpresa, 'false', false, true);
        for (var i = 0; i < availGDS.value.tables.Table.rows.length; i++) {
            var opt = document.createElement('option');
            opt.value = availGDS.value.tables.Table.rows[i].Nome;
            opt.innerHTML = opt.value;
            sel.appendChild(opt);
        };
        $('txt_cust_retrieve').onkeyup = function(){
            this.value = this.value.toUpperCase();
        };
        _Base.getFilasPedidos(codEmpresa, renderFilasPedidos, [false]);
    };
    
    this.refreshFilasPedidos = function(){
        refreshFilas(true);
    };
    
	this.refreshMenuPedido = function(){
		_Base.getPedido(codPed, populatePodMenu);
	};
	
    this.manualRetrieve = function(){
        $('alerterIcon').src = images.get['loading_compass'].loading.src;
        $('alerterMessage').innerHTML = 'O sistema está procurando por ' +
	        'informações atualizadas para: ' +
	        	locVtp;
        $('alerter').style.display = 'block';
        _Base.DoRetrieve(locVtp, doRetrieve);
    };
    
    this.goTo = {
        principal: function(){
            startEnv();
        },
        main: {
            historico: function(codPed){
                _Base.getPedHistorico(codPed, getPedHistorico);
            }
        },
        aereo: {
            reserva: function(codPed){
                getAereoReserva();
            },
            reservaBlank: function(){
                getAereoReserva();
            },
            rtrvIssue: function(codPed){
                _Base.getAereoRtrvIssue(codPed, getAereoRtrvIssue);
            }
        },
        hoteis: {
            main: function(){
                getHoteisMain();
            },
            rtrv: function(codPed){
                getHotelRtrv(codPed);
            }
        }
    };
    
    this.populatePedidoMenu = function(i){
        codPed = histPedidos[i].value.tables.Geral.rows[0].CodPedido;
        locVtp = histPedidos[i].value.tables.Geral.rows[0].LOCVTP;
        populatePodMenu(histPedidos[i]);
        setPodMenuControls(i);
    };
    
    this.doCustomRetrieve = function(){
        if ($('txt_cust_retrieve').value == '') {
            alert('Digite o LOC!');
        }else {
            if ($('sel_cust_retrieve').value == 'false') {
                $('ico_load_CRetrieve').appendChild(images.get['ico_load_m']);
                _Base.DoC1Retrieve($('txt_cust_retrieve').value, codEmpresa, doCRetrieve);
            }else {
                $('ico_load_CRetrieve').appendChild(images.get['ico_load_m']);
                _Base.DoC2Retrieve($('txt_cust_retrieve').value, $('sel_cust_retrieve').value, codEmpresa, doCRetrieve);
            };
    	};
    };
	
	this.history = function(){
        return history;
    };
	
	this.getCodEmpresa = function(){
        return codEmpresa;
    };
    
    this.getPedCod = function(){
        return codPed;
    };
    
    this.getLocVTP = function(){
        return locVtp;
    };
    
    this.scope = function(){
        return scope;
    };
    
    this.tpl = function(){
        return t;
    };
    
    this.tester = function(){
        //mainControl.scope().tarifada().buildReserva();
        getAereoReserva().tarifada().buildReserva();
    };
    
    this.constructor = new function(){
    	// PUBLIC GLOBALS
        var images;
		var btnArea1Control;
        var podMenuControl;
		var msgLayer = new MsgLayer({template: new Template('scrs').msg});
        
        if(isLogged()) {
			startEnv();
		}else {
			startEnv();
		};
    };
};

