 // ***************************************************************
 // Name:             Web & Safety GmbH, Rita Joller
 // Date:             Sept. 2006
 // JavaScript File:  navigation.js
 // Description :     menu navigation of the website unterbözberg
 // ***************************************************************
 //
 //----------
 //  menu
 //----------
 // 1.	name of the menu
 // 2.	name of the menu-site for a link (.htm)
 


 var menu=new Array();

 // lime menu

 menu[0]=new Array("Portrait","portrait.htm");
 menu[1]=new Array("Verwaltung","verwaltung.htm");
 menu[2]=new Array("Behörden","behoerden.htm");
 menu[3]=new Array("SBB Tageskarte","sbbTageskarte.htm");

 // menu

 menu[4]=new Array("Bauwesen","bauwesen.htm");
 menu[5]=new Array("Familien- wappen","familienwappen.htm");
 menu[6]=new Array("Entsorgung","entsorgung.htm");
 menu[7]=new Array("Feuerwehr","feuerwehr.htm");
 menu[8]=new Array("Links","links.htm");
 menu[9]=new Array("Mitteilungen","mitteilungen.htm");
 menu[10]=new Array("Ortsplan","ortsplan_Unterboezberg.pdf");
 menu[11]=new Array("Schule","schule.htm");
 menu[12]=new Array("Vereine","vereine.htm");
 menu[13]=new Array("Von A-Z","info.htm");
 menu[14]=new Array("Wasser- versorgung","wasserversorgung.htm");   

 //-----------------
 // variables intro
 //-----------------

 var topIntroLime1=208;                 // Intro top position lime menu prompt 1
 var topIntroLime2=447;                 // Intro top position lime menu prompt 2
 var topIntroLime3=307;                 // Intro top position lime menu prompt 3
 var topIntroLime4=400;                 // Intro top position lime menu prompt 4
 var topIntro=180;                      // Intro top start position menu prompts

 var leftIntroLime1=485;                // Intro left position lime menu prompt 1
 var leftIntroLime2=210;                // Intro left position lime menu prompt 2
 var leftIntroLime3=95;                 // Intro left position lime menu prompt 3
 var leftIntroLime4=490;                 // Intro left position lime menu prompt 4
 var leftIntro=652;                     // Intro left start position menu prompts

 //----------------------
 // variables second site
 //----------------------

 var topLime=108;                       // top start position lime menu prompts
 var top=214;                           // top start position menu prompts
 var leftLime=5;                        // left position lime menu prompts
 var left=10;                           // left position menu prompts
 var distance_lime=15;				// distance between lime menu prompts

 //-----------
 // variables
 //-----------

 var distance_menu=0;				// distance between menu prompts
 var maxLength=12;					// max. length menu prompts to show in one line

 var resizedX=0;                        // calculate windows size minus intro image size
 var imgWidthStart=775;  			// width of intro start image

 var menuWidth=0;                           // all menu prompts same width
 var menuHeight=20,menuHeightDouble=35;	    // all menu prompts same height or double height

 var IEDiff=10;                         // position compensation Internet Explorer
 var mozzDiff=5;                        // position compensation Mozilla Firefox
 var shadowDiff=2;                      // shadow font

 var start_site=0;  				// 0 = start site index.htm / 1 = all links
 var startX=0;						// x start position menu prompts
 var startY=0;						// y start position menu prompts

 var posY=0;                            // top position of all menu prompts ( will be calculate)
 var posX=0;                            // left position of all menu prompts ( will be calculate)

 var targ="_self";					// _self = target for .htm file  /  _blank = target for .pdf file
 var mHref="";                          // pdf.file = "menu[i][1]"     / htm-file = "javascript:mlink("+i+")"

 leer=new Image();
 leer.src="./images/empty.gif";


 //-----------------------------------------------
 // function calculate new height (window-resize)
 //-----------------------------------------------

 function resized()
	{resizedX=0;
 	if (document.body.offsetWidth)
		if  (document.body.offsetWidth>=imgWidthStart)
     		resizedX=Math.round((document.body.offsetWidth-imgWidthStart)/2);

  	show_menu();
	}

