/**
*  The Footer Plugin
*  
* 	Copyright 2010 Icewares
*  
*  Licensed under the CPL (http://footer.icewares.com.br/licence.html)
*/
/**
* 	The Footer Plugin
* 
*  version 1.0.2
*  
*  Created by Stefano Stypulkowski
*   
*  Requires jQuery 1.4.x - www.jquery.com
*  
*  For instructions see:  http://footer.icewares.com.br 
*/
//(function ($) { Footer = { style: { absolute: { position: "absolute", bottom: 0 }, relative: { position: "relative", bottom: "auto"} }, configs: { timeOut: 200, zIndex: 200 }, browserAdjust: 0, height: 0, fHeight: 0, fId: 0, monitor: function () { if (Footer.height !== $(document).height()) { Footer.setPosition(); Footer.height = $(document).height(); } if (Footer.fHeight !== $(Footer.fId).height()) { Footer.setFsmHeight(); Footer.footerHeight = $(Footer.fId).height(); } setTimeout(function () { Footer.monitor(); }, Footer.configs.timeOut); }, setPosition: function () { if (($(document).height() - Footer.browserAdjust) > $(window).height()) { $("#footerSpaceManager").remove(); $(Footer.fId).css(Footer.style.relative); } else { if ($("#footerSpaceManager").size() == 0) { $(Footer.fId).parent().append("<div id='footerSpaceManager' style='height: " + $(Footer.fId).height() + "px;'></div>"); } $(Footer.fId).css(Footer.style.absolute); } }, setFsmHeight: function () { if ($("#footerSpaceManager").size() > 0 && $(Footer.fId).height() !== $("#footerSpaceManager").height()) { $("#footerSpaceManager").height($(Footer.fId).height()); } } }; $.fn.footer = function (options) { Footer.configs = $.extend(Footer.configs, options); if (Footer.configs.timeOut < 1) { Footer.configs.timeOut = 1; } if ($(this).attr("id") === "") { $(this).attr("id", "footerAutoGeneratedId"); } $(this).css("z-index", Footer.configs.zIndex); Footer.fId = "#" + $(this).attr("id"); Footer.height = $(document).height(); Footer.fHeight = $(this).height(); if ($.browser.msie) { Footer.browserAdjust = 4; } Footer.setPosition(); Footer.monitor(); }; })(jQuery);
/******************************************************
* jQuery plug-in
* Easy Pinned Footer
* Developed by J.P. Given (http://johnpatrickgiven.com)
* Useage: anyone so long as credit is left alone
******************************************************/
(function ($) {
    // plugin definition
    $.fn.pinFooter = function (options) {
        // Get the height of the footer and window + window width
        var wH = $(window).height();
        var wW = getWindowWidth();
        var fH = $(this).outerHeight(true);
        var bH = $("body").outerHeight(true);
        var mB = parseInt($("body").css("margin-bottom"));

        if (options == 'relative') {
            if (bH > getWindowHeight()) {
                $(this).css("position", "absolute");
                $(this).css("width", wW + "px");
                $(this).css("top", bH - fH + "px");
                $("body").css("overflow-x", "hidden");
            } else {
                $(this).css("position", "fixed");
                $(this).css("width", wW + "px");
                $(this).css("top", wH - fH + "px");
            }
        } else { // Pinned option
            // Set CSS attributes for positioning footer
            $(this).css("position", "fixed");
            $(this).css("width", wW + "px");
            $(this).css("top", wH - fH + "px");
            $("body").css("height", (bH + mB) + "px");
        }
    };

    // private function for debugging
    function debug($obj) {
        if (window.console && window.console.log) {
            window.console.log('Window Width: ' + $(window).width());
            window.console.log('Window Height: ' + $(window).height());
        }
    };

    // Dependable function to get Window Height
    function getWindowHeight() {
        var windowHeight = 0;
        if (typeof (window.innerHeight) == 'number') {
            windowHeight = window.innerHeight;
        }
        else {
            if (document.documentElement && document.documentElement.clientHeight) {
                windowHeight = document.documentElement.clientHeight;
            }
            else {
                if (document.body && document.body.clientHeight) {
                    windowHeight = document.body.clientHeight;
                }
            }
        }
        return windowHeight;
    };

    // Dependable function to get Window Width
    function getWindowWidth() {
        var windowWidth = 0;
        if (typeof (window.innerWidth) == 'number') {
            windowWidth = window.innerWidth;
        }
        else {
            if (document.documentElement && document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            }
            else {
                if (document.body && document.body.clientWidth) {
                    windowWidth = document.body.clientWidth;
                }
            }
        }
        return windowWidth;
    };
})(jQuery);
