function makeItoken(timestamp)
{
   var login = document.getElementById('auth_login').value;
   var passwd = document.getElementById('auth_pwd').value;
   var hash = hex_md5(passwd);
   // ecrire le login et le hash dans un cookie qui expirera au bout de 24h
   document.cookie = "login=" + login + "; expires=" + (new Date((new Date()).getTime() + 24*60*60*1000)).toGMTString();
   document.cookie = "hash=" + hash + "; expires=" + (new Date((new Date()).getTime() + 24*60*60*1000)).toGMTString(); 
   var itoken = hex_md5(login + timestamp + hash);

   document.getElementById('password').value = itoken;
   document.getElementById('login').value    = login;
   document.getElementById('auth_pwd').value = '';

   return true;
}

function readCookie(name)
{
	var allcookies = document.cookie;
	var start = allcookies.indexOf(name + '=');
	if (start != -1) {			// cookie not defined for this page.
		start += name.length + 1;	// skip name and equals sign.
		var end = allcookies.indexOf(';', start);
		if (end == -1) end = allcookies.length;
		var cookieval = allcookies.substring(start, end);
		return cookieval;
	}
	return "";
}

function goTo (page, params)
{
	var token = readCookie('token');
	var hash = readCookie('hash');
	var login = readCookie('login');
	var auth = hex_md5(token + hash);
	var current = new String(document.location);
	var url = current.substring(0, current.lastIndexOf('/')+1);
	url += page + '?login=' + login + '&auth=' + auth;
	if (goTo.arguments.length == 2) {
		url += params;
	}
	document.location = url;
}
