function getUser() {
	var username = GetCookie('MMGUsername');
	var password = GetCookie('MMGPassword');
	//alert("getUser: " + username + "; Password: " + password);
	if (username != null && password != null) {
		document.login.username.value = username;
		document.login.password.value = password;		
		document.login.checkbox.checked = true;
	}
}

function authenticateUser(curLocation) {
	var username = document.login.username.value;
	var password = document.login.password.value;
	//alert("authenticateUser: " + username + "; Password: " + password);
	if (document.login.checkbox.checked) {
		var expiration = new Date();
		expiration.setTime(expiration.getTime() + 365 * 24 * 60 * 60 * 1000);
		SetCookie('MMGUsername', username, expiration, '/');
		SetCookie('MMGPassword', password, expiration, '/');
	} else {
		delete_cookie('MMGUsername');
		delete_cookie('MMGPassword');
	}
	document.login.action = curLocation;
	document.login.submit();
}
function SetCookie(name, value, expires, path, domain) 
{ document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null)    ? "" : "; path=" + path) +
  ((domain == null)  ? "" : "; domain=" + domain);
}

function GetCookie(name)
{ var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) 
  { begin = dc.indexOf(cname);       
    if (begin != -1) 
    { begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function DelCookie (name,path,domain) 
{ if (GetCookie(name)) 
  { document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}