	
	var AF_ident = 'anvilfire_ndat';
	var the_userID = '10000000';
	var user_group = "iron";
	var uink_color = "000000";
    var member_exp = "YYYY-MM-DD";
    var user_data = "extra";
    
function SetTheCookie(form) {

    var the_date = new Date ();
    var nodays = 1
    if (user_group == 'gold' || 'silver') {nodays = 2;} else {nodays = 10}

    the_date.setTime (the_date.getTime() + (24 * 3600 * 1000 * nodays));

	var the_cookie_date = the_date.toGMTString();   			
	var the_cookie = ':' + the_userID + '&' + form.realname.value + '&' + form.username.value + '&' + user_group + '&' + uink_color + '&' + member_exp + '&' + user_data;
	
    the_cookie = AF_ident + "=" + escape(the_cookie) + ";expires=" + the_cookie_date + "; path=/;"
	
	document.cookie = the_cookie;
	
	document.UserForm.cookie_contents.value = unescape(the_cookie);

}


function readCookie()
{

  var the_cookie = AF_readCookie(AF_ident);

  if(the_cookie == '') {return};
   
  var broken_cookie = the_cookie.split(":");
  var the_name_part = broken_cookie[1];
  var broken_name = the_name_part.split("&");

    the_userID = broken_name[0];
  var the_name = broken_name[1];
  var the_user = broken_name[2];
    user_group = broken_name[3];
    uink_color = broken_name[4];
    member_exp = broken_name[5];
     user_data = broken_name[6];

    if(user_group == 'undefined') {user_group = "iron"; }
    if(uink_color == 'undefined') {uink_color = "#000000"; }

    var name_parts = the_name.split("+");
        
    if(name_parts.length == 2){ the_name = name_parts[0] + " " + name_parts[1];}

  document.UserForm.realname.value = unescape(the_name);
  document.UserForm.username.value = unescape(the_user);
  document.UserForm.exp_date.value = unescape(member_exp);
  document.UserForm.cookie_contents.value = unescape(document.cookie);

/* guru page code */

  var icolor = '#' + unescape(uink_color);
  document.UserForm.inkcolor.value = icolor;

 document.UserForm.OK.value = 0; 
 document.bgColor = '#000000';

  if(user_group == 'gold') { 
    document.bgColor = icolor; 
    document.UserForm.OK.value = 1; } 
  if(user_group == 'silver') { document.bgColor = icolor; document.UserForm.OK.value = 0;} 
 
}


function AF_readCookie(AF_ident) {

  // if there's no cookie, return false else get the value and return it

  if(document.cookie == '') return false;
  else return unescape(AF_getCookieValue(AF_ident));

}


function AF_getCookieValue(AF_ident)
{
  // Declare variables.
  var firstChar, lastChar;

  // Get the entire cookie string. (This may have other name=value pairs in it.)
  var theBigCookie = document.cookie;

  // Grab just this cookie from theBigCookie string.

  // Find the start of 'name'.
  firstChar = theBigCookie.indexOf(AF_ident);

  // If you found it,
  if(firstChar != -1)
{
  // skip 'name' and '='.
  firstChar += name.length;

// Find the end of the value string (i.e. the next '&').
    lastChar = theBigCookie.indexOf('&', firstChar);

    if(lastChar == -1) lastChar = theBigCookie.length;

    // Return the value.
    return theBigCookie.substring(firstChar, lastChar);

  } else {
    // If there was no cookie, return false.
    return false;
  }
}

function AF_delCookie () {

    document.cookie = AF_ident + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
    document.UserForm.realname.value = "";
    document.UserForm.username.value = "";
    document.UserForm.cookie_contents.value = "";	
}

function multiTask(form) {

    SetTheCookie(document.UserForm);
    var word = document.UserForm.username.value;
    AF_encrypt01(word);
}
