// SwitchLanguage script
// ---------------------------------------------
// Copyright 2006 by XIAM Solutions B.V.
// Author: V. van Beveren (vvanbeveren@xiam.nl).
// the root path the application is in
contentDir = '/';
// the language configurations.
var langs = [
	{ path  : '' ,
	  code  : 'en',
	  title : 'English'
	},
	{ path  : 'nederlands/',
	  code  : 'nl',
	  title : 'Nederlands'
	},
    { path  : 'francais/',
      code  : 'fr',
      title : 'Fran&ccedil;ais'
    },
    { path  : 'deutsch/',
      code  : 'de',
      title : 'Deutsch'
    }
];
// -------------- DO NOT EDIT BEYOND THIS POINT --------
var currentLang = null;
// resolve current language from location.
path = location.pathname;
// IE Fix
path = path.replace(/\\/g,'/');
if (path.indexOf(contentDir) >= 0) {
	idx = path.indexOf(contentDir) + contentDir.length;
    path = path.substring(idx);
}
root = '';
for (i = 0; i < path.length; i++) {
	if (path.charAt(i) == '/') {
		root += '../';
    }
}
for (i = 0; i < langs.length; i++) {
    if (path.substring(0, langs[i].path.length) == langs[i].path) {
		if (currentLang == null || currentLang.path.length < langs[i].path.length) {
			currentLang = langs[i];
  		}
    }
}
file = path.substring(currentLang.path.length);
function writeFlags() {
	for (i = 0; i < langs.length; i++) {
		lang = langs[i];
		if (lang == currentLang) {
			writeFlag(lang, true);
  		} else {
  		    document.write('<a href="' + root + lang.path + file + '">');
  		    writeFlag(lang, false);
  		    document.write('</a>');
    	}
 	}
}
function writeFlag(lang, selected) {
	document.write('<img src="' + root + 'images/flag_' + lang.code + (selected ? '_disabled' : '') + '.png" alt="' + lang.title +
		'" title="' + lang.title + '" width="16" height="16" border="0" style="margin-left: 15px;" />');
}
