
// this script creates the java function to set the canivetlanguage cookie

// SetCanivetCookie("CanivetLanguage","EN");

function SetCanivetCookie(name,param,expir) 
{ var ojourdui = new Date();
  var expiration = new Date();
  
  if (expir == "1")
  {
    expiration.setTime(ojourdui.getTime() + 1000*60*60*24*1); // 1 jour de plus    
	// setCookie("CanivetLanguage", param, expiration);
   	setCookie(name, param, expiration);
  }
  else
  {
   	expiration.setTime(ojourdui.getTime() + 1000*60*60*24*2000); // 2000 jours de plus    
	// setCookie("CanivetLanguage", param, expiration);
   	setCookie(name, param, expiration);
  }
}

// ATTENTION
//
// the path info in cookie is important. If there is no path, it will use the
// current level from which the cookie function is called. ie: canivet.com/ecard
// and will not be available for upper levels. It will cause duplication of
// cookies and add confusion depending on which one is applicable
// depending on the level where you are. In order to fix this, we specify / (root)
// as the path. Only one cookie name and value will be set and it will be available
// for all lower levels.
//
// That's the same story with the domain. If you want to avoid the same confusion 
// if your domain can be called some different way (canivet.com or www.canivet.com),
// using domain '.canivet.com' allows for one common cookie for any of these two
// domain names canivet.com and www.canivet.com

function setCookie(nom, valeur, expire) 
{ document.cookie = nom + '=' + escape(valeur)
       + ((expire == null) ? '' : ('; expires=' + expire.toGMTString()))
	   + '; path=/; domain=.canivet.com';
}

// this script read the language from the canivetlanguage cookie

// var=GetCanivetCookie("CanivetLanguage");

function GetCanivetCookie(name)
{ var search = name + "="
  if (document.cookie.length > 0) { // if there are any cookies
     offset = document.cookie.indexOf(search)
     if (offset != -1) { // if cookie exists
        offset += search.length
        // set index of beginning value
        end = document.cookie.indexOf(";", offset)
        // set index of end of cookie value
        if (end == -1) end = document.cookie.length
        return unescape(document.cookie.substring(offset, end))
     }
  }
}
