﻿var postBackElement; // Going to capture the postback control that triggred the update panel

var chMsg01 = '<span><b>Clique num banco para mais detalhes.</b></span><br><br><span class="red">' +
              '*</span> O n&uacute;mero de bancos apresentado na p&aacute;gina de resultados, pode' +
              'variar em fun&ccedil;&atilde;o dos dados introduzidos.<br /><span class="red">**</span>' +
              ' Despesas de processo.<br /><span class="red">***</span> N&atilde;o inclui pr&eacute;mios' + 
              ' de seguros normalmente associados ao cr&eacute;dito habita&ccedil;&atilde;o.';
var chMsg02 = '<span>Clique aqui para fazer uma nova simulação.</span>';  

// Handles the pageload event after the updatepanel post
function pageLoad() {
    var manager = Sys.WebForms.PageRequestManager.getInstance();
    manager.add_beginRequest(beginRequest);

    deployAnchor();
}

// Handles the begin request event of the updatepanel post
function beginRequest(sender, args) {
    postBackElement = args.get_postBackElement();
}

// Handles the anchor href to show the detail area
function gotoDetailsAnchor() {
    if (postBackElement != null && !postBackElement.id.endsWith("grid")) {
        if (location.href.indexOf("#") != -1) {
            location.href = location.href;
        }
        else {
            location.href = location.href + '#ch_detail';
        }
    }
}

// Handles the anchor deployment first time the page is loaded
function deployAnchor() { }

// Handles the round cornering of the divs inside the update panel
function round() {
    var _ch_RoundCorners = Rico.Corner.round.bind(Rico.Corner);

    _ch_RoundCorners('div_ch_result_02', { corners: "all", bgColor: '#F5F5F5' });
    _ch_RoundCorners('div_ch_result_03', { corners: "all", bgColor: '#F5F5F5' });
    _ch_RoundCorners('div_ch_result_04', { corners: "all", bgColor: '#F5F5F5' });
}

// Handles the round cornering of the fixesd areas
function roundNewCalculation() {
    var _ch_RoundCorners = Rico.Corner.round.bind(Rico.Corner);

    _ch_RoundCorners('div_ch_result_01', { corners: "all", bgColor: '#FFFFFF' });
    _ch_RoundCorners('div_ch_newcalculation_01', { corners: "all", bgColor: '#F5F5F5' });
    _ch_RoundCorners('div_ch_result_05', { corners: "all", bgColor: '#F5F5F5' });
}
