var ePrevActive = null;
var titles = null;
/* class myTitles */
function myTitles ()
{
this.allHeadings = new Array ();
//methods
this.generateMenu = generateMenu;
this.getAllHeadings = getAllHeadings;
this.showFirstTitle = showFirstTitle;
}
/* function generateMenu
* description:
* function used for building and displaying titles in a menu
*/
function generateMenu ()
{
this.getAllHeadings ();
var htmlObj = document.getElementById ('titlesMenu');
var menuHTML = "
";
var rowNumber = this.allHeadings.length;
var index = 0;
for (var i=0; i < rowNumber; i++)
{
index = i;
menuHTML += "- " + this.allHeadings[index] + "
";
}
menuHTML += "
";
if (htmlObj)
htmlObj.innerHTML = menuHTML;
this.showFirstTitle ();
setTitleActive (null, 0);
//display table
var obj = document.getElementById ('titlesMain');
if (obj)
obj.style.display = '';
}
/* function getAllHeadings
* description:
* function used for obtaining all headings into a string array
*/
function getAllHeadings ()
{
var elements;
elements = document.getElementsByTagName ('H2');
if (elements)
{
for (var i=0; i < elements.length; i++)
{
this.allHeadings [i] = elements [i].innerHTML;
}
}
}
/* function showFirstTitle
* description:
* function displays first item and hides all others
*/
function showFirstTitle ()
{
var elements = document.getElementsByTagName ('H2');
if (!elements)
return 0;
var parent = elements [0].parentNode;
if (!parent)
return 0;
parent.style.display = '';
for (var i=1; i < elements.length; i++)
{
parent = elements [i].parentNode;
if (!parent)
return 0;
if (parent.tagName.toUpperCase () == "DIV")
parent.style.display = 'none';
}
}
/* end class myTitles */
//EVENT FUNCTIONS
/* function setHover
* params:
* e hovered element object
* description:
* function used to change style of hovered object
*/
function setHover(e) { e.oldClassName = e.className; e.className = "linkHover"; }
/* function setNoHover
* params:
* e element object
* description:
* function used to change style of object on mouse out
*/
function setNoHover(e) { e.className = e.oldClassName; }
/* function setObjHide
* params:
* e element object
* description:
* function used to change class of object
*/
function setObjHide(e) { e.className = "hidden"; }
/* function setObjShow
* params:
* e element object
* description:
* function used to change class of object
*/
function setObjShow(e) { e.className = ""; }
/* function setTitleActive
* params:
* e current title object
* index index number of the object
* description:
* function used to change style of clicked object.
*/
function setTitleActive (e, index)
{
if (!e)
{
var obj = document.getElementById ("title" + index);
if (!obj)
return 0;
e = obj.parentNode;
}
e.className = "linkActive";
e.oldClassName = "linkActive";
if ((ePrevActive) && (e != ePrevActive))
ePrevActive.className = "";
ePrevActive = e;
showItem (index);
showNavigator (index);
scroll (0, 0);
}
/* function showItem
* params:
* itemNumber number of item that should be displayed
* description:
* function shows selected item and hides all others
*/
function showItem (itemNumber)
{
var elements = document.getElementsByTagName ('H2');
if (!elements)
return 0;
var parent = elements [itemNumber].parentNode;
if (!parent)
return 0;
parent.style.display = '';
var linkbox = document.getElementById ("mktgLinksPH");
if (linkbox != 0)
{
if (itemNumber == 0)
linkbox.style.display = "";
else
linkbox.style.display = "none";
}
for (var i=0; i < elements.length; i++)
{
if (i != itemNumber)
{
parent = elements [i].parentNode;
if (!parent)
return 0;
if (parent.tagName.toUpperCase () == "DIV")
parent.style.display = 'none';
}
}
}
/* function showFullArticle
* description:
* function used to display full article and hide navigator
*/
function showFullArticle ()
{
var elements = document.getElementsByTagName ('H2');
if (!elements)
return 0;
var parent = null;
for (var i=0; i < elements.length; i++)
{
parent = elements [i].parentNode;
if (!parent)
return 0;
if (parent.tagName.toUpperCase () == "DIV")
parent.style.display = '';
}
var linkbox = document.getElementById ("mktgLinksPH");
if (linkbox != 0)
linkbox.style.display = "";
//prev
obj = document.getElementById ("navPrevImg");
if (obj)
setObjHide (obj);
//next
obj = document.getElementById ("navNextImg");
if (obj)
setObjHide (obj);
//full article
obj = document.getElementById ("navFullImg");
setObjHide (obj);
//reset selection
ePrevActive.className = "";
scroll (0, 0);
}
/* function showNavigator
* params:
* itemNumber number of currently displayed item
* description:
* function shows navigator for previous and next chapter
*/
function showNavigator (itemNumber)
{
var obj;
//previous
obj = document.getElementById ("navPrevImg");
if (obj)
{
if (itemNumber == 0)
setObjHide (obj);
else
{
setObjShow (obj);
addOnClick (obj, setTitleActive, null, (itemNumber - 1));
}
}
//next
obj = document.getElementById ("navNextImg");
if (obj)
{
if (itemNumber == (titles.allHeadings.length - 1))
setObjHide (obj);
else
{
setObjShow (obj);
addOnClick (obj, setTitleActive, null, (itemNumber + 1));
}
}
//full article
obj = document.getElementById ("navFullImg");
if (obj)
{
setObjShow (obj);
addOnClick (obj, showFullArticle, null, null);
}
}
/* function loadNavImg
* params:
* e object with preloaded images
* activeGif image loaded for mouseover event
* inactiveGif image loaded for mouseout event
* description:
* function used for preloading navigator images
*/
function loadNavImg (e, activeGif, inactiveGif) {
e.active = new Image();
e.active.src = activeGif;
e.inactive = new Image();
e.inactive.src = inactiveGif;
}
/* function setNavImg
* params:
* e current object
* active boolean state: 1 - show active image, 0 - show inactive image
* description:
* function used for seting a valid preloaded image
*/
function setNavImg (e, active)
{
if (active)
e.src = e.active.src;
else
e.src = e.inactive.src;
}
function loadTitles() {
titles = new myTitles ();
titles.generateMenu ();
}
function addOnLoad(f) {
var wasOnLoad = window.onload ;
window.onload = function () {
f ();
if (wasOnLoad) {
if (typeof wasOnLoad == "string") { eval(wasOnLoad); } else { wasOnLoad(); }
}
}
}
/* function addOnClick
* params:
* e object to which onClick event will be added;
* f function to run
* param1 first function parameter
* param2 second function parameter
*/
function addOnClick (e, f, param1, param2)
{
e.onclick = function () { f (param1, param2); }
}