// JavaScript Document
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return false;
}
function setLanguage(l,page) {
	setCookie('lang',l,"/");
	return document.location.href=page;
}
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, path, domain, secure) {
	//deleteCookie(name, path, domain);
	var d=new Date();
	var t=d.getTime()+(61*24*60*60*1000);
	d.setTime(t);
    document.cookie= name + "=" + escape(value) +
        ((d) ? "; expires=" + d.toGMTString() : "") +
        ((path) ? "; path=" + path : "/") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
	return 0;
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "/") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
	return 0;
}
var anch;
anch="";
qmarkat=location.href.indexOf("?");
arg=''
if (qmarkat>0) {
mypage=location.href.substr(0,qmarkat);
arg=location.href.substring(qmarkat,location.href.length);
}
else {
mypage=location.href;
}
if((num=mypage.indexOf("#"))>0) {
	anch=mypage.substr(num,mypage.length);
	mypage=mypage.substr(0,num);
	if(anch=="#") anch="";
}
mylength=mypage.length;
fileend=mypage.substr(mylength-6);
filestart=mypage.substr(0,mylength-6);
pagelang='';
currentend=fileend;
//-------------------------
//alert(fileend);
//-------------------------
if(fileend=="_e.asp") {
	fileend="_f.asp";
	pagelang="Fran&ccedil;ais";
	l="f";
} else {
	if(fileend=="_f.asp") {
		fileend="_e.asp";
		pagelang="English";
		l="e";		
	}
}
if(fileend=="ex.htm" || (fileend.indexOf(".htm")==-1 && fileend.indexOf(".asp")==-1) && pagelang=='') {
	filestart="index";
	fileend="_f.htm";
	pagelang="Fran&ccedil;ais";
	l="f";
}
else
if (fileend=="_e.htm"||fileend=="_E.htm"){
	fileend="_f.htm";
	pagelang="Fran&ccedil;ais";
	l="f";
}
else {
	if (fileend=="_f.htm"||fileend=="_F.htm") {
		//alert(mypage.indexOf(".2/index_f"));
		if(mypage.indexOf("index_f")==-1) {
			fileend="_e.htm";
		}
		else fileend=".htm";
		pagelang="English";
		l="e";
	}
}
if(fileend=="ex.htm"||fileend=="r.com/"||fileend=="er.com"||fileend=="0.0.2/"||fileend=="host/") {
	filestart="index";
	fileend="_f.htm";
	pagelang="Fran&ccedil;ais";
	l="f";
}/*
if(getQueryVariable("l")==false) {
	l=getCookie('lang');
	if(currentend=="_f.htm" && l=="e") {
		if(currentend!="ex.com" || currentend!="r.com/" || currentend!="er.com") fileend="_e.htm";
		else fileend=".htm";
	}
	else {
		if(l=="f")
		fileend="_f.htm";
	}
	setLanguage(l,filestart+fileend+"?l="+l);
}*/
if(pagelang!="") {
	//<!--[if IE6]><style type="text/css">#prelude{position:relative;top:-40px;</style><![endif]-->
	document.write('<a name="TOP" class="hideme"></a><a href="'+filestart+fileend+arg+'" onClick="setLanguage(\''+l+'\',\''+filestart+fileend+'\');" class="' + l + '">'+pagelang+'</a>');
}