if(!($.browser.msie && $.browser.version < 7)){

    $(document).ready(function() {        
        
        $('.page').after('<div id="loading" ><p><img src="/img/js/ajax-loader.gif" /></p></div>');
        
        if(window.location.hash){
            loadPage(window.location.hash.substr(1));
        }
        
        $("a:not(a[href^=http://])").live('click', function(){
            loadPage($(this).attr('href'));
            window.location.hash = $(this).attr('href');
            return false;
        });
    
    });
    
    function loadPage(url){
        if(url){
            if(window.location.hash && !(window.location == 'http://watcherthemovie.com/' + window.location.hash)){
                window.location = 'http://watcherthemovie.com/' + window.location.hash;
            }

            $('.page').slideUp(300);
            $('#loading').fadeIn(300);
            
            $('.page').load(
                url,
                {"fromUrl" : window.location.hash.substr(1)},
                function (responseText, textStatus, XMLHttpRequest) {
                    
                    $('#loading').fadeOut(300, function(){
                            $('.page').slideDown(300);
                        });
                    
                    if((document.documentElement.scrollTop + document.body.scrollTop) > $("#content").offset().top){
                        $('html, body').animate({
                        scrollTop: $("#content").offset().top
                        }, 200);
                    }            
                    
                    document.title = $('h2:first').text();
                    
                });
        }
    }
}
