﻿/*
object_AddEventListener(window, 'load', initializeDhtmlHistory, false);

// Our function that initializes when the page is finished loading. 
function initializeDhtmlHistory() {
    // initialize the DHTML History framework
    dhtmlHistory.initialize();
    // add ourselves as a DHTML History listener
    dhtmlHistory.addListener(handleHistoryChange);  
    
    
    var currentLocation = dhtmlHistory.getCurrentLocation();
    if (currentLocation == "") {
        currentLocation = "TutorialMenu.asp";
    }
        
    
    __LoadTutorialSection(currentLocation, null);     
}

// Handles history change events.
function handleHistoryChange(newLocation, historyData) {
    if (newLocation == "") {
        newLocation = "TutorialMenu.asp";
    }    
    
    __LoadTutorialSection(newLocation, historyData);        
}

function __LoadTutorialSection(sectionName, content) {
    var div, innerDiv, menuLink;
    var subSectionName = null;
    var splitIndex;
    //var TutorialSectionIFrame;
    
    div = document.getElementById("TutorialSectionDiv");
    innerDiv = document.getElementById("TutorialSectionDivContents");
    menuLink = document.getElementById("TutorialMenuLink");
    //TutorialSectionIFrame = document.getElementById("TutorialSectionIFrame");
    
    splitIndex = sectionName.indexOf(":")
    if (splitIndex > -1) {
        subSectionName = sectionName.substring(splitIndex+1);
        sectionName = sectionName.substring(0, splitIndex);
    }
    
    if (sectionName.toLowerCase() == "tutorialmenu.asp") {
        menuLink.style.display="none"; 
        div.style.padding = "0px;"   
    } else {
        menuLink.style.display="";    
        div.style.padding="5px";
    }
    
    
    if (content == null)
    {
        // get the filename to load
        var url = ServerURL + "/lists/tutorial/" + sectionName;

        // load this file synchronously
        var request = GetSynchronousXmlHttpObject();
        request.open("POST", url, false);
        request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");	
        
        request.send(null);
        content = ""; //request.getAllResponseHeaders() + "<br />";
        //alert(request.responseText);
        content += request.responseText;        
    }
    
    // now place this content and title into the HTML
    div.scrollTop = 0;
    dhtmlHistory.add(sectionName, content);
    //TutorialSectionIFrame.src = ServerURL + "/lists/tutorial/" + sectionName
    innerDiv.innerHTML = content;
    
    if (subSectionName != null && document.getElementById("anchor:" + subSectionName)) {
        document.getElementById("anchor:" + subSectionName).scrollIntoView(true);
    }
}

*/

function LoadTutorialSection(sectionName) {
    var subSectionName = null;
    var splitIndex;
    var url;
    var menuLink;
    
    menuLink = document.getElementById("TutorialMenuLink");
    
    splitIndex = sectionName.indexOf(":")
    if (splitIndex > -1) {
        subSectionName = sectionName.substring(splitIndex+1);
        sectionName = sectionName.substring(0, splitIndex);
    }   
    
    url = "/Lists/Tutorial.asp?sectionName=" + sectionName;
    
    if (subSectionName != null) {
        url += "&subSectionName=" + subSectionName;
    }
    
    window.location.href = url;
    
    //__LoadTutorialSection(sectionName, null);
}

function ShowTutorialMenu() {
    LoadTutorialSection("TutorialMenu.asp");
}
