/*!
 * (c) 2010 SysIQ, Inc. All rights reserved.
 *
 * This product is protected by United States laws,
 * international copyright treaties and all other applicable
 * national or international laws.
 *
 * This software may not, in whole or in part, be copied,
 * photocopied, translated, modified, or reduced to any
 * electronic medium or machine readable form
 * without the prior written consent of SysIQ, Inc.
 *
 * Filename: jquery.viewport.js
 * Author:   Alexander Goldobin
 *
 * 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);
