//======================================================================================================================
/* DESCRIPTION
<properties>
	<history author="ABOE" type="create" date="23.09.2002"/>
	<property name="SCPath" value="$Archive: /js/menu.js $"/>
	<property name="SCVersion" value="$Revision: 3 $"/>
	<property name="SCModtime" value="$Modtime: 25.10.02 15:40 $"/>
	<property name="SCAuthor" value="$Author: aboe $"/>
</properties>
<comments>
	How the menu works:
	
		the top-menu (and his ID num) call by mouse-over the left-menu division ( ID of the top-menu)
			-> topMenu "NavTop2" calls leftMenu division "divNavLeft2"
		the leftmenu item calls the content page and the info page
			-> leftMenu item "NavLeft2-3" calls the page content "page2-3.htm" and a info page	 

	Menu-objects naming-convention:
		Position		         Typ					  Name													                            Remarques
		-------------------- ------------- ---------------------------------------------------------	--------------------------------------------------------
		Top menu:		         <TD>  object  "navTop" & the chapter ID 	                                the Home-button is the "NavTop0" object  				
		Left menu:	         <DIV> object	 "divNavLeft" & the chapter ID
								         <TD>  object	 "navLeft" & the chapter ID & "-" & the subchapter ID
		Content page:        html-page  	 "page" & the chapter ID & "-" & the subchapter ID
		Info page:		       html-page 		 "info-"  & a page ID
		Obj who needs help:  <TD> object   "obj-" & a object ID
		Help divisions:			 <DIV> object	 "divHelp-" & the object ID	from the object who needs help
				
	Menu-objects functionalities:
		Position		         Function			 																 Remarques
		-------------------- --------------------------------------------- ------------------------------------------------	
		Top menu:						 MouseOver(chapter ID,subchapter ID)           display the submenu division
												 MouseClick(chapter ID,subchapter ID, Info ID) display the submenu division and the content / info pages
												 MouseOut(chapter ID)                          hide the submenu division
		Left menu:	         MouseClick(chapter ID,subchapter ID, Info ID) display the content / info pages
		Content page:				 ---        
		Info page:		       ---
		Obj who needs help:  showHelp(help ID)														 display the help division
												 hideHelp(help ID)														 hidde the help division
		Help divisions:			 ---
</comments>
*/
//======================================================================================================================
/* --------- Allgemeine Variablen -------- */
var nNavTopSelected  = "";
var nNavLeftSelected = "";
var nDivSelected		 = "";	
var nIndex           = "2";
var nDivisions			 = "6";
var	nEmpty					 = "";
/* --------- LOADING BACKGROUND IMAGES IN MEMORY -------- */
var nBgImages = 1;
var aBgImages = new Array();
for(var i = 0; i < nBgImages; i++){
	if (i < 10){
		aBgImages[i]  = new Image(); aBgImages[i].src = "../images/bg0"+i+".jpg";}
	else{
		aBgImages[i]  = new Image(); aBgImages[i].src = "../images/bg"+i+".jpg";}
}	

//======================================================================================================================


/* --------- SITE INITIALISATION -------- */

function init(){
/* Functionality:
		1. Set the windows default sstatus 
		2. Set the default begins page
*/
	window.defaultStatus = "Anicom's Homepage";

	showPages(0,0,0); 	

	loadBgImages(0); 

	for(var i = 1; i < nDivisions; i++){	
		if (document.getElementById("divNavLeft"+i) != null)
			document.getElementById("divNavLeft"+i).style.visibility = "hidden";}

}
/* --------- SETTING BACKGROUND IMG -------- */
function loadBgImages(img){
		document.body.background = aBgImages[img].src;
}

/* --------- Reload Page -------- */
/* Functionality:
		1. Refresh from the Page 
		2. Function must be called in the body tag of the page with command onLoad		
*/
function refreshPage(){

  reload();
}

/* --------- Load a specific page afer autorizaded login or changing the roles -------- */
/* Functionality:
		1. display page 1 or page 9 from the menu 7
*/
function setPage(){

	if ((parent.nNavTopSelected == 7)&&(parent.nNavLeftSelected != "")) {
		var num=parent.nNavLeftSelected.slice(2,3);
		parent.MouseClick(7,num,0);
	} else {
		parent.MouseClick(7,1,0);
	}

}
/* --------- Pop up a new window  -------- */
/* Functionality:
		1. Pop up a new window
*/
function popupWindow(webpage) {
	popup = window.open
		(webpage, "popupWindow", "status=yes,width=400,height=400,resizable=1,scrollbars=1");
	if (popup != null) {
		if (popup.opener == null) {
			popup.opener = self;
		}
	}
}
//======================================================================================================================


