// JavaScript Document

function langue()
{
var the_url = (document.URL);

	if ((the_url.indexOf("/en/", 0)!=-1) || (the_url.indexOf("/fr/", 0)!=-1)) {
		engcode="/en/"
		frcode="/fr/"
	} else {
		engcode="\\en\\"
		frcode="\\fr\\"
	}
		
if (the_url.indexOf(engcode, 0)!=-1){
	setcookie('lang','fr')
	var nb_debut = the_url.indexOf(engcode, 0);
	var debut = the_url.substring(0, nb_debut);
	var longueur = the_url.length;
	var fin = the_url.substring(nb_debut+4, longueur);
	var the_page = debut+frcode+fin;
	document.location = the_page;
}	
else if (the_url.indexOf(frcode, 0)!=-1){
	setcookie('lang','en')
	var nb_debut = the_url.indexOf(frcode, 0);
	var debut = the_url.substring(0, nb_debut);
	var longueur = the_url.length;
	var fin = the_url.substring(nb_debut+4, longueur);
	var the_page = debut+engcode+fin;
	document.location = the_page;
}
else {
}	
}


function setcookie(ckyname,ckyval) {
	var expDays = 180;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000))
	if (ckyval=='') {exp="Tue, 01-Aug-1996 00:00:00 GMT"}
	document.cookie = trim(ckyname) + "=" + ckyval + "; expires=" + exp + "; path=/"
}


function trim(strText) { 										// remove leading and trailing blanks
	if (strText=="") {return}
	while (strText.substring(0,1) == ' ') {	strText = strText.substring(1, strText.length); }
	while (strText.substring(strText.length-1,strText.length) == ' ') {	strText = strText.substring(0, strText.length-1); }
	return strText;
}