var url = "/" ;
var expDays = 360;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
var oCurrentCookie = new MyCookie ( "", "", "", "na", "", "", "" ) ;

function getCookieVal (offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) 
{
	var arg = name + "=";
	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 getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break;
	}
	return null;
}

function SetCookie (name, value) 
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function WriteCookies ( nom1, val1, nom2, val2, nom3, val3, nom4, val4 )
{
	SetCookie(nom1 , val1 , exp, '/cgi-bin/') ;
	SetCookie(nom2 , val2 , exp, '/cgi-bin/') ;
	SetCookie(nom3 , val3 , exp, '/cgi-bin/') ;
	SetCookie(nom4 , val4 , exp, '/cgi-bin/') ;
}

function DeleteCookie (name) {document.cookie = name + "=deleted; path=/; expires Thu, 01-Jan-1970 00:00:00 GMT";}
function DeleteCookies ( nom1, nom2, nom3, nom4 ) {DeleteCookie(nom1);DeleteCookie(nom2);DeleteCookie(nom3) ;DeleteCookie(nom4) ;}
function SetNom ( nom ){this.nom = nom ;}
function SetPrenom ( prenom ){this.prenom = prenom ;}
function SetEmail ( email){this.email = email;}
function SetSessionKey ( sessionkey ){this.sessionkey = sessionkey ;}
function SetPkProfil ( pkprofil ){this.pkprofil = pkprofil ;}
function SetCRC ( crc ){this.crc = crc ;}
function SetT ( t ){this.t = t ;}

function MyCookie ( nom, prenom, email, sessionkey, pkprofil, crc, t )
{
   this.nom = nom ;
   this.prenom = prenom ;
   this.email  = email ;
   this.sessionkey = sessionkey ;
   this.pkprofil = pkprofil ;
   this.crc = crc ;
   this.t = t ;

   this.SetNom = SetNom  ;
   this.SetPrenom = SetPrenom  ;
   this.SetEmail = SetEmail ;
   this.SetSessionKey = SetSessionKey  ;
   this.SetPkProfil   = SetPkProfil   ;
   this.SetCRC = SetCRC ;
   this.SetT = SetT ;

}

function GetRDSCookieValue ( valeur )
{
 if ( valeur != null )
  {
   var tab = valeur.split ( "|" ) ;
   oCurrentCookie.SetSessionKey ( tab [ 0 ] ) ;
   oCurrentCookie.SetPkProfil   ( tab [ 1 ] ) ;
   oCurrentCookie.SetPrenom     ( tab [ 2 ] ) ;
   oCurrentCookie.SetNom        ( tab [ 3 ] ) ;
   if ( tab.length == 5 )
    {
      oCurrentCookie.SetT ( tab [ 4 ] ) ;
    }
  }
   else
   {
     oCurrentCookie.SetSessionKey ( "na" ) ;
     oCurrentCookie.SetEmail ( "na" ) ;
   }
	return tab;
}