var SilverlightPopupControl;
        var imageCollection = '';

        function SilverlightPopupControlLoaded(sender, args) 
        {
            SilverlightPopupControl = document.getElementById('SilverlightPopup').Content.Popup;
        }

        function ImagePopup(uri) 
        {
            if (SilverlightPopupControl == null) 
            {
                SilverlightPopupControl = document.getElementById('SilverlightPopup').Content.Popup;
            }

            document.getElementById('SilverlightPopupContainer').style.width = '100%';
            document.getElementById('SilverlightPopupContainer').style.height = '100%';

            if (imageCollection != '') {
                SilverlightPopupControl.SetUrl(uri, imageCollection);
            }
            else {

                SilverlightPopupControl.SetUrl(uri);
            }

            window.onscroll = SilverlightPopupOnScroll;
            window.onresize = SilverlightPopupOnScroll;

            SilverlightPopupOnScroll();
        }

        function CloseSilverlightPopup() {
            document.getElementById('SilverlightPopupContainer').style.width = '1px';
            document.getElementById('SilverlightPopupContainer').style.height = '1px';          
        }

        function IETrueBody() {
            return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
        }

        function SilverlightPopupOnScroll() {
            var divModal = document.getElementById('SilverlightPopupContainer');

            if (divModal != null) {
                divModal.style.top = IETrueBody().scrollTop + 'px';
                divModal.style.width = IETrueBody().scrollLeft + IETrueBody().clientWidth + 'px';
            }
        }

        function GetClientHeight() {
            return IETrueBody().clientHeight;
        }

        function SetImageCollection(collection) {
            imageCollection = collection;
        }           
