function DebugMsg( level, sMsg)
{
	var iDebugLevel=0;
	if( iDebugLevel >= level)
	{
		alert( sMsg);
	}
}

function set_location( newURL)
{
    // bij voorkeur replace() method gebruiken.
    // alleen mogelijk als document.image gedefinieerd is ????
    //    DebugMsg( 10, "set_location: newURL: " + newURL);
    if (document.images)
		document.location.replace(newURL);
    else
		document.location.href = newURL;
}

//-------------------------------------------------------
// bepaalt het 'absolute pad' van een file
// Als het met een '/' begint, dan blijft het ongewijzigd.
// anders wordt cur_path (tot de laatste '/') er voor gezet
//-------------------------------------------------------
function absolute_path( cur_path, filename)
{
    return( cur_path.substring(0, cur_path.lastIndexOf('/')) + '/' + filename);
}

// -------------------------------------------------------------------------
// herlaadt een URL in een frame.
// parameters: 
// frame_name: naam van het frame waarin een bestand geladen moet zijn. 
//	      default: 'content'
// frameset_name: naam van het bestand waarin de frameset wordt gedefinieerd. 
//		 default: 'index.html'
// -------------------------------------------------------------------------
function reload_frame( frame_name, frameset_name, content_name)
{
	
    // zet default waarden
    if( !frame_name || frame_name.length == 0)
	{
	    frame_name="content";
	}
    if( !frameset_name || frameset_name.length == 0)
	{
	    frameset_name = '/index.html';
	}

    if( !content_name || content_name.length == 0)
	{
	    content = location.pathname;
	}
    else
	{
    content = absolute_path( location.pathname, content_name);
	}


	DebugMsg( 10, "reload_frame (" + document.location.href + ")\n" +
    		   "frame_name: " + frame_name + "\n" +
    		   "frameset_name: " + frameset_name + "\n" +
    		   "content: " + content + "\n" +
    	   	"parent: " + parent + "\n" +
		"parent.frames[ " + frame_name + "]: " + parent.frames[ frame_name]);

    if ((top == self) ||
	! parent ||
	! parent.frames[ frame_name])
	{
	    // deze pagina staat niet in het gewenste frame: laad frameset_name
	    // Als parameter krijgt deze de URL van de huidige locatie mee (achter het '?')
	    // De oorspronkelijke URl bestaat uit pathname?search#hash
	    // volledige URL wordt nu http://host[:port]/nw_path/frameset_name?/path/this.html?search#hash
	    var newURL = location.protocol + // http:
		'//' + 
		location.host +	     // www.kadaster.nl
		frameset_name + '?' +
		content +	    
		location.search +   // alles achter de ?
		location.hash;	    // Het anker achter #. Moet als laatste
	    DebugMsg( 10, newURL);
 
	    set_location( newURL);
	}
}
function setMenu( bNederlands)
{
	var menu_frame = parent.frames["menu"];
	if( menu_frame)
	{
		var sLocation = String( menu_frame.location.href);
		if( bNederlands)
			sLocation = sLocation.replace( /menu_engels.html/, "menu.html");
		else
			sLocation = sLocation.replace( /menu.html/, "menu_engels.html");
		
		DebugMsg( 10, "menu_frame: " + menu_frame.location.href);
		if( menu_frame.location.href != sLocation)
		{
			menu_frame.location.replace( sLocation);
		}
	}
}
function setContent( bNederlands)
{
	return( true);
}

function isInhoud( bNederlands)
{
	var sParentDir="";
	DebugMsg( 10, "isInhoud(): " + sParentDir);
	reload_frame( 'content', "/index.html");
	setMenu( bNederlands);
}

function getParams ()
{
	array = new Array();
	sArgs = location.search.slice(1).split('&');
    r = '';
    for (var i = 0; i < sArgs.length; i++) 
	{
		var parms = sArgs[ i].split( '=');
		array[ unescape( parms[ 0])] = unescape( parms[ 1]);
    }

	return( array);
}

function s_(text) {
	window.status=text?text:'';return true;
}


function koppad_nederlands()
{
	var i = 0;
	document.write( '> <a href="');
	document.write( '/home.html">PlusLeo</a> ');
	if( document.location.pathname.match( /spelers\/.*\//))
		document.write( '> <a href="/spelers/">Spelers</a> ');
	if( document.location.pathname.match( /producties\/.*\//))
		document.write( '> <a href="/producties/">Producties</a> ');
	if( document.location.pathname.match( /leden\/.*\//))
		document.write( '> <a href="/leden/adressen.html">Leden</a> ');
//	document.write( '> ' + document.title);
}

function koppad_engels()
{
	var i = 0;
	document.write( '> <a href="');
	document.write( '/home_engels.html">PlusLeo</a> ');
	if( document.location.pathname.match( /spelers\/.*\//))
		document.write( '> <a href="/spelers/engels.html">Players</a> ');
	if( document.location.pathname.match( /producties\/.*\//))
		document.write( '> <a href="/producties/engels.html">Productions</a> ');
//	document.write( '> ' + document.title);
}

function koppad( bNederlands)
{
	if( bNederlands)
		koppad_nederlands();
	else
		koppad_engels();
}





