﻿$.ajaxSetup({
    // Disable caching of AJAX responses */
    cache: false
});


$(document).ready(function() {
    $("dd:not(:first)").hide();
    $("dt a").click(function() {
        $("dd:visible").slideUp("slow")
        $(this).parent().next().slideDown("slow");
        return false;
    });
});


function loadTutorial(tutorialName) {
    $.ajax({
        type: "GET",
        url: "tutorials/" + tutorialName,
        dataType: "html",
        success: function(tutorialXml) {
            helper(tutorialXml);
        }
    });
}


function helper(tutorialXml) {
    var elem = $("#content > div").remove();
    elem = null;

    $("#content").append(tutorialXml);
}


function callback(hash) {
    if (hash == "")
        loadTutorial("default.xml");
    else
        loadTutorial(hash + ".xml");
}


$(document).ready(function() {
    $.history.init(callback);
    $("a[@rel='history']").click(function() {
        $.history.load(this.href.replace(/^.*#/, ''));
        return false;
    });
});