﻿

var footer = {



    initialized: false,



    init: function () {

        if (!this.initialized) {

            //                    this.header = document.getElementById("header");

            //                    this.container = document.getElementById("container");

            //                    this.footer = document.getElementById("footer");

            //this.minContainerHeight = this.container.clientHeight;

            this.principal = document.getElementById("principal");

            this.lateral = document.getElementById("lateral");

            this.conteudo = document.getElementById("conteudo");

            this.sliderPagp = document.getElementById("sliderPagp-wrapper");
            this.sliderConteudo = document.getElementById("sliderConteudo-wrapper");


            this.initialized = true;

        }

    },



    calc: function () {

        $("#" + this.lateral.id).css("height", "");
        $("#" + this.principal.id).css("height", "");
        $("#" + this.conteudo.id).css("height", "");

//        $("#" + this.lateral.id).css("height", 1235);
//        $("#" + this.conteudo.id).css("height", $("#" + this.conteudo.id).innerHeight());

        var slideHeight = 0;
        if (this.sliderPagp != null)
            slideHeight = slideHeight + $("#" + this.sliderPagp.id).height(); // this.sliderPagp.clientHeight;

        if (this.sliderConteudo != null)
            slideHeight = slideHeight + $("#" + this.sliderConteudo.id).height(); // this.sliderConteudo.clientHeight;

        //                var windowHeight = window.innerHeight || document.documentElement.clientHeight;

        //                var innerHeight = this.header.clientHeight + this.minContainerHeight + this.footer.clientHeight;



        //                var newHeight = windowHeight < innerHeight

        //							  ? this.minContainerHeight + ieDif

        //							  : windowHeight - (this.header.clientHeight + this.footer.clientHeight + 3);



        //                this.container.style["height"] = newHeight + "px";


        if (this.principal.clientHeight > this.lateral.clientHeight)
            $("#" + this.lateral.id).css("height", $("#" + this.principal.id).height() + "px"); //this.lateral.style["height"] = this.principal.clientHeight + "px";

        if (this.principal.clientHeight < this.lateral.clientHeight)
            $("#" + this.principal.id).css("height", $("#" + this.lateral.id).height() + "px"); // this.principal.style["height"] = this.lateral.clientHeight + "px";


        $("#" + this.conteudo.id).css("height", $("#" + this.lateral.id).height() - slideHeight - 120 + "px"); // this.conteudo.style["height"] = this.lateral.clientHeight - slideHeight - 120 + "px";
    }

};

Sys.Application.add_init(appl_init);

function appl_init() {
    var pgRegMgr = Sys.WebForms.PageRequestManager.getInstance();

    pgRegMgr.add_pageLoaded(function () {

        footer.init();
        footer.calc();

        window.onload = function (e) {

            footer.init();
            footer.calc();

        };



        window.onresize = function (e) {
            footer.calc();

        };
    });


}
