/**
 * @author tony.tak
 */
$(function(){

    // Funcoes de alinhamento
    function alinha(elemento){
        this.getMetodos = function(){
            var metodos = [];
            if (window.innerHeight <= 0 || isNaN(window.innerHeight)) {
                metodos.push(function(){
                    return document.body.clientWidth;
                }, function(){
                    return document.body.clientHeight;
                });
            }
            else {
                metodos.push(function(){
                    return window.innerWidth;
                }, function(){
                    return window.innerHeight;
                });
            }
            return metodos;
        };
        this.metodos = this.getMetodos();
        //this.width = this.metodos[0];
        this.height = this.metodos[1];
        this.bodyInterno = $(elemento);
        this.setPaddingTop = function(){
            if ((this.metodos[1]() - 660) / 2 < 20) {
                this.bodyInterno.css('paddingTop', 20);            
            }
            else {
                this.bodyInterno.css('paddingTop', (this.metodos[1]() - 660) / 2);
            }
        };
    }
    
    var alinhamento = new alinha('#bodyPrincipal');
    alinhamento.setPaddingTop();
    
    // Utiliza o evento onResize para alinhar verticalmente novamente.
    $(window).resize(function(){
        alinhamento.setPaddingTop();
    });
});

