

<!--
/*
name     : highlightcurrentlink.js
version  : 1.1.1
author   : Ron Deijkers
modified : june 11, JdHart



THIS FILE REQUIRES an updaterdata.js.asp TO BE INCLUDED IN THE PAGE AS WELL!!!
use the correct version of updaterdata.js.asp, which depends on the Updater version. 
also always read the instructions and requirements in all included files. i.e. updaterdata.js.asp itself has requirements: read the file. 

USAGE:
invoke highlightCurrentLink in the onLoad of the body. 
 
example 1:
<body onLoad="highlightCurrentLink('current-link-class');">

this will add the class named 'current-link-class' (without quotes) to
the/all link(s) which points to the current URL of the frame/window in which this script is used. 

example 2:
<body onLoad="highlightCurrentLink('my-class', 'mainframe');">

this will add the class named 'current-link-class' (without quotes) to
the/all link(s) which points to the current URL of the frame with the name mainframe. 


explained:
the first argument of highlightCurrentLink is the name of the class and
the second argument is the name of the content frame. if the second argument
if the second argument is not provided then the current frame/window is used. 
(like all texts in javascript these arguments should be given with quotes. )

*/



// changed: 26 08 2004, 9:19 (remarks above changed)



// set iDebugLevel to a possitive number to get debug messages
var iDebugLevel = 0;   // 0, 1 or 2





  /*
  ' function  : highlightCurrentLink
  ' overview  : this function changes the CSS class of the link that points to the current URL
  '             (or the URL of a specified frame).  
  '             this function must be invoked in the onLoad of the body.
  '             The CSS class obviously must exist in the page (or a linked css file).
  '
  '             note that only internal Updater links can be effected with this function.
  '
  '             the function linksAreEqual is used to compare links (read function description of this function for more info).
  ' requires  : when this function is invoked the location of the given frame must
  '             already be set to the correct value (the document in that frame must be loading
  '             or must be loaded when this function is invoked). so check the loading
  '             sequence of the frames.   
  ' arguments : [in] sClass, the class name which should be set on the hyperlink
  '             [in] sFrameName, the name of the frame of which the URL should be used of. 
  '                              in other words, this is the main frame, the content frame. 
  ' returns   : 
  ' example   : <body onLoad="highlightCurrentLink('currentLink');">
  */
  function highlightCurrentLink(sClass, sFrameName)
  {

	
    if (!sFrameName) sFrameName = '_self';
  
    if (iDebugLevel >= 1) alert('function highlightCurrentLink invoked with parameters: sClass = ' + sClass + ' en sFrameName = ' + sFrameName);


    if ((iDebugLevel >= 1) && (document.links.length == 0)) alert('highlightCurrentLink detected that there are no links in this page. ');

  /*-- speciaal voor STAO --*/
    for (var iLink = 0; iLink < document.links.length; iLink++)
    {
		if (typeof themeId != "undefined" ) {
		  if ( themeId >"" && document.links[iLink].href.match("themeid="+themeId) ) {
			  if (iDebugLevel >= 1) alert('link altered (class or bold): ' + document.links[iLink].href);
			  if ((sClass) && (sClass != ''))
			  {  
				document.links[iLink].className = sClass;
			  }
			  else
			  {
				document.links[iLink].style.fontWeight = 'bold';
			  }	  		
		  }
	  }/* -- end --*/
	  
	  var sLinkLocation = document.links[iLink].pathname + document.links[iLink].search;
	  
	  
      if (sLinkLocation.indexOf('showpage.asp') > -1) {
        var sCurrentLocation
        
        var objFrame;
        if (sFrameName == '_self')
          objFrame = window;
        else
          objFrame = window.open('javascript: ;', sFrameName);
        

        if ((sFrameName) && (sFrameName != ''))
        {
          if (objFrame)
          {
            sCurrentLocation = objFrame.location.pathname + objFrame.location.search;
          }
          else
          {
            alert('frame with name \'' + sFrameName + '\' does not exist!');
            return;
          }
        }
        else
        {
          sCurrentLocation = location.pathname + location.search;
        }

        if (sLinkLocation.substring(0,1) != '/')
        {
          sLinkLocation = '/' + sLinkLocation;
        }
        if (sCurrentLocation.substring(0,1) != '/')
        {
          sCurrentLocation = '/' + sCurrentLocation;
        }

//alert(sLinkLocation);
//alert(sCurrentLocation);
        
        if (linksAreEqual(sLinkLocation, sCurrentLocation))
        {
          if (iDebugLevel >= 1) alert('link altered (class or bold): ' + document.links[iLink].href);

          if ((sClass) && (sClass != ''))
          {  
            document.links[iLink].className = sClass;

		         }
          else
          {
            document.links[iLink].style.fontWeight = 'bold';
			
          }

        }
      }
    }

  } 
  


  /*
  ' function  : linksAreEqual
  ' overview  : Returns true if the two given links are equal else false. 
  '             Equality is dependent on the homepage of a theme as well. 
  '             This means that showpage.asp?themeid=1 is equal to showpage.asp?pageid=1
  '             if page 1 is the homepage of theme.
  '             Before the links are compared http://....... is stripped from both links. 
  '             this makes 'http://www.we.com/hello.htm' equal to 'http://www.somewhereelse.com/hello.htm' 
  ' arguments : [in] sLink1, sLink2
  ' returns   : true or false
  ' example   : linksAreEqual('/cms/publish/content/showpage.asp?pageID=1', '/cms/publish/content/showpage.asp?pageid=1') returns true
  */
  function linksAreEqual(sLink1, sLink2)
  {
    if (iDebugLevel >= 2) alert('comparing links: ' + sLink1 + ' and ' + sLink2);
  
    // make links lowercase and make relative
    var sCorrectedLink1 = sLink1.toLowerCase().replace(/^http:\/\/[^\/]+/i, '');
    var sCorrectedLink2 = sLink2.toLowerCase().replace(/^http:\/\/[^\/]+/i, '');


    if (iDebugLevel >= 2) alert('the links were corrected to: ' + sLink1 + ' and ' + sLink2);
    
    
    // create a regular expression to search for themeid=....
    var sThemeIDRegExp = /themeid\=(\d+)/;
    
    // for both links: if themeid=.... is found replace it with pageid=.... in which the homepage is used
    var saThemeIDNameValuePair1 = sThemeIDRegExp.exec(sCorrectedLink1);
    if (saThemeIDNameValuePair1)
    {
      var sThemeID1 = saThemeIDNameValuePair1[1];
      sCorrectedLink1 = sCorrectedLink1.replace(saThemeIDNameValuePair1[0], 'pageid=' + homepageOfTheme(parseInt(sThemeID1)));
    }
    var saThemeIDNameValuePair2 = sThemeIDRegExp.exec(sCorrectedLink2);
    if (saThemeIDNameValuePair2)
    {
      var sThemeID2 = saThemeIDNameValuePair2[1];
      sCorrectedLink2 = sCorrectedLink2.replace(saThemeIDNameValuePair2[0], 'pageid=' + homepageOfTheme(parseInt(sThemeID2)));
    }
    
    // both links now only contain pageid's
    if (iDebugLevel >= 2)
    {
      if (sCorrectedLink1 == sCorrectedLink2)
      {
        alert('the links are equal');
      }
      else
      {
        alert('the links are NOT equal. ');
      }
    }
    
    return (sCorrectedLink1 == sCorrectedLink2);
  } 
  
  

//-->


var links
function checkLevel2(x) {

	var linkFound = false;
	if( document.getElementById(x) ) 
	{

		links = document.getElementById(x).getElementsByTagName("a");
	
		for (var i=0 ; i<links.length ; i++) 
		{
			if (links[i].className.match("currentlink" )) 
			{
				linkFound = true;
				break;
			}
	
		}

	}
	if (linkFound==true || !document.getElementById(x))
	{
		if (!document.getElementById("content_container")) return;
		document.getElementById("content_container").style.borderColor="#001244";
	}	
	/*if() {
	
		document.getElementById('level01').className="lastLevel");
	}*/
}
