        function scaleImg() {

        what = document.getElementById('thepic');

                if ((what.width<actualWidth)||(what.height<actualHeight)) {
                        what.width=actualWidth;
                        what.height=actualHeight;
                        displayLayer('block');
                } else {

                        if (what.width>tableWidth()) {
                        what.width=tableWidth();
                        what.height = (actualHeight/actualWidth) * tableWidth();
                        }

                        if (what.height>tableHeight()) {
                        what.height=tableHeight();
                        what.width = (actualWidth/actualHeight) * tableHeight();
                        }
                        displayLayer('none');
                }
         //document.getElementById('scalewarning').style.top=what.height+'px';
         //document.getElementById('scalewarning').style.top=document.body.clientHeight+'px';
         document.getElementById('scalewarning').style.top=(findPosY(document.getElementById('poslyr'))-30)+'px';

                 if(actualHeight<windowHeight()){
                 displayLayer('block');
                 }
        }

        function tableWidth() {
                return windowWidth()-30;
        }

        function tableHeight() {
                return windowHeight()-30;
        }

        function windowWidth() {
                if (navigator.appName=="Netscape")
                        return window.innerWidth;

                return document.body.offsetWidth;
        }

        function windowHeight() {
                if (navigator.appName=="Netscape")
                        return window.innerHeight;

                return document.body.offsetHeight;
        }


        function findPosX(obj){
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (obj.x)
                curleft += obj.x;
        return curleft;
        }

       function findPosY(obj){
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop;
        }

        function displayLayer(how) {
                document.getElementById('scalewarning').style.display=how;
        }

        onresize=scaleImg;
