//_________________GLOBALS_________________
var audioIsOn = false;
var bookIsOn = false;
var popupT = null;
var popupA = null;
var linkToForum = "http://23839.homepagemodules.de/";
var linkToCalendar = "";
//_________________FUNCTIONS_________________

// **************************************************************************
function popup_audio()
    {
      breit = 256;
      maxpos = screen.availWidth - 10 - breit;
      popupA = window.open( "audio.html","audio", 'toolbar=no,scrollbars=no,location=no,top=5,left=' + maxpos + ',statusbar=no,menubar=no,resizable=no,width=' + breit + ',height=' + "64" + '' );
 

      if ( popupT ) popupT.focus();
      popupA.focus();
    }
// **************************************************************************
function popup_close()
    {
      if ( popupT ) popupT.close();
      if ( popupA ) popupA.close();
    }
// **************************************************************************
function popup_text()
    {
      breit = 450; hoch=440;
      Xpos = screen.availWidth - 10 -breit;
      Ypos = 154;
      hoch = screen.availHeight - 30 - Ypos;

      bars = 'toolbar=no,scrollbars=yes,location=no,statusbar=no';
      poss = ',top=' + Ypos + ',left=' + Xpos + ',width=' + breit + ',height=' + hoch + '' ;
      popupT = window.open( "text.html","text", bars + poss );
      

      if ( popupA ) popupA.focus();
      popupT.focus();
    }

// **************************************************************************
function switchIcon(imageName, imageSrc)
{
  if (document.images)
  {
    if (imageSrc != "none")
    {
      document.images[imageName].src = imageSrc;
    }
  }
}

// **************************************************************************
function audioOnOff()
{
	if (audioIsOn)
	{
		audioIsOn = false;
		switchIcon("speaker", pathString+"speakerNoActive.gif");
		if ( popupA ) popupA.close();
		popupA = null;
		if ( popupT ) popupT.focus();
	}
	else
	{
		audioIsOn = true;
		switchIcon("speaker", pathString+"speakerActive.gif");
		popup_audio();
	}
}
// **************************************************************************
function bookOnOff()
{
	if (bookIsOn)
	{
		bookIsOn = false;
		switchIcon("book", pathString+"bookOpenNoActive.gif");
		if ( popupT ) popupT.close();
		popupT = null;
		if ( popupA ) popupA.focus();
	}
	else
	{
		bookIsOn = true;
		switchIcon("book", pathString+"bookOpenActive.gif");
		popup_text();
	}
}
// **************************************************************************
function closeTextWindow()
{
	if (bookIsOn == true)
	{
		bookIsOn = false;
		switchIcon("book", pathString+"bookOpenNoActive.gif");
		popupT = null;
	}
}
// **************************************************************************
function closeAudioWindow()
{
	if (audioIsOn == true)
	{
		audioIsOn = false;
		switchIcon("speaker", pathString+"speakerNoActive.gif");
		popupA = null;
	}
}
//*************************************************************************
function jumpToPage()
{
	var pageNo = document.getElementById("currentPage").value;
	if (pageNo > 0 && pageNo <= structure.length)
	{
		if (pageNo != myPageNo)
		{
			if (pageNo == 1)
			{
				parent.location.href = "../frameset.html";
			}
			else
			{
				if (myPageNo == 1)
				{
					parent.location.href = structure[pageNo-1] + "/frameset.html";
				}
				else
				{
					parent.location.href = "../" + structure[pageNo-1] + "/frameset.html";
				}
				
			}
			myPageNo = pageNo;
		}
	}
	else
	{
		document.getElementById("currentPage").value = myPageNo;
	}
}
// **************************************************************************
function setJumpToPageNo(pageNumber)
{
	jumpToPageNo = pageNumber;
	alert("jumpToPageNo = " + structure.length);
}
// **************************************************************************
function deleteAllChildren(myNode)
{
	while(myNode.hasChildNodes())
	{
		myNode.removeChild(myNode.firstChild);
	}
}
// **************************************************************************
function appendLITagTo(list, textString)
{
	var newLI = document.createElement("li");
	var newLIText = document.createTextNode(textString);
	newLI.appendChild(newLIText);
	list.appendChild(newLI);
}
// **************************************************************************
function appendText(node, text)
{
	var newText = document.createTextNode(text);
	node.appendChild(newText);
	return newText;
}
// **************************************************************************
function createAndAppend(node, tag)
{
	var newTag = document.createElement(tag);
	node.appendChild(newTag);
	return newTag;
}

// *** Functions for Jumping to Forum and Calendar ***
function showForum()
{
  window.open(linkToForum, "_blank");
}

function showCalendar()
{
  window.open(linkToCalendar, "_blank");
}