/******************************************************************************
Copyright (C) Matteo Lucarelli - matteo@matteolucarelli.net
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
//---------------------------EDIT-SECTION--------------------------------------
// the common part of all links in menu (the base url location)
var basepath = 'http://www.matteolucarelli.net/javascript/dynaMenu/';
// these are the menu items
var name=new Array("page1","page2","page3");
// these are the menu links (used as basepath+path[i])
var path=new Array("testpage1.htm","testpage2.htm","testpage3.htm");
//-----------------------------------------------------------------------------
// return the index in menu of the currently loaded page
function actualid(){
ret=-1;
for (i=0;i<name.length;i++){
if ( document.location == basepath+path[i] ){
ret=i;
break;
}
}
return ret;
}
// this built-up the menu in form of HTML list-items
function addMenu(){
ai=actualid();
document.writeln('<ul>');
for (i=0;i<name.length;i++){
if ( i==ai ) {
document.writeln('<li id="selected">'+name[i]+'</li>');
}else{
document.writeln('<li><a href="'+basepath+path[i]+'">'+name[i]+'</a></li>');
}
}
document.writeln('</ul>');
}