//gestion des cookies

function ecrire_cookie(nom, valeur, expires) {
	var date = null;
	if(expires) {
		date = new Date();
		//on définit la date d'expiration a une semaine
		date.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()+7);
	}
	
	var cookiecont = nom + "="+ escape(valeur);
	if(date!=null) cookiecont += "; expires="+date.toGMTString();
	cookiecont += "; path=/";
	cookiecont += "; domain="+document.domain;
	
	document.cookie = cookiecont;
}

function arguments_cookie(offset){
  var endstr=document.cookie.indexOf (";", offset);
  if (endstr==-1) endstr=document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr)); 
}

function lire_cookie(nom) {
  var arg=nom+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  while (i<clen){
    var j=i+alen;
    if (document.cookie.substring(i, j)==arg)
       return arguments_cookie(j);
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
  }
  return null; 
}

function gotoRetour() {
	var retour = lire_cookie('GUEBWILLER_RETOUR');
	if(retour!=null) document.location.href = retour;
}