
  //---------------------------------domready functions ------------------
 var w3c=(document.getElementById)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns4=(document.layers)?true:false;

function $(id){
 //var el= document.getElementById(id);
 //return el;
   if(ns4)return findLayer(id,parent.navigatie.document);
   else return (ie4)?parent.navigatie.document.all[id]:parent.navigatie.document.getElementById(id);
}

function setStyles(element,styles){
        for (var st in styles) {
          element.style[st]=styles[st];
        }
}

var oldStyle=true;
var currentPage=null;
var founditem=null;
var selectedParent=null;
var headcolor='#F73030'; /*'#EF3030';*/
var menuItems=[];
menuItems.push([0,0,'Wie zijn we','wiezijnwe.php']);
menuItems.push([0,1,'Harmonie','harmonie.php']);
menuItems.push([0,2,'Slagwerkgroep','slagwerkgroep.php']);
menuItems.push([0,3,'OpleidingsOrkest','opleidingsorkest.php']);
menuItems.push([0,4,'Stichting Begunstigers','stichting.php']);
/*
menuItems.push([1,0,'75-jarig Jubileum','jubileum.php']);
menuItems.push([1,1,'De activiteiten','jubileumitems.php']);
menuItems.push([1,1,'Ons Jubileumboek','jubileumboek.php']);
menuItems.push([1,2,'Sponsors','sponsors.php']);
*/
menuItems.push([2,0,'Onze Muziek','onzemuziek.php']);
menuItems.push([2,1,'Repertoire','repertoire.php']);
menuItems.push([2,2,'Bibliotheek','bibliotheek.php']);
menuItems.push([3,0,'Optredens','optredens.php']);
menuItems.push([3,1,'Agenda','agenda.php']);
menuItems.push([3,1,'Kalender','kalender.php']);
menuItems.push([3,2,'Foto Album','fotoalbum.php']);
menuItems.push([4,0,'Nieuws','nieuws.php']);
menuItems.push([4,1,'Bazuin','bazuin.php']);
menuItems.push([5,0,'Informatie','informatie.php']);
menuItems.push([5,1,'Repetities','repetities.php']);
menuItems.push([5,2,'Vacatures','vacatures.php']);
menuItems.push([5,3,'Links','links.php']);
//var menuTypes=[];

function showStart(obj,file){
//alert(obj.document);
  obj.document.html=file;
}
     /*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
@end @*/

function setStartPage(currentwindow){
  var url=currentwindow.document.URL;
  var arr=url.split('/');
  var pagename=arr[arr.length-1];
  var urlpage= 'tools/saveSettings.php?currentpage='+pagename;
   var xmlhttp = new XMLHttpRequest();
   xmlhttp.open("GET", urlpage,true);//method, target, async (set always true!)
   xmlhttp.onreadystatechange=function() {
           if (xmlhttp.readyState==4) {
               var txt= xmlhttp.responseText;
               if (txt) alert('Als start-pagina is geregistreerd: '+txt);
            }
       }
   xmlhttp.send(null);
}
function setPage(filenm,extra){
      var url;
      if (filenm.indexOf('.php')>0 || filenm.indexOf('.htm')>0 || filenm.indexOf('.html')>0) {
         url = filenm;
      } else {
        url = filenm+".php";
      }
      if (extra) url+='?'+extra;
     parent.main.location=url;
  }

  /*
function saveLastPage(){
  var urlpage= 'saveSettings.php?currentpage='+currentPage;
   var xmlhttp = new XMLHttpRequest();
   xmlhttp.open("GET", urlpage,true);//method, target, async (set always true!)
   xmlhttp.send(null);
 }
 */
function createMenu(){
 if (oldStyle){
    createMenuOld();
 } else {
    //createMenuNew();
 }
}
/*
function createMenuNew(){
         var kopfound=false;
         var html='';
        for (var i=0;i<menuItems.length;i++){
           var item=menuItems[i];
             if (item[1]===0){
                if (kopfound){
                   html +='</ul>';
                }
                html +='<ul id="'+item[0]+'"';
                html +=' onMouseOver=expandMenu("'+item[0]+'")>';
                 
                kopfound=true;
                if (item[3]>''){
                   html +='<div id="'+item[3]+'" class="head" onMouseDown=parent.setPage("'+item[3]+'")>';
                  // html +=' onMouseOver=expandMenu("'+item[0]+'")>';
                   html += item[2]+'</div>';
                } else {
                   html +='<div class="head">'+item[2]+'</div>';
                }
             } else {
                if (item[3]>''){
                   html +='<ol id="'+item[3]+'" onMouseDown=parent.setPage("'+item[3]+'")';
                   html +=' onMouseOver=expandMenu("'+item[0]+'")>';
                   html += item[2]+'</ol>';
                } else {
                  html +='<ol>'+item[2]+'</ol>';
                }
             }
         };
         if (kopfound){
            html +='</ul>';
         }
        // menuTypes.push(html);
         $('menu').innerHTML=html; //menuTypes[0];
        if (currentPage) updateLeftMenu(currentPage);
}

*/
function selectMenuItem(filename){
         var index=-1;
         var it=null;
        for (var i=0;i<menuItems.length;i++){
             var item=menuItems[i];
            for (var j=0;j<item.length;j++){
                if (item[j]==filename){
                  it=item;
                }
             }
         };
         return it;
}

