        /****
        * IMPORTANT:  Controls in here are named specifically for /Products/DocumentView.aspx page (id's are derived by asp.net from a content page inside a master page)
        * Ideally this would be a little more flexible
        *****/
        var postBackElement; 
        var clientClickX;
        var clientClickY;


        function setClickPosition(e) 
        {
            clientClickY = e.clientY - $get("centercolcontent").parentNode.offsetTop + document.body.scrollTop + document.documentElement.scrollTop;
            clientClickX = e.clientX - $get("centercolcontent").parentNode.offsetLeft + document.body.scrollLeft + document.documentElement.scrollLeft;
            setYellowDiv(e);
        }


        function ImageMapBegin() 
        {
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
            Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoadComplete); 
            addClickHandlerForImageMap();
            addScrollHandlerForImageMap();
        }
        

        
        function beginRequest(sender, args) 
        {
            postbackElement = args.get_postBackElement();
            if (postbackElement.id.toLowerCase().indexOf('ctl00_maincontent_uiimagemap') > -1) 
            {
                $clearHandlers($get('ctl00_MainContent_uiImageMap'));
            }
        }
        
        
        function pageLoadComplete(sender, args) 
        {
            
            var updatedPanels = args.get_panelsUpdated();

            if (typeof(postbackElement) === "undefined") 
            {
                return;
            } 
            else if (postbackElement.id.toLowerCase().indexOf('ctl00_maincontent_uiimagemap') > -1) 
            {
                setProductInfoPosition();
                addClickHandlerForImageMap();
                addScrollHandlerForImageMap();
            }
            else if (postbackElement.id.toLowerCase().indexOf('ctl00_pagebody_partaddtocart') > -1) 
            {
                hideProductInfo();
            }
            else if (postbackElement.id.toLowerCase().indexOf('ctl00_pagebody_zoomtext') > -1) 
            {
                hideProductInfo();
                addClickHandlerForImageMap();
                addScrollHandlerForImageMap();
            }
            
            
        }
        

        function setProductInfoPosition() 
        {
            var infoDiv = $get('ProductInformation');
            infoDiv.style.display = "block";
            var img = $get("ImageHolder");
            var infoBounds = Sys.UI.DomElement.getBounds(infoDiv);
            var imgBounds = Sys.UI.DomElement.getBounds(img)
            
            var left = clientClickX + 10;
            
            if ((left + infoBounds.width) > (imgBounds.width + imgBounds.x))
            {
                var farLeft = imgBounds.width + imgBounds.x;
                var w = infoBounds.width;
                left = (farLeft - w);
            }
            
            Sys.UI.DomElement.setLocation(infoDiv, left, clientClickY);
            
        }
        
        
        function hideProductInfo(e) 
        {
                var div = $get('ProductInformation');
                div.style.display = "none";
                
                var div = $get('yellowDiv');
                div.style.display = "none";
        }
        
        function addScrollHandlerForImageMap()
        {
            var e = $get('ImageHolder');
            $addHandler(e, "scroll", hideProductInfo);
        }
        
        
        function addClickHandlerForImageMap()
        {
            var e = document.getElementsByName("ImageMapctl00_MainContent_uiImageMap")[0];
            $addHandler(e, "click", setClickPosition);
        }
        
        function setOriginalSize() 
        {
            var img = $get("ctl00_MainContent_uiImageMap");
            $get("ctl00_MainContent_imageClientWidth").value = img.clientWidth;
            $get("ctl00_MainContent_imageClientHeight").value = img.clientHeight;
        }

          //doesnt work when scrolling...        
        function setYellowDiv(e) 
        {
            //hilite is only working in Firefox....
            if(navigator.userAgent.indexOf("Firefox/2") < 0) 
               return;
             
        
            var yellow = $get("yellowDiv");
            var coords = e.target.coords;
            var divProps = coords.split(',');
            
            var left = e.target.parentNode.parentNode.offsetLeft - $get("ImageHolder").scrollLeft  + parseInt(divProps[0]);
            var top  = e.target.parentNode.parentNode.offsetTop - $get("ImageHolder").scrollTop + parseInt(divProps[1]);
            var width =  parseInt(divProps[2]) - parseInt(divProps[0]);
            var height = parseInt(divProps[3]) - parseInt(divProps[1]);
            
            
            left-=5;
            top-=5;
            width+=10;
            height+=10;
            
            
            yellow.style.top = top + "px;";
            yellow.style.left = left + "px;";
            yellow.style.height = height + "px;";
            yellow.style.width = width + "px;";
            yellow.style.display = "block;"
        }

        if(typeof(Sys) != 'undefined') Sys.Application.notifyScriptLoaded();
