Help with form wizard and onbeforeunload

Help with form wizard and onbeforeunload

Hi, I have a very long form that has been broken into steps with a modified form wizard. I had to use onbeforeunload so a warning is displayed if the user refreshes, closes or hits the browser back button. I need to disable this on the first and last (fifth) step. So it only needs to work on the steps 2-4. Easy enough to disable it on submit, but I can't get it to disable for the first. Im trying to disable it when #step0 has a css display of block, that is when it is visible. Can you see why this isn't working?

<script type="text/javascript">
 var action_is_post = false;

        $(document).ready(function () {

            $("form").submit(function () {
                action_is_post === true;
            });
           
//when step 0 has display:block it should be able to refresh, close or hit back button
            if($("#step0").css("display","block")) {
                action_is_post === true;                  
            }
           
            window.onbeforeunload = function () {
                if (action_is_post === false) {
                    return 'Using the browsers back, refresh or close button will cause you to lose all form data. Please use the Next and Back buttons on the form.';
                }
            }

        });

</script>

Kane Leins