<script language="javascript" type="text/javascript">
        window.onload = setValues();
        window.onunload = popup();
        
        var doPopup = 1;
        
        function popup() {
            if (doPopup == 1)
            alert('I see you are leaving the site');
        }
        
        function setValues()
        {
            doPopup = 0;
        }
</script>