/* --------- Navigation HTML - Funktions -------- */

/* --------- Navigation Menu MouseOver -------- */
/* Functionality:
		1. Display the division ("NavLeft"+nNavID) assigned to the parentObject ("NavTop"+nID)
		2. Params: 	nID 			->  ID from the NavTop-Object or from the DivNavLeft-Object
								nNavID		->	ID from the NavLeft-Object		
*/

function MouseOver(nID,nNavID){

	showMenu(nID);

}
/* --------- Navigation Menu MouseClick -------- */
/* Functionality:
		1. Set the division ("NavLeft"+nNavID) assigned to the parentObject (NavTop)
		2. Display the content page ("page"+nID+"-"+nNavID) assigned to the NavLeft-Object
		3. Display the info page ("info"+"-"+nInfoID) 
		4. Params: 	nID 			->  ID from the NavTop-Object or from the DivNavLeft-Object
								nNavID		->	ID from the NavLeft-Object
								nInfoID		->	ID from the Info-Page		
*/
function MouseClick(nID,nNavID,nInfoID){

	nDivSelected  = "";	
	if (nID != nNavTopSelected){
		hideMenu(nNavTopSelected);
		setMenu(nID);
	}	

	if (nNavID != "0"){
		hideSubMenu(nNavLeftSelected);
		setSubMenu(nID,nNavID);
	}
	showMenu(nID);

	showPages(nID,nNavID,nInfoID);

}
function MouseOut(nID){

	if (nID != nNavTopSelected)	hideMenu(nID);

}


/* --------- Navigation JS - Funktions -------- */

/* --------- Navigation showMenu --------- */
/* Functionality:
		1. Set the level (zindex) of the division to the top-level
		2. Show the division from the parentObject if the division exists
		3. Make the over-objects from the top-navigation as choosen-objects 
		4. Hide temporaly the selected division		
*/

function showMenu(nID){

	if (document.getElementById("divNavLeft"+nID) != null) {
	
		var sNavTop   	= "navTop" + nID;
		var sDivName 	 	= "divNavLeft" + nID;
		nIndex++;

		document.getElementById(sDivName).style.zIndex 	    = nIndex;
		document.getElementById(sDivName).style.visibility 	= "visible";

		if (document.getElementById(sNavTop).className == "navtopnormal")
			document.getElementById(sNavTop).className = "navtopchoosen";

		if ((nNavTopSelected != nID)&&(nNavTopSelected != "")) {
			var sDivName 	 	= "divNavLeft" + nNavTopSelected;
			nDivSelected    	= nNavTopSelected;
			document.getElementById(sDivName).style.visibility 	= "hidden";
		}
	}
}

/* --------- Navigation hideMenu --------- */
/* Functionality:
		1. Hide the left-navigation-division from the over-object (nID)
		2. If a other object from the top-navigation is selected (clicked), 
			 display his left-navigation-division again
		3. Make the over-object from the top-navigation as normal-object with stylesheet
		2. Params: 	nID 			->  ID from the top-navigation-Object 		
*/
function hideMenu(nID){

	if (document.getElementById("divNavLeft"+nID) != null){

		var sDivName 	 	= "divNavLeft" + nID;
		document.getElementById(sDivName).style.visibility 	= "hidden";
		
		if ((nDivSelected != nID) || (nDivSelected != "")){
			if (document.getElementById("divNavLeft"+nDivSelected) != null){
				sDivName      = "divNavLeft" + nDivSelected;
				document.getElementById(sDivName).style.visibility 	= "visible";
				nDivSelected = nEmpty;
			}
		}
	}

	if (document.getElementById("NavTop"+nID) != null){
	
		var sNavTop   	= "navTop" + nID;
		if (document.getElementById(sNavTop).className != "navtopnormal")
			document.getElementById(sNavTop).className = "navtopnormal";
	}
}

/* --------- Navigation hideSubMenu --------- */
/* Functionality:
		1. Make the over-object from the left-navigation as normal-object 		
		2. Params: 	nIDnNavID		->	ID from the left-navigation-object (sub-chapter num)
*/
function hideSubMenu(nIDnNavID){

	if (document.getElementById("navLeft" + nIDnNavID) != null){

		var sNavLeft 	 	= "navLeft" + nIDnNavID;
		
		if (document.getElementById(sNavLeft).className != "navleftnormal")
			document.getElementById(sNavLeft).className = "navleftnormal";
	}
}

