// Code from Sebastian Hosche (http://rainforest1155.smugmug.com/)
//-------start of StyleSheetSwitch Code
// add your own reliable webspace where you'll have to put lang1_file and lang2_file
// don't add a '/' at the end of the server address - this is done later!!
var current_url = document.location.toString();
var _g_myServer = current_url.substr(0,current_url.lastIndexOf("/"));
var lang1 = "english";
var lang1_file = "eng.css";
var lang2 = "francais";
var lang2_file = "fra.css";
 
function readCookieStyle(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
 
function createCookieStyle(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
 
function setSheet(lang) {
createCookieStyle("style", lang, 365);
location.reload();
}
 
function includeBrowserCSS()
{
document.writeln("<style type=\"text/css\">");
var lang;
var lang_file;
var cookie = readCookieStyle("style");
if (cookie == lang1) {
lang = lang1;
lang_file = lang1_file;
}
if (cookie == lang2) {
lang = lang2;
lang_file = lang2_file;
}
// when no cookie is found, use lang1 as standard language
if (cookie != lang1 && cookie != lang2) {
lang = lang1;
lang_file = lang1_file;
}
document.writeln("@import url("+_g_myServer+"/"+lang_file+");");
document.writeln("</style>");
createCookieStyle("style", lang, 365);
}
//------ end of StyleSheetSwitch Code
