//----------------------------------------------------------
// Copyright (C) SysIQ Inc. All rights reserved.
// Author: Alexander Goldobin
//----------------------------------------------------------
// jquery.viewport.js
//
// Used information from: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

(function($) {

$.viewportScroll = function() {
    var win = $(window);
    if( win.attr("pageXOffset") !== undefined) {
        return {
            left: win.attr("pageXOffset"),
            top: win.attr("pageYOffset")
        };
    };

    var documentElement = $(document.documentElement);
    if( documentElement.size() > 0 && documentElement.attr("scrollLeft")  !== undefined) {
        return {
            left: documentElement.attr("scrollLeft"),
            top: documentElement.attr("scrollTop")
        };
    }

    return {
        left: 0,
        top: 0
    };
};

$.viewportDimensions = function() {
    var win = $(window);
    if( win.attr("innerWidth") !== undefined) {
        return {
            width: win.attr("innerWidth"),
            height: win.attr("innerHeight")
        };
    };

    var documentElement = $(document.documentElement);
    if( documentElement.size() > 0  && documentElement.attr("clientWidth") !== undefined) {
        return {
            width: documentElement.attr("clientWidth"),
            height: documentElement.attr("clientHeight")
        };
    }

    return {
        width: 0,
        height: 0
    };
};

})(jQuery);
