

function getCurrentDir() {
	base = rootUrl.substr(0, rootUrl.length-1);      // remove last slash from base	
	var url = document.location.href;          // get current URL
	var reminder = url.replace( base, '' );    // remove base from current URL
	var reminderSplit = reminder.split('/');   // get toplevel directory
	
	// the result. should look like 'news/', when we are at 
	// http://www.sggp.ch/news/index.cfm (or whatever file in this directory
	// or in a subdirectory).
	return reminderSplit[1] + '/';
}
URI = getCurrentDir();





// for print version, any link needs to have a '&print=' url parameter, so 
// the next page is also displayed in the same layout!
//
// the function must be called onload!
//
function urlTuner() {
	with (document) {
		
		// url tuning:
		i=0; str = '';
		for ( ;i < links.length; i++ ) {
			if (links[i].search == '') { str = '?'; } else { str = '&'; }
			
			// exclude javascript links, eg. href='javascript:<whatever_js_stuff>'
			myProto = links[i].protocol;
			if ( myProto.toLowerCase() != 'javascript:' ) {
				links[i].href += str + 'print=';
				// alert(links[i].href);
			}
		}
		
		// all form targets point ot it's caller! submitting always to the normal 
		// browser window, since the form's element array is readonly. cannot add 
		// a form parameter 'print=' :(
		for (i=0; document.forms[i]; i++) { 
			document.forms[i].target = 'parent'; 
		}

	}
}
