$(function() {
    var base = 'subdocs/';
    var previous = '';
    var rand = parseInt(Math.random() * 1000);
    window.setInterval(function() {
        var hash = document.location.hash.substr(1);
        if (hash == previous) {
            return;
        }
        var crumbs = hash.split('.');
        var url = base + crumbs[0] + '.html?r=' + rand;
        
        $('#content').css('height', '').load(url, function() {
            var contentHeight = $(this).height();
            var sidebarHeight = $('#sidebar').height();
            if (contentHeight < sidebarHeight) {
                $(this).css('height', sidebarHeight + 'px');
            }
            $(this).css('width', ($(window).width() - 230) + 'px');
            prettyPrint();
            document.location.hash = '#' + hash;
        });
        previous = hash;
    }, 100);
    if (document.location.hash.length == 0) {
        document.location.hash = '#GMap2';
    }
    window.onresize = function() {
        $('#content').css('width', ($(window).width() - 230) + 'px');
    };
    var gaJsHost = ((document.location.protocol == "https:") ? "https://ssl." : "http://www.");
    $(document.body).append(unescape('%3Cscript src="' + gaJsHost + 'google-analytics.com/ga.js" type="text/javascript"%3E%3C/script%3E'));
        var analyticsPoller = window.setInterval(function() {
        if (window._gat) {
            window.clearInterval(analyticsPoller);
            var pageTracker = _gat._getTracker("UA-3704871-1");
            pageTracker._initData();
            pageTracker._trackPageview();
        }
    }, 500);
});
