// 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  : 'NL',
	  title :'Nederlands'
	},

	{ path  : 'english/',
	  code  : 'EN',
	  title : 'English'
	} ,

	{ path  : 'francais/',
	  code  : 'FR',
	  title : 'Fran&ccedil;ais'
	}
];


// -------------- 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/dc_flag' + lang.code + (selected ? '_in' : '') + '.gif" alt="' + lang.title +
		'" width="17" height="10" border="0" style="margin-left: 15px;" />');
}
