﻿/**

* CSShiarchMenu v0.3

*        written by: me[AT]daantje[DOT]nl

*        last update: Sun May 29 13:04:00 CEST 2005

*

*        Documentation:

*                Build this small script cause all the gpl-ed scripts I found where too big

*                and had too many options I never going to use, or the config for the menu

*                was not easy to set with a PHP routine.

*

*        License:

*                Use this script any way you like...

*/



//declare

var submenu = new Array();

var tmr = new Array();

var adj = new Array();

var last_zIndex = 10000;

var lastOverId = '';



// EXAMPLE CONFIG

var menuWidth                 = 250;                        //width of submenu in pixels

var alignSubmenu         = 'bottom';                //bottom or right side of the main button.

var useLastItemCSS        = true;                        //generate last menu item too

                                                                        //if false, it will behave as a normal item

                                                                        //and the css menuItemLast class will not be used



//fisrt submenu tree

submenu['menu1'] = new Array();

submenu['menu1'][0] = menuItem('Informacja o Parafii','../onas.htm','_self');

submenu['menu1'][1] = menuItem('Historia Parafii','../historia/historia_start.html','_self');

submenu['menu1'][2] = menuItem('Kontakt','../kontakt.htm','_self');



submenu['menu2'] = new Array();

submenu['menu2'][0] = menuItem('Zapowiedzi','../zapowiedzi.htm','_self');

submenu['menu2'][1] = menuItem('Śluby','../sluby.htm','_self');

submenu['menu2'][2] = menuItem('Chrzty','../chrzty.htm','_self');

submenu['menu2'][3] = menuItem('Pożegnalismy','../zgony.htm','_self');

submenu['menu2'][4] = menuItem('Historia Ogłoszeń','../ogloszenia.htm','_self');



submenu['menu3'] = new Array();

submenu['menu3'][0] = menuItem('Akcja Katolicka','../akcjakatolicka.html','_self');

submenu['menu3'][1] = menuItem('Apostolstwo modlitwy pw. św. Faustyny','../apostolstwo_msfk.html','_self');

submenu['menu3'][2] = menuItem('Domowy Kosciół','../domowykosciol.html','_self');

submenu['menu3'][3] = menuItem('Liturgiczna Służba Ołtarza','../liturgicznasluzbaoltarza.html','_self');

submenu['menu3'][4] = menuItem('Klub Honorowych Dawców Krwi','../khdk/khdk.html','_self');

submenu['menu3'][5] = menuItem('Koło Przyjaciół Radia Maryja','../kprm.html','_self');

submenu['menu3'][6] = menuItem('Oaza Dzieci Bożych','../oaza.html','_self');

submenu['menu3'][7] = menuItem('Oaza Młodzieżowa','../oaza_mlodziezy.html','_self');

submenu['menu3'][8] = menuItem('Odnowa w Duchu Świętym','../odnowawduchuswietym.html','_self');

submenu['menu3'][9] = menuItem('Parafialny Zespół Caritas','../caritas/caritas.html','_self');

submenu['menu3'][10] = menuItem('Poradnictwo Rodzinne','../poradnictworodzinne.html','_self');

submenu['menu3'][11] = menuItem('Przyjaciele Paradyża','../pparadyza.html','_self');

submenu['menu3'][12] = menuItem('Punkt Społeczno-Prawno-Konsultacyjny','../punktspk.html','_self');

submenu['menu3'][13] = menuItem('Rada Parafialna','../radaparafialna.html','_self');

submenu['menu3'][14] = menuItem('Różaniec Rodziców','../rozaniec.html','_self');

submenu['menu3'][15] = menuItem('Sportowy Klub Parafialny','../klubsportowy.html','_self');

submenu['menu3'][16] = menuItem('Stowarzyszenie Przyjaciół Kisielina','../spk/spk.html','_self');

submenu['menu3'][17] = menuItem('Świetlica Opiekuńczo-Wychowawcza','../sst.html','_self');

submenu['menu3'][18] = menuItem('Żywy Różaniec','../zrozaniec.html','_self');


submenu['menu4'] = new Array();

submenu['menu4'][0] = menuItem('Galeria - archiwum','../galeria/galeria.php','_self');


submenu['menu5'] = new Array();

submenu['menu5'][0] = menuItem('2011','','_blank');
submenu['menu5'][1] = menuItem('2010','','_blank');
submenu['menu5'][2] = menuItem('2009','','_blank');
submenu['menu5'][3] = menuItem('2008','','_blank');
submenu['menu5'][4] = menuItem('2007','','_blank');
submenu['menu5'][5] = menuItem('2006','','_blank');
submenu['menu5'][6] = menuItem('2005','','_blank');

submenu['menu9'] = new Array();

submenu['menu9'][0] = menuItem('1352 - 1985','../historia/historia_s1.html','_self');

submenu['menu9'][1] = menuItem('1986 - 2005','../historia/historia_s2.html','_self');

submenu['menu9'][2] = menuItem('2005 - 2007','../historia/historia_s3.html','_self');

submenu['menu9'][3] = menuItem('2008','../historia/historia_s4.html','_self');

submenu['menu9'][4] = menuItem('2009','../historia/historia_s5.html','_self');

submenu['menu9'][5] = menuItem('2010','../historia/historia_s6.html','_self');

submenu['menu9'][6] = menuItem('2011','../historia/historia_s7.html','_self');

// END OF EXAMPLE CONFIG





//build or unhide submenu div...

