/**
 * Barra de progresso utilizando
 * a módulo APC do PHP
 */
var progressTimer;
var progressBar = {
    iniciar: function (progressKey)
    {
        progressTimer = setInterval( function()
        {
            new Ajax.Request (
                'getProgress.php',
                {
                    method: 'post',
                    frequency: 3,
                    decay: 1,
                    parameters: 'progress_key=' + progressKey,
                    onSuccess: function(t)
                    {
                        $('progressInner').removeAttribute("style");
                        $('progressInner').setAttribute('style', 'width: ' + t.responseText, 0);
                        $('progressInner').update( t.responseText );

                        if ( t.responseText == '100%' )
                        {
                            $("progressInner").update( 'Completo!' );

                            clearInterval(progressTimer);
                        }
                    }
                });
        },
        2000);
    },

    verificaImportaContatoArquivo: function ()
    {
        if ( $F('txtArquivo') == '' )
        {
            return false;
        }
        else
        {
            // Chama a função de pré-loader do arquivo
            $("progressOuter").style.display = "block";

            progressBar.iniciar( $F('progress_key') );

            return true;
        }
    }
}