//---------------------------
 // function link menu prompt
 //--------------------------

 function mlink(obj)
	{self.location.href=menu[obj][1];
	}

 //-----------------------------
 // function create menu prompt
 //-----------------------------

 function create_menu()
	{document.write('<link  rel="stylesheet" href="./css/unterboezberg.css" type="text/css">');
 	if (start_site==0)
		document.write('<body class="body_menu" onresize="resized()" onload="resized()">');
 	else
     	document.write('<body class="body_navi" onresize="resized()" onload="resized()">');

	document.write('<div id="main" style="position:absolute">');

	for(i=0;i<menu.length;i++)
		{if (menu[i][1].indexOf(".pdf")!=-1)
               {targ="_blank";
                mHref=menu[i][1];
               }
          else
          	if (menu[i][1].indexOf(".doc")!=-1)
               	{if (typeof(document.all)=='object')     // Internet Explorer
                       	{targ="_blank";
                		mHref=menu[i][1];
                         }
                    else                                    // Firefox,Netscape,Operas
                        	{targ="_self";
                         mHref=menu[i][1];
                         }
                    }
          else
          	{targ="_self";
                mHref="javascript:mlink("+i+")";
               }

          if (i>=0 && i<=3)
     		{
                document.write('<div id="menuShadow'+i+'"  style="position:absolute;visibility:hidden;height:'+menuHeight+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
           	document.write(mstring(i,false,1)+"</div>");
           	document.write('<div id="lmenuShadow'+i+'" style="position:absolute;height:'+menuHeight+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
              	document.write('<a href="'+mHref+'" target="'+targ+'" onclick="change_menu('+i+',1)" onmouseover="change_menu('+i+',1)" onmouseout="change_menu('+i+',0)"><img src="'+leer.src+'" border="0" width="'+menuWidth+'" height="'+menuHeight+'">');
     	 	document.write('</a></div>');
          	}

    		if (menu[i][0].length>maxLength && start_site == 1)
        		{document.write('<div id="menu'+i+'"  style="position:absolute;visibility:hidden;height:'+menuHeightDouble+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
                document.write(mstring(i,false,0)+"</div>");
                document.write('<div id="lmenu'+i+'" style="position:absolute;height:'+menuHeightDouble+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
                document.write('<a href="'+mHref+'"  target="'+targ+'" onclick="change_menu('+i+',1)" onmouseover="change_menu('+i+',1)" onmouseout="change_menu('+i+',0)"><img src="'+leer.src+'" border="0" width="'+menuWidth+'" height="'+menuHeightDouble+'">');
               }
          else
        		{document.write('<div id="menu'+i+'"  style="position:absolute;visibility:hidden;height:'+menuHeight+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
                document.write(mstring(i,false,0)+"</div>");
                document.write('<div id="lmenu'+i+'" style="position:absolute;height:'+menuHeight+';width:'+menuWidth+';top:'+posY+';left:'+startX+'">');
                document.write('<a href="'+mHref+'"  target="'+targ+'" onclick="change_menu('+i+',1)" onmouseover="change_menu('+i+',1)" onmouseout="change_menu('+i+',0)"><img src="'+leer.src+'" border="0" width="'+menuWidth+'" height="'+menuHeight+'">');
               }
     	document.write('</a></div>');
		}
	document.write( '</div>');
	}

 //-----------------------------------
// function set the height for Opera
//------------------------------------

 function setHeight()
	{for(i=0;i<menu.length;i++)
		{if  (menu[i][0].length>maxLength)
        		document.getElementById("menu"+i).style.height=menuHeightDouble;
     	else
        		document.getElementById("menu"+i).style.height=menuHeight;
     	}
	}

 //---------------------------
 // function show menu prompt
 //---------------------------

 function show_menu()
	{var counter=0;
	if (typeof(document.all)=='object')                  // only IE
		{for(i=0;i<menu.length;i++)
			{if(document.all["menu"+i])
                   {if (start_site == 0)            // intro index.htm
       				{if (i==0)
             				{posY=startL1Y;
              				startX=resizedX + leftIntroLime1 - IEDiff;
              				}
          			else if (i==1)
                  			{posY=startL2Y;
              	   		 	startX=resizedX + leftIntroLime2 - IEDiff;
              	   		 	}
         			 	else if (i==2)
                  			{posY=startL3Y;
              	   			startX=resizedX + leftIntroLime3 - IEDiff;
                            
                  			}
                        else if (i==3)
                              {posY=startL4Y;
                                 startX=resizedX + leftIntroLime4 - IEDiff;
                                 
                              }
          			else
                         	{posY=(i*menuHeight)+startY+(i*distance_menu);
          				startX=resizedX + leftIntro - IEDiff;
                              }
                         }
                    else
                    	{if (document.all["menu"+(i-1)])
                        		{if (document.all["menu"+(i-1)].style.height==menuHeightDouble+"px")
                          		counter++;
                        		}
                          if (i>=0 && i<=3)
                              {posY=(i*menuHeight)+topLime+(i*distance_lime)+counter*(menuHeightDouble-menuHeight);
                              startX=leftLime;
                              }
                          else
                              {posY=(i*menuHeight)+startY+(i*distance_menu)+counter*(menuHeightDouble-menuHeight);
                               startX=left;
                              }
                          }
                    if (i>=0 && i<=3)
                    	{if (document.all["menuShadow"+i])
                     		{document.all["menuShadow"+i].style.left=(startX+shadowDiff)+"px";
                         	document.all["menuShadow"+i].style.top=(posY+shadowDiff)+"px";
                         	}
                    	if (document.all["lmenuShadow"+i])
                     		{document.all["lmenuShadow"+i].style.left=(startX+shadowDiff)+"px";
                         	document.all["lmenuShadow"+i].style.top=(posY+shadowDiff)+"px";
                         	}
                    	document.all["menuShadow"+i].style.visibility="visible";
                         }
                    if (document.all["menu"+i])
                    	{document.all["menu"+i].style.left=startX+"px";
                         document.all["menu"+i].style.top=posY+"px";
                         }
                    if (document.all["lmenu"+i])
                    	{document.all["lmenu"+i].style.left=startX+"px";
                         document.all["lmenu"+i].style.top=posY+"px";
                         }
                    document.all["menu"+i].style.visibility="visible";
                    }
			}
		}
	else if(document.getElementById)                         	// Firefox, Netscape
		{for(i=0;i<menu.length;i++)
			{if(document.getElementById("menu"+i))
				{if (start_site == 0)            		// intro index.htm
       				{if (i==0)
             				{if (window.opera)
                                  posY=startL1Y;
                              else
                                  posY=startL1Y-mozzDiff;
              				startX=resizedX + leftIntroLime1;
              				}
          			else if (i==1)
                  			{if (window.opera)
                                  posY=startL2Y;
                              else
                                  posY=startL2Y-mozzDiff;
              	   		 	startX=resizedX + leftIntroLime2;
              	   		 	}
         			 	else if (i==2)
                  			{if (window.opera)
                                  posY=startL3Y;
                              else
                                  posY=startL3Y-mozzDiff;
              	   			startX=resizedX + leftIntroLime3;
                  			}
                        else if (i==3)
                              {if (window.opera)
                                  posY=startL4Y;
                              else
                                  posY=startL4Y-mozzDiff;
                                 startX=resizedX + leftIntroLime4;
                              }
          			else
          				{posY=(i*menuHeight)+startY+(i*distance_menu);
                              startX=resizedX + leftIntro;
                              }
                         }
                    else
                    	{if (document.getElementById("menu"+(i-1)))
                        		{if (document.getElementById("menu"+(i-1)).style.height==menuHeightDouble+"px")
                                   counter++;
                        		}
                          if (i>=0 && i<=3)
                              {posY=(i*menuHeight)+topLime+(i*distance_lime)+counter*(menuHeightDouble-menuHeight);
                              startX=leftLime;
                              }
                          else
                              {posY=(i*menuHeight)+startY+(i*distance_menu)+counter*(menuHeightDouble-menuHeight);
                               startX=left;
                              }
                         }
                    if (i>=0 && i<=3)
                    	{if (document.getElementById("menuShadow"+i))
                     		{document.getElementById("menuShadow"+i).style.left=(startX+shadowDiff)+"px";
                         	document.getElementById("menuShadow"+i).style.top=(posY+shadowDiff)+"px";
                         	}
                    	if (document.getElementById("lmenuShadow"+i))
                     		{document.getElementById("lmenuShadow"+i).style.left=(startX+shadowDiff)+"px";
                         	document.getElementById("lmenuShadow"+i).style.top=(posY+shadowDiff)+"px";
                         	}
                    	document.getElementById("menuShadow"+i).style.visibility="visible";
                         }
                    if (document.getElementById("menu"+i))
                     	{document.getElementById("menu"+i).style.left=startX+"px";
                         document.getElementById("menu"+i).style.top=posY+"px";
                         }
                    if (document.getElementById("lmenu"+i))
                     	{document.getElementById("lmenu"+i).style.left=startX+"px";
                         document.getElementById("lmenu"+i).style.top=posY+"px";
                         }
                    document.getElementById("menu"+i).style.visibility="visible";
				}
	    		}
          document.getElementById("main").focus();
          }
	}

 //---------------------------------------
 // function hoover effect in menu prompt
 //---------------------------------------

 function change_menu(mnr,state)
	{if(state==1)
		zustand=true
	else
    		zustand=false

	if (typeof(document.all)=='object')
			{if (document.all["menu"+mnr])
                    document.all["menu"+mnr].innerHTML=mstring(mnr,zustand,0);

               if (start_site == 1)
               	{url=unescape(self.location.href.replace(/\+/g," ")).split("/");
  				 site=url[url.length-1];
                     if (menu[mnr][1]== site)
                         if (document.all["menu"+mnr])
                            document.all["menu"+mnr].innerHTML=mstring(mnr,true,0);
                    }
			}
	else if (document.getElementById)
			{if (document.getElementById("menu"+mnr))
                    document.getElementById("menu"+mnr).innerHTML=mstring(mnr,zustand,0);

               if (start_site == 1)
               	{ url=unescape(self.location.href.replace(/\+/g," ")).split("/");
  			 	  site=url[url.length-1];
                      if (menu[mnr][1]== site)
                          {if  (document.getElementById("menu"+mnr))
                              document.getElementById("menu"+mnr).innerHTML=mstring(mnr,true,0);
                          }
                    }
			}
  	document.getElementById("main").focus();

	}

 //------------------------------------------------------------
 // function change text in hoover/normal state in menu prompt
 //------------------------------------------------------------


 function mstring(mnr,aktiv,shadow)
	{var menu_name=menu[mnr][0];

 	if (start_site==0)
  		{var mname=new Array();
     	 if (menu_name.indexOf("- ")!=-1)
      		{mname=menu_name.split("- ");
          	menu_name=mname[0].concat(mname[1]);
          	}
	 	if (aktiv)
   			{if (mnr>=0 && mnr<=3)
               	if (shadow)
                  		txt='<nobr><div><p class="menuActLimeShadow_intro">'+menu[mnr][0]+'</p></div></nobr>';
               	else
                 		txt='<nobr><div class="menu_outer"><p class="menuActLime_intro">'+menu[mnr][0]+'</p></div></nobr>';
          	else
      			txt='<nobr><div class="menu_outer"><p class="menuAct_intro">'+menu_name+'</p></div></nobr>';
          	}
	 	else
    			if (mnr>=0 && mnr<=3)
              		if (shadow)
                 		txt='<nobr><div><p class="menuNormLimeShadow_intro">'+menu[mnr][0]+'</p></div></nobr>';
              		else
                 		txt='<nobr><div class="menu_outer"><p class="menuNormLime_intro">'+menu[mnr][0]+'</p></div></nobr>';
    			else
       			txt='<nobr><div class="menu_outer"><p class="menuNorm_intro">'+menu_name+'</p></div></nobr>';
     	}
  	else
  		{if (window.opera)
     		{if (menu_name.indexOf(" ")!=-1 && menu_name.indexOf("- ")==-1)
              		{if (aktiv)
   		 	  	 	if (mnr>=0 && mnr<=3)
                          	if (shadow)
                             		txt='<nobr><div><p class="menuActLimeShadow">'+menu[mnr][0]+'</p></div></nobr>';
                          	else
                             		txt='<nobr><div><p class="menuActLime">'+menu[mnr][0]+'</p></div></nobr>';
                     	else
      	    				txt='<nobr><div><p class="menuAct">'+menu_name+'</p></div></nobr>';
			  	else
    		 	  	 	if (mnr>=0 && mnr<=3)
                         	if (shadow)
                             		txt='<nobr><div><p class="menuNormLimeShadow">'+menu[mnr][0]+'</p></div></nobr>';
                         	else
                             		txt='<nobr><div><p class="menuNormLime">'+menu[mnr][0]+'</p></div></nobr>';
                     	else
       	 				txt='<nobr><div><p class="menuNorm">'+menu_name+'</p></div></nobr>';
              		}
          	else
          		{if (aktiv)
   					if (mnr>=0 && mnr<=3)
                         	if (shadow)
                            		txt='<div><p class="menuActLimeShadow">'+menu[mnr][0]+'</p></div>';
                         	else
                            		txt='<div><p class="menuActLime">'+menu[mnr][0]+'</p></div>';
                    	else
      					txt='<div><p class="menuAct">'+menu_name+'</p></div>';
    				else
    	    				if (mnr>=0 && mnr<=3)
                         	if (shadow)
                             		txt='<div><p class="menuNormLimeShadow">'+menu[mnr][0]+'</p></div>';
                         	else
                             		txt='<div><p class="menuNormLime">'+menu[mnr][0]+'</p></div>';
                    	else
       					txt='<div><p class="menuNorm">'+menu_name+'</p></div>';
               	}
          }
     else
        	{if (aktiv)
   			if (mnr>=0 && mnr<=3)
				if (shadow)
                    	txt='<div><p class="menuActLimeShadow">'+menu[mnr][0]+'</p></div>';
                   	else
                      	txt='<div><p class="menuActLime">'+menu[mnr][0]+'</p></div>';
               else
      			txt='<div><p class="menuAct">'+menu_name+'</p></div>';
    		else
    	    		if (mnr>=0 && mnr<=3)
                    if (shadow)
                        	txt='<div><p class="menuNormLimeShadow">'+menu[mnr][0]+'</p></div>';
                    else
                       	txt='<div><p class="menuNormLime">'+menu[mnr][0]+'</p></div>';
               else
       			txt='<div><p class="menuNorm">'+menu_name+'</p></div>';
     	}
     }
	return txt;
	}

 //-------------------------
 // function initialization
 //-------------------------

 function ini()
	{url=unescape(self.location.href.replace(/\+/g," ")).split("/");
  	site=url[url.length-1].split(".");

  	if (site[0]=="index" || site[0]=="")    					// navigation start site
  		{start_site=0
     	menuWidth=180;
     	if (typeof(document.all)=='object')         	// Internet Explorer
     		{startY=topIntro-5;
               startL1Y=topIntroLime1-5;
               startL2Y=topIntroLime2-5;
               startL3Y=topIntroLime3-5;
               startL4Y=topIntroLime4-5;
               }
     	else
         		if (window.opera)        			// Opera
          		{startY=topIntro-10;
                     startL1Y=topIntroLime1-10;
                     startL2Y=topIntroLime2-10;
                     startL3Y=topIntroLime3-10;
                     startL4Y=topIntroLime4-10;
                    }
     		else
    	 			if (document.getElementById)       // Firefox u. Netscape
          			{startY=topIntro;
                         startL1Y=topIntroLime1;
                     	startL2Y=topIntroLime2;
                     	startL3Y=topIntroLime3;
                        startL4Y=topIntroLime4;
                     	}
     	}
  	else
     	{start_site=1                               	// navigation links
     	menuWidth=78;
     	if (typeof(document.all)=='object')        	// Internet Explorer
     		startY=top;
     	else
         		if (window.opera)        			// Opera
         			startY=top+5;
     		else
    	 			if (document.getElementById)       // Firefox u. Netscape
          			startY=top+3;
     	}
	if (document.layers)
		error_msg()
	}

 //------
 // start
 //------

    	ini();
    	create_menu();
