/*
HTMLElement Prototyping in KHTML and WebCore


if (navigator.vendor == "Apple Computer, Inc." || navigator.vendor == "KDE") { // WebCore/KHTML
	(function(c) {
		for (var i in c)
			window["HTML" + i + "Element"] = document.createElement(c[ i ]).constructor;
	})({
		Html: "html", Head: "head", Link: "link", Title: "title", Meta: "meta",
		Base: "base", IsIndex: "isindex", Style: "style", Body: "body", Form: "form",
		Select: "select", OptGroup: "optgroup", Option: "option", Input: "input",
		TextArea: "textarea", Button: "button", Label: "label", FieldSet: "fieldset",
		Legend: "legend", UList: "ul", OList: "ol", DList: "dl", Directory: "dir",
		Menu: "menu", LI: "li", Div: "div", Paragraph: "p", Heading: "h1", Quote: "q",
		Pre: "pre", BR: "br", BaseFont: "basefont", Font: "font", HR: "hr", Mod: "ins",
		Anchor: "a", Image: "img", Object: "object", Param: "param", Applet: "applet",
		Map: "map", Area: "area", Script: "script", Table: "table", TableCaption: "caption",
		TableCol: "col", TableSection: "tbody", TableRow: "tr", TableCell: "td",
		FrameSet: "frameset", Frame: "frame", IFrame: "iframe"
	});

	function HTMLElement() {}
	HTMLElement.prototype     = HTMLHtmlElement.__proto__.__proto__;	
	var HTMLDocument          = document.constructor;
	var HTMLCollection        = document.links.constructor;
	var HTMLOptionsCollection = document.createElement("select").options.constructor;
	var Text                  = document.createTextNode("").constructor;
	var Node                  = Text;
}
*/
////////////////////////////////////////////////////////////////////////////////////////////////////

//Function browser (Constructor)

