﻿// ---------------------------------------------------------------
// KNOWLEDGE MAP DYNAMIC "ON THIS PAGE..." NAVIGATION MENUS LAYOUT
// ---------------------------------------------------------------
// Copyright (c) 2004 The Salamander Organization Ltd.  All Rights Reserved.
//
// THIS WORK IS SUBJECT TO U.K. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
//
// DISCLAIMER:
//
// The Salamander Organization Ltd. (hereto referred as "Salamander") makes no representations or warranties
// with respect to the contents or use of this code, and specifically disclaims any express or implied
// warranties of merchantability or fitness for any particular purpose.  Further, Salamander reserves the right
// to revise this publication and to make changes to its content, at any time, without obligation to notify any
// person or entity of such revisions or changes.
//
// Further, Salamander makes no representations or warranties with respect to any software, and specifically
// disclaims any express or implied warranties of merchantability or fitness for any particular purpose.  Salamander
// reserves the right to make changes to any and all parts of the software, at any time, without obligation to notify
// any person or entity of such changes.
//
// Inclusion of the above notice does not necessarily imply publication.

// ########################
// ### SYSTEM VARIABLES ###

// the text for when there are no sections
var noNavText = "There is no navigation for this page.";


// ##########################################
// ### HTML LAYOUT FOR THE SECTION TITLES ###

// layout the basic structure for a section title
function LayoutSectionTitle(titleText, lock)
{	
	if (lock)
	{
		var sectionTitleStructure = "<h3 class='pageSubTitle'>" + titleText + "</h3>\n";
	}
	else
	{
		var sectionTitleEvent = GetSectionTitleClickEvent(titleText);
		var sectionTitleStructure = "<h3 class='pageSubTitle'><a href='#' onclick='" + sectionTitleEvent + "'>" + titleText + "</a></h3>\n";
	}
	
	return sectionTitleStructure;
}

// #####################################################################
// ### NAVIGATION FUNCTIONS FOR "ON THIS PAGE..." AND SECTION TITLES ###

// definition for action when a navigation link is clicked on
// --- scrolls to the section specified
function DoNavClickEvent_ScrollToSection(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) document.getElementById(\"" + sectionTextID + "\").scrollIntoView(true)";
}


// definition for action when a navigation link is clicked on
// --- shows or hides the section specified
function DoNavClickEvent_ToggleSection(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) ToggleSection(\"" + sectionTextID + "\", false)";
}

// definition for action when a navigation link is clicked on
// --- shows or hides the section specified
// --- if displaying, scrolls to the section specified
// --- if hiding, scrolls back to the top of the page
function DoNavClickEvent_ToggleSectionAndScroll(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) ToggleSection(\"" + sectionTextID + "\", true)";
}

// definition for action when a navigation link is clicked on
// --- shows the section specified
// --- if already displayed, does nothing
function DoNavClickEvent_ShowSection(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) ShowSectionByFullId(\"" + sectionTextID + "\", false)";
}

// definition for action when a navigation link is clicked on
// --- shows the section specified
// --- if already displayed, scrolls to the section specified
function DoNavClickEvent_ShowSectionAndScroll(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) ShowSectionByFullId(\"" + sectionTextID + "\", true)";
}

// definition for action when a navigation link is clicked on
// --- hides all currently visible sections
// --- shows the section specified, ensuring that the top of this section is in view
function DoNavClickEvent_ShowOnlySection(sectionTextID)
{
	return "javascript:if (document.getElementById(\"" + sectionTextID + "\")) ShowOnlySectionByFullId(\"" + sectionTextID + "\", true)";
}

// definition for action when a section title link is clicked on
// --- hides the section specified
function DoSectionTitleClickEvent_HideSection(sectionName)
{
	HideSectionByName(sectionName, false, false);
}

// definition for action when a section title link is clicked on
// --- hides the section specified
// --- scrolls back to the top of the page
function DoSectionTitleClickEvent_HideSectionAndScroll(sectionName)
{
	HideSectionByName(sectionName, true, false);
}

// helper to write out the event for a section title click
function GetSectionTitleClickEvent(titleText)
{
	var clickEvent = 'javascript:DoSectionTitleClickEvent("' + titleText + '")';
	
	return clickEvent;
}
