demo/load-event/js/libs/jquery.isinview/jquery.isinview-1.0.3.js
function wrapContainer ( container ) {
        var $container,
            isJquery = container instanceof $;

        if ( ! isJquery && ! $.isWindow( container ) && ! container.nodeType && ! isString( container ) ) throw new Error( 'Invalid container: not a window, node, jQuery object or selector string' );

        $container = isJquery ? container : container === root ? $root : $( container );

        if ( !$container.length ) throw new Error( 'Invalid container: empty jQuery object' );

        container = $container[0];

        if ( container.nodeType === 9 ) {
            // Document is passed in, transform to window
            $container = wrapContainer( container.defaultView || container.parentWindow );
        } else if ( container.nodeType === 1 && container.tagName.toLowerCase() === "iframe" ) {
            // IFrame element is passed in, transform to IFrame content window
            $container = wrapContainer( container.contentWindow );
        }

        // Check if the container matches the requirements
        if ( !$.isWindow( $container[0] ) && $container.css( "overflow" ) === "visible" ) throw new Error( 'Invalid container: is set to overflow:visible. Containers must have the ability to obscure some of their content, otherwise the in-view test is pointless. Containers must be set to overflow:scroll/auto/hide, or be a window (or document, or iframe, as proxies for a window)' );

        return $container;
    }
function wrapContainer ( container ) {
        var $container,
            isJquery = container instanceof $;

        if ( ! isJquery && ! $.isWindow( container ) && ! container.nodeType && ! isString( container ) ) throw new Error( 'Invalid container: not a window, node, jQuery object or selector string' );

        $container = isJquery ? container : container === root ? $root : $( container );

        if ( !$container.length ) throw new Error( 'Invalid container: empty jQuery object' );

        container = $container[0];

        if ( container.nodeType === 9 ) {
            // Document is passed in, transform to window
            $container = wrapContainer( container.defaultView || container.parentWindow );
        } else if ( container.nodeType === 1 && container.tagName.toLowerCase() === "iframe" ) {
            // IFrame element is passed in, transform to IFrame content window
            $container = wrapContainer( container.contentWindow );
        }

        // Check if the container matches the requirements
        if ( !$.isWindow( $container[0] ) && $container.css( "overflow" ) === "visible" ) throw new Error( 'Invalid container: is set to overflow:visible. Containers must have the ability to obscure some of their content, otherwise the in-view test is pointless. Containers must be set to overflow:scroll/auto/hide, or be a window (or document, or iframe, as proxies for a window)' );

        return $container;
    }
function wrapContainer ( container ) { var $container , isJquery = container instanceof $ ; if ( ! isJquery && ! $ . isWindow ( container ) && ! container . nodeType && ! isString ( container ) ) throw new Error ( 'Invalid container: not a window, node, jQuery object or selector string' ) ; $container = isJquery ? container : container === root ? $root : $ ( container ) ; if ( ! $container . length ) throw new Error ( 'Invalid container: empty jQuery object' ) ; container = $container [ 0 ] ; if ( container . nodeType === 9 ) { // Document is passed in, transform to window $container = wrapContainer ( container . defaultView || container . parentWindow ) ; } else if ( container . nodeType === 1 && container . tagName . toLowerCase ( ) === "iframe" ) { // IFrame element is passed in, transform to IFrame content window $container = wrapContainer ( container . contentWindow ) ; } // Check if the container matches the requirements if ( ! $ . isWindow ( $container [ 0 ] ) && $container . css ( "overflow" ) === "visible" ) throw new Error ( 'Invalid container: is set to overflow:visible. Containers must have the ability to obscure some of their content, otherwise the in-view test is pointless. Containers must be set to overflow:scroll/auto/hide, or be a window (or document, or iframe, as proxies for a window)' ) ; return $container ; }
Establishes the container and returns it in a jQuery wrapper.

Resolves and normalizes the input, which may be a document, HTMLElement, window, or selector string. Corrects
likely mistakes, such as passing in a document or an iframe, rather than the corresponding window.

@param {Window|Document|HTMLElement|HTMLIFrameElement|jQuery|string} container
@returns {jQuery}
Establishes the container and returns it in a jQuery wrapper .