addDOMLoadEvent(function() {
    if (window.location.href.indexOf('paged=true') < 0)
        return;

    hideSections();

		 var defaultSection = $C('section', 'div')[0].id;

    if (window.location.href.indexOf('#') >= 0) {
    		 var tmp = window.location.href.split('#')[1];
    		 tmp = tmp.split('&')[0].split('?')[0];

		 		 if (tmp.split('section_').length > 1 && document.getElementById(tmp.split('section_')[1]))
		 		 		 defaultSection = tmp.split('section_')[1];
		 }

    var pagedDocument = new PagedDocument('main_content', defaultSection);
		 var content = $('content');
		 HTMLDOMUtil.addClass(content, 'paged_document');

    if (window.parent && window.parent.location != window.location) {
        $A(content.getElementsByTagName('a'), function(link) {
            if (window.location.href == link.href.split('#')[0]) {
                link.pagedDocument = pagedDocument;
		 		 		 		 link.onclick = function(e) { this.pagedDocument.display(this.href.split('#')[1]); return false; };
		 		 		 } else if (link.rel != 'external' && link.rel != 'document') {
                link.onclick = function() { window.parent.location.href = this.href; return false; };
            }
        });
    }

		 content.appendChild(pagedDocument.getMenu('popup_navigation'));

    var printButton = HTMLDOMUtil.createElement('a', null, null, 'Skriv ut alle sidene', ['href', '', 'onclick', function(e) { window.print(); return false; }]);
    content.appendChild(HTMLDOMUtil.createElement('p', null, 'print', printButton));
});

function hideSections() {
    if (window.location.href.indexOf('hide') < 0)
        return;

    var hide = URL.parameter('hide').split('-');

    for (var i = 0; i < hide.length; i++)
        HTMLDOMUtil.removeIfExists(hide[i]);
}