/* --------- Navigation setMenu --------- */
/* Functionality:
		1. Set the over-object from the top-navigation as selected-object 		
		2. Set the variable nNavTopSelected to the selected-object ID
		3. Params: 	nID 			->  ID from the top-navigation-object
*/
function setMenu(nID){

	if (document.getElementById("navTop"+nID) != null){

		var sNavTop 	= "navTop" + nID;
		if (document.getElementById(sNavTop).className != "navtopselected")
			document.getElementById(sNavTop).className = "navtopselected";
		nNavTopSelected = nID;	
	}
}

/* --------- Navigation setSubMenu --------- */
/* Functionality:
		1. Set the over-object from the left-navigation as selected-object 		
		2. Set the variable nNavLeftSelected to the selected-object ID 		
		3. Params: 	nID 			->  ID from the top-navigation-object
								nNavID		->	ID from the left-navigation-object
*/
function setSubMenu(nID,nNavID){

	if (document.getElementById("navLeft" + nID + "-" + nNavID) != null){

		var sNavLeft 	= "navLeft" + nID + "-" + nNavID;
		if (document.getElementById(sNavLeft).className == "navleftnormal")
			document.getElementById(sNavLeft).className = "navleftselected";
		nNavLeftSelected = nID + "-" + nNavID;	
	}
}

/* --------- Navigation showPage --------- */
/* Functionality:
		1. Load the pages in the frames 		
		2. Params: 	nID 			->  ID from the top-navigation-object
								nNavID		->	ID from the left-navigation-object
								nInfoID		->	ID from the Info-Page		
*/
function showPages(nID,nNavID,nInfoID){

		document.getElementById("content_frame").src = "page" + nID + "-" + nNavID + ".htm";
		document.getElementById("info_frame").src    = "info" + "-" + nInfoID + ".htm";
		
}

/* --------- Function for Links GetContent --------- */
/* Functionality:
		1. Load the page in the frame "content_frame" 		
		2. Params: sPageName 	->  complete name of the page with extension (ex:"pagexx.htm")
*/
function GetContent(sPageName){

		parent.document.getElementById("content_frame").src = sPageName;
}
/* --------- Function for Links GetInfo --------- */
/* Functionality:
		1. Load the page in the frame "content_info" 
		2. Params: sPageName 	->  complete name of the page with extension (ex:"infoxx.htm")
*/
function GetInfo(sPageName){

		parent.parent.document.getElementById("info_frame").src = sPageName;
}

//======================================================================================================================
/* --------- PAGE REPORTS & OTHER PAGES - Funktions -------- */

/* --------- HELP-COMMENTS VISIBLE -------- */
/* Functionality:
		1. Display the division ("divHelp"+nID) assigned to the parent-object ("obj-"+nID)
		2. Params: 	nID 			->  ID from the parent object 		
*/
	function showHelp(nID){

		var sDivName 	 		= "divHelp-" + nID;
		var sParentObj 		= "obj-" + nID;

		var nposLeft 	= getPosLeft(document.getElementById(sParentObj)) - 160;
		var nposTop  	= getPosTop(document.getElementById(sParentObj))  + 10

		document.getElementById(sDivName).style.zIndex 	    = 99;
		document.getElementById(sDivName).style.left 				= nposLeft;
		document.getElementById(sDivName).style.top 				= nposTop;
		
		document.getElementById(sDivName).style.visibility 	= "visible";
  
	}
/* --------- REPORT COMMENTS HIDDEN -------- */
/* Functionality:
		1. Hidde the division ("divHelp"+nID) assigned to the parent-object ("obj-"+nID)
		2. Params: 	nID 			->  ID from the parent-object 		
*/
	function hideHelp(nID){
	
		var sDivName 	 	= "divHelp-" + nID;
		document.getElementById(sDivName).style.visibility 	= "hidden";
	}
	
	
//======================================================================================================================
/* ---------  Funktions -------- */
	
	function getPosLeft(obj){
	
		if (!obj) return 0; 
		var posLeft = document.body.scrollLeft;
		while (obj.offsetParent){
			posLeft += obj.offsetLeft;
			obj = obj.offsetParent;}
		return posLeft;
	}
	function getPosTop(obj){
	
		if (!obj) return 0; 
		var posTop = document.body.scrollTop;
		while (obj.offsetParent){
			posTop += obj.offsetTop;
			obj = obj.offsetParent;}
		if (document.body.scrollTop > 0) posTop = posTop - document.body.scrollTop;	
		return posTop;
	}	
//======================================================================================================================
	
