//  file name:
//      dhtml.js
//
//  created:
//      20 January 2004
//
//  revision history (most recent changes first):
//      YYYY-MMM-DD    editor            notes
//      -----------    --------------    -------------------------------
//      2004-Jan-27    David Freedman    added Netscape 7 support
//      2004-Jan-27    David Freedman    added dhtmljs_clickToAdvance
//      2004-Jan-26    David Freedman    added recursive searching for spans
//      2004-Jan-20    David Freedman    file created
//
//
//  Licensed Materials  - Property  of IBM
//  (c)  Copyright IBM Canada Ltd. 2004    All Rights Reserved



function /*void*/ dhtmljs_clickToAdvance(/*String*/ nextPage) {
//sets up a page-level onclick event handler to advance to another page
//
//parameters:
//    nextPage
//        the url to advance to when the user clicks
//
//returns:
//    nothing.

	//if the function has already been called by this page
	if (window.dhtmljs_clickToAdvance_nextPage) {
		//change the next page used by the function
		window.dhtmljs_clickToAdvance_nextPage = nextPage;

		//get out
		return;

	} /*end if*/

	//save the nextPage parameter in the window for later access
	window.dhtmljs_clickToAdvance_nextPage = nextPage;

	//create a function to handle the click
	var /*function*/ onmouseup = function() {
		window.location = window.dhtmljs_clickToAdvance_nextPage;
	};

	//if we are using Netscape
	if (window.captureEvents) {

		//register the function with the browser as a handler
		window.captureEvents(Event.MOUSEUP);
		window.onmouseup = onmouseup;

	//assume Internet Explorer
	} else

		//register the function with the browser as a handler
		document.onmouseup = onmouseup;

} /*end function dhtmljs_clickToAdvance*/



function /*private Span*/ dhtmljs_find(/*String*/ spanName, /*optional Document*/ startFrom) {
//searches through the DOM for a span
//
//parameters:
//    spanName
//        the name of the span to find
//
//    startFrom
//        the starting node in the DOM.  This should be either document or
//        omitted
//
//returns:
//    the span if the search was successfull, otherwise null

	//results of a recursive function call in Netscape
	var /*Span*/ childRet = null;

	//default the optional startFrom parameter to document.
	if (!startFrom) startFrom = document;

	//if we're using the Netscape 7 DOM
	if (startFrom.getElementById)
		return startFrom.getElementById(spanName);

	//if we're using the Internet Explorer DOM
	else if (startFrom.all)

		//if the span exists
		if (startFrom.all[spanName])

			//return the span
			return startFrom.all[spanName];

		//if the span does not exist
		else

			//exit and return null to indicate failure
			return null;

	//assume we're using the Netscape 4.x DOM
	else

		//if the span exists
		if (startFrom.layers[spanName])

			//return the span
			return startFrom.layers[spanName];

		//if the span does not exist
		else

			//search recursively through the child documents
			for (var /*int*/ i = 0; i < startFrom.layers.length; i++)

				//if the span is found in a subdocument
				if ((childRet = dhtmljs_find(spanName, startFrom.layers[i])) != null)

					//return the span
					return childRet;

	//exit and return false to indicate the span was not found
	return null;

} /*end function dhtmljs_find*/



function /*public boolean*/ dhtmljs_hide(/*String*/ spanName) {
//hides a span
//if the span does not exist, nothing happens
//
//parameters:
//    spanName
//        the name of the span to hide
//
//returns:
//    true if the span was successfully hidden, otherwise false


	//attempt to find the span on the page
	var /*Span*/ span = dhtmljs_find(spanName);

	//if the span was not found
	if (span == null)

		//exit and return false to indicate failure
		return false;

	//if we're using the Internet Explorer DOM
	else if (span.style)

		//hide the span
		span.style.visibility = "hidden";

	//if we're using the Netscape DOM
	else if (span.visibility)

		//hide the span
		span.visibility = "hide";

	//if we're using something else
	else

		//exit and return false to indicate failure
		return false;

	//exit and return true to indicate success
	return true;

} /*end function dhtmljs_hide*/




function /*public boolean*/ dhtmljs_show(/*String*/ spanName) {
//shows a span
//if the span does not exist, nothing happens
//
//parameters:
//    spanName
//        the name of the span to show
//
//returns:
//    true if the span was successfully shown, otherwise false


	//attempt to find the span on the page
	var /*Span*/ span = dhtmljs_find(spanName);

	//if the span was not found
	if (span == null)

		//exit and return false to indicate failure
		return false;

	//if we're using the Internet Explorer DOM
	else if (span.style)

		//show the span
		span.style.visibility = "visible";

	//if we're using the Netscape DOM
	else if (span.visibility)
{
		//show the span
		span.visibility = "show";

}
	//if we're using something else
	else

		//exit and return false to indicate failure
		return false;

	//exit and return true to indicate success
	return true;

} /*end function dhtmljs_show*/