function buildSubmenu(obj){



        lastOverId = obj.id;

        //get common part of div id

        menuPath = obj.id.split('_');
        str = obj.id.substring(0,5);
// test
 
 if(str == 'menu9'){

		alignSubmenu = 'Right';

   document['fpAnimswapImgFPx'].src='pliki/hp_menu3.gif';
      
                        }else{

    		alignSubmenu = 'bottom';
	}


        //unset mousout of parent menus and make sure they are visible...

        x = "div";

        for(i=0;i<menuPath.length;i++){

                x+= '_' + menuPath[i];

                if(document.getElementById(x)){

                        if(tmr[x])

                                window.clearTimeout(tmr[x]);

                        document.getElementById(x).style.visibility = 'visible';

                }

        }



        //check if we have a submenu of the obj...

        if(submenu[obj.id]){

                //check if allready build...

                c = document.getElementById('div_' + obj.id);

                if(c){

                        //unhide...
	
                        c.style.visibility = 'visible';

                        c.style.zIndex = last_zIndex++;


                }else{

                        //calc position of mouseover

                        d = obj;

                        if(d){

                                L_pos = d.offsetLeft + d.offsetWidth - 1;

                                T_pos = d.offsetTop - 1;

                                while(d.offsetParent){

                                        d = d.offsetParent;

                                        L_pos+= d.offsetLeft;

                                        T_pos+= d.offsetTop;

                                }

                        }



                        //patch first submenu to go right below the main buttons...

                        if(obj.className.indexOf('menuItem') < 0 && alignSubmenu == 'bottom'){

                                L_pos-= obj.offsetWidth-1;

                                T_pos+= obj.offsetHeight+10;
			
		}


                        //build new div

                        subObj = document.createElement('div');

                        subObj.id = 'div_' + obj.id;

                        subObj.className = 'submenu';

                        subObj.style.position = 'absolute';

                        subObj.style.zIndex = last_zIndex++;

                        //subObj.style.width = menuWidth;

	          str = obj.id.substring(0,5);

 if(str == 'menu9'){

	    subObj.style.top = T_pos+10;
                  subObj.style.left = L_pos;
	 	    }else{
	          subObj.style.top = T_pos;
                        subObj.style.left = L_pos;
	      		}


                        //write div to the body...

                        document.getElementsByTagName('body')[0].appendChild(subObj);



                        //build html for submenu

                        content = "";

                        m = submenu[obj.id];

                        for(i=0;i<m.length;i++){



                                //determin target for onclick...

                                //        (sorry, I should rewrite this routine...)

                                if(!m[i][2] || m[i][2] == '_self'){

                                        act = "self.location.href='" + m[i][1] + "';";

                                }else if(m[i][2] == '_top'){

                                        act = "top.location.href='" + m[i][1] + "';";

                                }else if(m[i][2] == '_blank'){

                    act = "window.open('" + m[i][1] + "');";

                                }else{

                                        //get javascript target (not tested yet)

                                        //TODO: check how to do this cleanly

                                        act = "window.frames['"+m[i][2]+"'].location.href='" + m[i][1] + "';";

                                }



                                //make item

                                content+= "<div onmouseout=\"hideSubmenu(this)\" onmouseover=\"buildSubmenu(this)\" "+ (m[i][1] ? "onclick=\""+ act + "\" " : "") +"class=menuItem" + (i==0 ? 'First' : (i==(m.length -1) && useLastItemCSS ? 'Last' : '')) + " id=\"" + obj.id + "_" + i +"\">" + m[i][0] + "</div>";

                                adj[i] = obj.id + "_" + i;

                        }



                        //insert new menu

                        subObj.innerHTML = content;

                        //make all just made div's the same width...
			
                        for(i=0;i<adj.length;i++)

	document.getElementById(adj[i]).style.width = subObj.style.width;


                }

        }

}



//hide a submebu div

function hideSubmenu(obj){

        //get common part of div id

        closePath = obj.id.split('_');

 str = obj.id.substring(0,5);

        //hide path

        x = "div";

        for(i=0;i<closePath.length;i++){

                x+= '_' + closePath[i];

                if(document.getElementById(x))

                        tmr[x] = window.setTimeout("document.getElementById('"+x+"').style.visibility = 'hidden';",150);

// test
 if(str == 'menu9'){
   document['fpAnimswapImgFPx'].src='pliki/hp_menu0.gif'; 
		}

                //The timeout above is needed for MSIE browsers... Or else the menu's will disapear on EVERY mousout!!!

                //Please get a normal browser like Firefox, Mozilla or Opera!!

        }

}



//add an menu item to the config array (called in the config lines)

function menuItem(txt,url,tar){

        return new Array(txt,url,tar);

}



//*** Patch for firefox bug with focus on mouseover...

//                This function should be called onMouseOver of every iFrame that's under the menu structure.

function iFramePatch(){

        if(!document.all && lastOverId)

                hideSubmenu(document.getElementById(lastOverId));

}



//*** Now a patch for MSIE lag of CSS2 compliance!!

if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')==-1){

        document.onmouseover = function(){

                obj = event.srcElement;

                if(obj.className == 'menuItemFirst' || obj.className == 'menuItem' || obj.className == 'menuItemLast')

                        obj.className+='Over';

        }

        document.onmouseout = function(){

                obj = event.srcElement;

                if(obj.className == 'menuItemFirstOver' || obj.className == 'menuItemOver' || obj.className == 'menuItemLastOver')

                        obj.className = obj.className.substring(0,(obj.className.length - 4));

        }

}

//*** End of msie patch

