﻿
        
       
        var IE = document.all ? true : false
       // if (!IE) document.captureEvents(Event.MOUSEUP)
        
        if (IE) {
            document.onmousedown = GetMouseXY;
        } else {
            document.addEventListener('mousedown', GetMouseXY, true);
        }
       
        
                
        
        
        ///////////////////////////////////////////////////
        // Capture MouseUP Events
        ///////////////////////////////////////////////////
        function GetMouseXY(e) 
        {
            var posx = 0;
            var posy = 0;
            
            if (!e) var e = window.event;
            if (e.pageX || e.pageY) 	
            {
	            posx = e.pageX;
	            posy = e.pageY;
            }
            else if (e.clientX || e.clientY) 	
            {
	            posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	            posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
            }
         
         
            // Get the current page name, or user supplied page name
            var sPage = location.href;

            loadscript("http://heatmap.paulunlimited.net/heatmapservice.aspx?coordX=" + posx + "&coordY=" + posy + "&page=" + escape(sPage));
            
            // Let the mouse event continue normally
            return true;
        }


	function loadscript(url) {
        if ((window.location.protocol == "http:") || (window.location.protocol == "https:")) {
            //delete old if exists
//            var oldscript = document.getElementById('callbackScript');
//               if (oldscript != null) {
//                 oldscript.parentNode.removeChild(oldscript);
//                 delete oldsctipt;
//               }  
            
            //add new script
            var scriptTag = document.createElement("script");
            scriptTag.setAttribute("type", "text/javascript");
            scriptTag.setAttribute("src", url);
            scriptTag.id = 'callbackScript';
            document.getElementsByTagName("head")[0].appendChild(scriptTag);
        }      
	}  