jQuery Delay and Queue not always running after window.onhashchange
<p>This code seems to work perfectly:</p>

<pre><code>window.onhashchange = function(){
    if (!window.location.href.match('#pop')) {
        //alert('go back last');
        $('#main').removeClass('hidden');
        $('.pop').removeClass('pop-ready');
        $('.pop').addClass('pop-hidden');
    }

    /* navigate back after back button */
    if (!window.location.href.match('#secondpage')) {
        $('#pageCont').removeClass('posTwo');
        $('#pageOne').removeClass('hidden');
        $('#pageTwoInner').addClass('hidden'); 

    }
    if (window.location.href.match('#secondpage')) {
        $('#pageCont').addClass('posTwo');

        $('#pageTwoInner').removeClass('hidden'); 
    }
}; 
</code></pre>

<p>However when I when I add a delay and queue to one function the code becomes temperamental and sometimes that class is not added: </p>

<pre><code>window.onhashchange = function(){
    if (!window.location.href.match('#pop')) {
        //alert('go back last');
        $('#main').removeClass('hidden');
        $('.pop').removeClass('pop-ready');
        $('.pop').addClass('pop-hidden');
    }

    /* navigate back after back button */
    if (!window.location.href.match('#secondpage')) {
        $('#pageCont').removeClass('posTwo');
        $('#pageOne').removeClass('hidden');
                    /* CHANGE HERE */
        $('#pageTwoInner').delay(200).queue(function(){
            $(this).addClass('hidden'); 
        });
    }
    if (window.location.href.match('#secondpage')) {
        $('#pageCont').addClass('posTwo');

        $('#pageTwoInner').removeClass('hidden'); 
    }
}; 
</code></pre>
