
var url = "/" ;
var expDays = 360;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

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 DeleteCookie (name) {
	//var exp = new Date();
	//exp.setTime (exp.getTime() - 10 );
	//var cval = GetCookie (name);
	document.cookie = name + "=deleted; path=/; expires Thu, 01-Jan-1970 00:00:00 GMT";
}

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 DeleteCookies ( nom1, nom2, nom3, nom4 ) {

	DeleteCookie(nom1) ;
	DeleteCookie(nom2) ;
	DeleteCookie(nom3) ;
	DeleteCookie(nom4) ;
}

// ----------------------------------------- //
// Fonctionnalites rajoutees par Jo
// 17 Avril 2002
// Permet de gerer facilement les cookies du devoir et de via aussi et de VDLProfil 
// ------------------------------------------------ //
// EXEMPLE D'UTILISATION :
//

// GetValue ( GetCookie ("userinfo") ) ;
// document.write ( "le NOM : " ) ;
// document.write ( oCurrentCookie["nom"] ) ;
// document.write ( "<BR>" ) ;
// document.write ( "le PRENOM : " ) ;
// document.write ( oCurrentCookie["prenom"] ) ;
// document.write ( "<BR>" ) ;


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 ;

}
var oCurrentCookie = new MyCookie ( "", "", "", "na", "", "", "" ) ;

function GetVIACookieValue ( valeur )
{
 if ( valeur != null )
  {
   var tab = valeur.split ( "|" ) ;
   oCurrentCookie.SetSessionKey ( tab [ 0 ] ) ;
   oCurrentCookie.SetPkProfil   ( tab [ 1 ] ) ;
   oCurrentCookie.SetPrenom     ( tab [ 2 ] ) ;
   oCurrentCookie.SetNom        ( tab [ 3 ] ) ;
   oCurrentCookie.SetT          ( tab [ 4 ] ) ;
  }
   else
   {
     oCurrentCookie.SetSessionKey ( "na" ) ;
     oCurrentCookie.SetEmail ( "na" ) ;
   }
return tab;
}

function GetAbonCookieValue ( valeur )
{
 if ( valeur != null )
  {
   var tab = valeur;
  }
   else
   {
		var tab = "na";
   }
return tab;
}

document.write('<script type="text/javascript" src="/js/global.js"></script>'); 

