

function getUser() {
	
	var username = GetCookie('MMGUsername');
	var password = GetCookie('MMGPassword');
	

	if (username != null && password != null) {
		document.login.username.value = username;
		document.login.password.value = password;
	}
	else {
 //   setUser()
	}
}


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 setUser() {


username = document.login.username.value;
password = document.login.password.value;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 365 * 24 * 60 * 60 * 1000);

SetCookie('MMGUsername',username,expiration);
SetCookie('MMGPassword',password,expiration);

}


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);
}
