﻿function Trim(str) { return str.replace(/^\s+|\s+$/g, ""); }

/*window.alert = function(sstring) {

    while (sstring.indexOf("\n") > 0) {
        sstring = sstring.replace("\n", "<br/><br/>");
    }

    window.radalert(sstring, 280, 120, "Alerta");
}*/


function refreshThisPage() {
    var parametro = "?refresh=1";
    if (location.href.indexOf("?", 0) > 0) {
        parametro = "&refresh=1";
    }
    location.href = location.href + parametro;
}

function refreshParentPage() {

    if (parent.location.href.indexOf("ReturnUrl", 0) > 0) {

        var indiceParametro = parent.location.href.indexOf("ReturnUrl", 0) + 10;
        var fimSub = parent.location.href.length - indiceParametro;
        parent.location.href = unescape(parent.location.href.substr(indiceParametro, fimSub));

    } else {

        var parametro = "?refresh=1";
        if (parent.location.href.indexOf("?", 0) > 0) {
            parametro = "&refresh=1";
        }
        parent.location.href = parent.location.href + parametro;

    }
}

function AbreCadastroRapido() {
    var pop = window.radopen('/Cadastro/CadastroRapidoPop.aspx?pag=' + escape(location.href), null);
    pop.Minimize = false;
    pop.setSize(535, 485);
    pop.SetModal(true);
    pop.center();
    //pop.add_close(OnClientClose);
}

function AbreEsqueciMinhaSenha() {
    var pop = window.radopen('/Cadastro/EsqueciMinhaSenha.aspx', null);
    pop.Minimize = false;
    pop.setSize(535, 425);
    pop.SetModal(true);
    pop.center();
}

function AbreAlterarFoto() {
    var pop = window.radopen('/Cadastro/AlterarFoto.aspx', null);
    pop.Minimize = false;
    pop.setSize(535, 425);
    pop.SetModal(true);
    pop.center();
}

function AbreAlterarSenha() {
    var pop = window.radopen('/Cadastro/AlterarSenha.aspx', null);
    pop.Minimize = false;
    pop.setSize(535, 425);
    pop.SetModal(true);
    pop.center();
}

function GraficoOpen(tipo) {
    var graficoPop = window.radopen('Grafico.aspx?tipo=' + tipo, null);
    graficoPop.setSize(700, 550);
    /*graficoPop.add_close(OnClientClose);*/
    graficoPop.SetModal(true);
    graficoPop.center();
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function CloseRadWindow() {
    GetRadWindow().close();
}

function CloseRadWindowAndRefresh() {
    var oCurrentWin = GetRadWindow();
    oCurrentWin.add_close(refreshParentPage);
    oCurrentWin.close();
}

function CloseRadWindowAndGoMinhaArea() {
    var oCurrentWin = GetRadWindow();
    oCurrentWin.add_close(goMinhaAreaParentPage);
    oCurrentWin.close();
}


function goHome() {
    location.href = '/';
}

function goMinhaArea() {
    location.href = '/MinhaArea.aspx';
}

function goMinhaAreaParentPage() {
    parent.location.href = '/MinhaArea.aspx';
}

function goControleFinanceiro() {
    location.href = '/controlefinanceiro/';
}

function goPreLancamento() {
    location.href = '/prelancamento/';
}

function goColabore() {
    location.href = '/colabore.aspx';
}

function AbreForumNovoTopico() {
    var pop = window.radopen('/forum/TopicoNovo.aspx', null);
    pop.Minimize = false;
    pop.setSize(535, 520);
    pop.SetModal(true);
    pop.center();
    //pop.add_close(OnClientClose);
}
function AbreForumRegras() {
    var pop = window.radopen('/forum/Regras.aspx', null);
    pop.Minimize = false;
    pop.setSize(620, 720);
    pop.SetModal(true);
    pop.center();
    //pop.add_close(OnClientClose);
}