function Browser() {
  var ua, s, i;
  this.isOP    = false;  // Opera
  this.isSA    = false;  // Safari
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Safari";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isSA = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}
var browser = new Browser();

///////////////////////////////////////////////////////////////////////////////////////////////////

//General Functions

// Define prototype click function to simulate user triggered click event.
var ie=document.all;
if ((!ie) || (browser.isSA==true) || (browser.isOP==true) )
{
HTMLElement.prototype.click = function() 
{
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////

// VARS
var lastOpenedMenuItem=-1;
var lastOpenedMenuItemId=-1;
var lastOpenedMenuSubItemRef=null;
var ignoreLastOpened=true;
var lastOpenedMenuItemIndexList=new Array();
var lastClicked=null;
var prevent=false;
var counter=0;

///////////////////////////////////////////////////////////////////////////////////////////////////


/// function controlMenu: controls menu LEVEL 1 /// 
  
function controlMenu(e){
 if (document.getElementById || document.all)
 {
    
 // Define cross browser Event object.
 var targ;
 if (!e) var e = window.event;
 if (e.target) targ = e.target;
 else if (e.srcElement) targ = e.srcElement;
 if (targ.nodeType == 3) // avoid Safari bug
 targ = targ.parentNode; //alert (targ.nodeType);
		
	
        
    // Open submenu and close active menu if necessary. 
    if (targ.id && (targ.id.indexOf('menuHeader')!=-1) )
    {
    var nextSib = findNextHtmlTag(targ); 
    var item=nextSib;	
		
     if (lastOpenedMenuItem!=-1 && lastOpenedMenuItemId!=item.id) 
     {
     lastOpenedMenuItem.style.display='none';
     }
     //end if
		 
     if (lastOpenedMenuItemIndexList.length>-1 && ignoreLastOpened==false)
     {
      while(lastOpenedMenuItemIndexList.length>0)
      {
      lastItem=lastOpenedMenuItemIndexList.pop();
      lastItem.style.display='none';
      }
      //end while
     }
     //end if
		
		
     // hide mainmenuitem if it is already open 
                
     if (item.style.display == '')
     {
     item.style.display = 'none'
     }
     //end if 
                
     // show mainmenuitem if it is closed 
     else 
     {
     item.style.display = ''
     if (ignoreLastOpened==false) {lastOpenedMenuItem=item;lastOpenedMenuItemId=item.id}
     else lastOpenedMenuItemIndexList[counter++]=item;
     }
     //end else
   }
   //end if 
 }
 //end if
}
//end fn controlMenu

////////////////////////////////////////////////////////////////////////////////////////////////////

// Attach event handler to document
document.onclick=controlMenu;

///////////////////////////////////////////////////////////////////////////////////////////////////


/// function controlMenuSubLevel: controls menu LEVEL 2 and switches CSS of selected subItems /// 

function controlMenuSubLevel(objRef){

// avoid Safari bug
if (objRef.nodeType == 3) 
objRef = objRef.parentNode; 
//alert (objRef.nodeType);


// CLEANUP LEVEL 1 if necessary (allNavOpen)

if ((lastOpenedMenuItemIndexList.length>0) && (navigator.vendor != "Apple Computer, Inc.") && (navigator.vendor != "KDE") && (browser.isOP!=true))
{
var x_object=findPreviousHtmlTag(objRef.parentNode.parentNode.parentNode)
x_object.click();
ignoreLastOpened=false;
}

// END CLEANUP

if (objRef.parentNode.status=='closed'||objRef.parentNode.status==null)
{
subRef=findNextHtmlTag(objRef);
subRef.style.display='';
objRef.parentNode.className='selected';
objRef.parentNode.onmouseover=function sublevelChangeClass(){objRef.parentNode.className = "selected";}
objRef.parentNode.onmouseout=function sublevelRestoreClass(){objRef.parentNode.className = "selected";}
objRef.parentNode.status='opened';
}
//end if

else 
{
subRef=findNextHtmlTag(objRef);
subRef.style.display='none';
objRef.parentNode.onmouseover=function restoreChangeClass(){changeClass(objRef.parentNode);}
objRef.parentNode.onmouseout=function restoreRestoreClass(){restoreClass(objRef.parentNode);}
objRef.parentNode.status='closed';
}
//end else


if (lastClicked!=null && lastClicked!=objRef)
{
 if (prevent==false)  
 {
 lastClicked.click();
 lastClicked.parentNode.className = "normal";
 }
}
if (lastClicked==objRef) 
{
prevent=!prevent;
}
else
{
prevent=false;
}
lastClicked=objRef;

}
// end fn controlMenuSubLevel

///////////////////////////////////////////////////////////////////////////////////////////////////

//utility functions

/// function findNextHtmlTag: searches the next HTML tag in the node hierarchy /// 

function findNextHtmlTag(oRef){
var nextSib = oRef.nextSibling;
while (nextSib.nodeType != 1)
nextSib = nextSib.nextSibling
return nextSib;
}

/// function findPreviousHtmlTag: searches the previous HTML tag in the node hierarchy /// 

function findPreviousHtmlTag(oRef){
var previousSib = oRef.previousSibling;
while (previousSib.nodeType != 1)
previousSib = previousSib.previousSibling
return previousSib;
}


///////////////////////////////////////////////////////////////////////////////////////////////////

//// functie to create breadCrums

var overrideCurrentURL="";
var p0P="";
var p4P="";
var p8P="";
var p1P="";
var p2P="";
var p3P="";
var p4P=false;

function createBreadCrum(){

 var titleDivTag = document.getElementsByTagName('div');
 for (var i=0;i<titleDivTag.length;i++)
  { 
    if (titleDivTag[i].className.indexOf('head')!=-1)
    {
     //alert(titleDivTag[i].className);
     p0P=(titleDivTag[i].firstChild.nodeValue);
     break;
    }
  }


 


// var searchPattern='/nl/';
// startIndex=currentURL.lastIndexOf(searchPattern); 
// if (startIndex==-1)
// {
// var searchPattern='/fr/';
// startIndex=currentURL.lastIndexOf(searchPattern); 
// }

// startIndex+=4;
// endIndex=currentURL.indexOf('html')+4;
//alert(startIndex);
//alert(endIndex);
// currentActiveURLString=currentURL.substring(startIndex,endIndex);


 var currentURL=window.location.toString();
  

 //overrideCurrentURL=true;

 if (overrideCurrentURL!="")
 { 
 tmpURLindex=currentURL.lastIndexOf('/');
 tmpURLindex+=1;
 var urlPrefix=currentURL.substring(0,tmpURLindex); 
 var compoundURL=urlPrefix+overrideCurrentURL;

 var currentActiveURLString=compoundURL;
 } 
 else
 {
 var currentActiveURLString=currentURL;
 }

 //alert(currentActiveURLString);

 var currentActiveTag = document.getElementsByTagName('a');
  for (var i=0;i<currentActiveTag.length;i++)
  { 
    if ( (currentActiveTag[i].href==currentActiveURLString)  &&  (currentActiveTag[i].parentNode.tagName=="LI") )
    {
     //alert(currentActiveTag[i].href); 
     //alert(currentActiveTag[i].parentNode.tagName);
     compoundText=(currentActiveTag[i].firstChild.nodeValue);

     //alert(currentActiveTag[i].parentNode.parentNode.parentNode.id);

    
     currentActiveTag[i].className="navCurrentItem"; 
     currentActiveTag[i].parentNode.className="mouseover";
     currentActiveTag[i].parentNode.onmouseout=function() {currentActiveTag[i].parentNode.className="mouseover";};    
      
     
     if (currentActiveTag[i].firstChild.nodeValue!=currentActiveTag[i].lastChild.nodeValue)

      compoundText+=(currentActiveTag[i].lastChild.nodeValue);

     compoundText=compoundText.replace(/(\r\n|\n|\r)/gm,"");
     compoundText=compoundText.replace(/^\s+|\s+$/g, '');
     compoundText=compoundText.replace('-', '');       
     p8P=compoundText; 
     break;  
    }
  }




/*

var breadCrumDestination=document.getElementById('breadcrumDestination');
var breadCrumStyle

if (document.getElementById('contentleft') || document.getElementById('contentleft02')) 
{
breadCrumString = "<span class='breadcrumb'><p style='color:#ababab;font-size:11px'>&nbsp;&nbsp;"
}
else breadCrumString = "<span class='breadcrumb' style='color:#ababab;font-size:11px' class=''><p>";


if (p0P!="")
{
breadCrumString+=p0P
 if (p2P) 
 {
 breadCrumString+=" > "; // IMG REF
 }
}

if (p2P!=null)
{
p2Pvalue=document.getElementById(p2P).firstChild.nodeValue;
 if (p2Pvalue!=p0P)
 {
// breadCrumString+='2 '+p2Pvalue;
 breadCrumString+=p2Pvalue;
 breadCrumString+=" > "; // IMG REF
 }
}

if (p4P!="")
{
//alert(p4P);
//breadCrumString+='4 '+p4P
breadCrumString+=p4P
breadCrumString+=" > "; // IMG REF
}
if (p2P)
 {
  if (p8P)
  {
  //breadCrumString+='8 '+p8P
  breadCrumString+=p8P
  }
 } 

breadCrumString+="</p></span>";
//alert(p8P);
txtCondition=true;

if (p4P=="")
{
if (p8P.toLowerCase().indexOf('overzicht')!=-1 || p8P.toLowerCase().indexOf('situering')!=-1) txtCondition=false;
if (p8P.toLowerCase().indexOf('aperçu')!=-1 || p8P.toLowerCase().indexOf('mise en perspective')!=-1) txtCondition=false;
}

if (  p2P!=null && txtCondition ) breadCrumDestination.innerHTML=breadCrumString;
*/
}




///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////MENU INITIALISATION////////////////////////////////////////     
///////////////////////////////////////////////////////////////////////////////////////////////////
var p2P=null;


function initMenu(allNavOpen,mainItemID,subItemID){

p1P=allNavOpen;
p2P=mainItemID;
p3P=subItemID;
p4P=false;

//hide all divs with subnavigation (divs are initially displayed in HTML document because of accesibility => scripting disabled) 

var x = document.getElementsByTagName('div');
 for (var i=0;i<x.length;i++)
 { if ( x[i].id.indexOf('subNavContainer') != -1 || x[i].id.indexOf('subNavItem') != -1)
   {
   x[i].style.display = 'none';
   }
}

//start initialisation

if (allNavOpen)

{
 var z = document.getElementsByTagName('div');
 for (var i=0;i<z.length;i++)
  { 
    if ( z[i].id.indexOf('menuHeader') != -1 )
    {
     z[i].click();
    }
  }

}

else
{
ignoreLastOpened=false;
var x_obj=document.getElementById(mainItemID)
var x_level2_obj=document.getElementById(subItemID);


x_level2_obj==null?{}:x_level2_obj=findPreviousHtmlTag(x_level2_obj);

if (x_level2_obj!=null) 
{
cmpdText=x_level2_obj.firstChild.nodeValue;
if (x_level2_obj.firstChild.nodeValue!=x_level2_obj.lastChild.nodeValue)
{
cmpdText+=x_level2_obj.lastChild.nodeValue;
}

cmpdText=cmpdText.replace(/(\r\n|\n|\r)/gm,"");
cmpdText=cmpdText.replace(/^\s+|\s+$/g, '');

p4P=cmpdText;
}


//if (x_level2_obj!=null)
//{
// var compoundText="";
// compoundText+=x_level2_obj.firstChild.nodeValue;
// 
// if (x_level2_obj.firstChild.nodeValue!=x_level2_obj.lastChild.nodeValue) 
// {
// compoundText+=x_level2_obj.lastChild.nodeValue; 
// } 
//
// p4P=compoundText;
//
//}

x_obj==null?{}:x_obj.click();

//RFC : ANCHORS ERROR
//x_level2_obj==null?{}:x_level2_obj.click();
x_level2_obj==null?{}:controlMenuSubLevel(x_level2_obj);
}

ignoreLastOpened=false;
window.scroll(0,0);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////MENU CONFIGURATION///////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

// function initMenuTest : this function must be called to start the menu configuration 


function initMenuTest(){

//hide all divs with subnavigation (divs are initially displayed in HTML document because of accesibility => scripting disabled)

var x = document.getElementsByTagName('div');
 for (var i=0;i<x.length;i++)
 { if ( x[i].id.indexOf('subNavContainer') != -1 || x[i].id.indexOf('subNavItem') != -1)
   {
   x[i].style.display = 'none';
   }
}


//start initialisation


window.open('../tools/menu_admin.html','','width=500,height=600,left=400,top=110');

}

///////////////////////////////////////////////////////////////////////////////////////////////////
