﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />
/// <reference path="jquery.history.js" />
/// <reference path="methods.js" />

// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {

    //alert("pageload: " + hash);
    // hash doesn't contain the first # character.

    if (hash) {
        hash = hash.replace(/#/, '');
        //alert(hash);
        // restore ajax loaded state
        if ($.browser.msie) {
            // jquery's $.load() function does't work when hash include special characters like åäö.
            hash = encodeURIComponent(hash);
        }
        if (alreadyRun != undefined && alreadyRun == true) { alreadyRun = false; return; }
        else {                    
            getPageHash(hash);
        }
    }
}


$(function() {    
    $.historyInit(pageload, window.location);    
    if ($.browser.msie && $.browser.version < 8) {
        $("a[href*='javascript:get']").click(function() {
            $.historyLoad(location.hash.replace(/#/, ''));
        });
    };


});


