function GetCookie(name)
{
//alert('getcookie: ' + document.cookie);
	if (document.cookie.length > 0)
	{
		var debut;
		var longueur;
		debut = document.cookie.indexOf(name+"=");
		if (debut != -1)
		{
			debut += name.length + 1;
			longueur = document.cookie.indexOf(";", debut) - debut;
			if (longueur < 0)
			{
				longueur = document.cookie.length - debut - 1;
			}
			return document.cookie.substr(debut, longueur);
		}
	}
	return '';
}

function SetCookie(name, valeur, cult, iDuree)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+iDuree);
	document.cookie=name+ "=" +escape(valeur)+"&Langue="+cult+((iDuree==null) ? "" : "; expires="+exdate.toUTCString());
}

function RenderUser(nomCookie, txtUser, txtCult)
{
//alert('RenderUser');
	var biscuit = GetCookie(nomCookie);
	//alert('apres cookie');
	var ctlU = document.getElementById(txtUser);
//	alert('apres ctlU ' + ctlU);
	//alert('txtUser ' + txtUser + ', txtCult ' + txtCult + ', biscuit ' + biscuit + ', ctlU.value ' +ctlU);
	if ((!biscuit)||(biscuit == 'null'))
	{
		SetCookie(nomCookie, 'ppp-', txtCult, 365 );
		RenderUser(nomCookie, txtUser, txtCult);
	}
	if ((ctlU != null)&&(ctlU))
	{
		ctlU.value = biscuit.substr(0, (biscuit.indexOf('&Langue=') != -1 ? biscuit.indexOf('&Langue=') : biscuit.length) );
	}
}