function parentMenuItem(menunr){
         var it=null;
         for (var i=0;i<menuItems.length;i++){
           var item=menuItems[i];
       
             if (item[0]==menunr && item[1]==0){
                 it= item;
             }
         };
         return it;
}

function updateLeftMenu(filenm){
         currentPage=filenm;
         founditem=selectMenuItem(currentPage);
         selectedParent=parentMenuItem(founditem[0]); //<ul>
         if (founditem && $(founditem[3])){
                 var el=$(founditem[3]);
                 for (var i=0;i<menuItems.length;i++){
                     var item=menuItems[i];
                     if (!oldStyle){
                        setStyles($(item[3]),{'height':'auto','visibility':'visible','paddingBottom': '3px','paddingLeft':'','color': ''});
                        if (founditem==item){
                            if (founditem[1]==0){ //nieuwe selectie van hoofdingang
                               el.style.color=headcolor; //met referentie
                            } else {
                                setStyles(el,{'paddingLeft':'10px','color':'yellow'});
                            }
                         } else {
                           if (item[1]>0  && (selectedParent[0] != item[0]) ){
                             setStyles($(item[3]),{'height':'0px','visibility':'hidden','paddingBottom': '0'});
                           }
                 
                           if (item[1]==0  && (selectedParent[0] != item[0])){
                               $(item[0]).style.height='24px';//van de <ul>
                               $(item[3]).style.color= '';   //van de <div header>
                            }
                         }
                      } else { //oldStyle
                         $(item[3]).style.color=''; //reset
                         if (founditem==item){
                            if (founditem[1]==0){ //nieuwe selectie van hoofdingang
                               el.style.color=headcolor; //met referentie
                            } else {
                                el.style.color='yellow';
                            }
                         }
                      }
                 };
                 if (selectedParent && $(selectedParent[3])){
                   $(selectedParent[3]).style.color=headcolor;
                   if (!oldStyle){
                      $(selectedParent[0]).style.height='auto';
                   }
                 }
                 //saveLastPage();
        }
}

/*
function expandMenu(topitemid){
   if (founditem ){
      for (var i=0;i<menuItems.length;i++){
              var item=menuItems[i];
              if (item[1]>0  && (selectedParent && selectedParent[0] != item[0]) ){
                   setStyles($(item[3]),{'height':'0px','visibility':'hidden','paddingBottom': '0'});
              }
              if ((item[1]>0) && (topitemid==item[0])){
                  if (item[0] != founditem[0]){
                    setStyles($(item[3]),{'height':'auto','visibility':'visible','paddingBottom': '3px','paddingLeft':'','color': ''});
                  }
               }

     };
     $(topitemid).style.height='auto';  //van de <ul>
   }
}
*/
function setOldStyle(){
   oldStyle=true;
}

function createMenuOld(){
        var html='<table cellpadding="0" cellspacing="0" border="0" >';
        for (var i=0;i<menuItems.length;i++){
           var item=menuItems[i];
             if (item[1]==0){
                html +='<tr >';
                if (item[3]>''){
                   html +='<td id="'+item[3]+'" class="head"  onMouseDown=parent.setPage("'+item[3]+'") onMouseOver=parent.hoverHead("'+item[3]+'") onMouseOut=parent.reset("'+item[3]+'")>';
                   html += item[2]+'</td>';
                } else {
                   html +='<td class="head">'+item[2]+'</td>';
                }
                html +='</tr><tr ><td>';
                html += insertSubmenu(item[0]);
                html += '</td></tr>';
             }
         };
         html += '</table>';
          $('menu').innerHTML=html;//menuTypes[0];
}

function insertSubmenu(topitemnr){
      var html='<table class="sub" cellpadding="0" cellspacing="0" border="0" >';
      for (var i=0;i<menuItems.length;i++){
           var item=menuItems[i];
           if (item[0]==topitemnr && item[1]>0){
               if (item[3]>''){
                   html +='<tr><td id="'+item[3]+'" class="sub" onMouseDown=parent.setPage("'+item[3]+'") onMouseOver=parent.hover("'+item[3]+'") onMouseOut=parent.reset("'+item[3]+'")>';
                   html += item[2]+'</td></tr>';
                } else {
                  html +='<tr><td>'+item[2]+'</td></tr>';
                }
           }
       }
       html +='</table>';
       return html;
}

function hoverHead(id){
     $(id).style.color=headcolor;

}
function hover(id){
     $(id).style.color='yellow';

}
function reset(id){
   if(selectedParent && (selectedParent[3] != id) && (founditem && founditem[3] !=id)  )
     $(id).style.color='';
}