
function getCookieViaIndex (index)
{
	var cookiestr = document.cookie.indexOf (";", index);
	if (cookiestr == -1)
	{
		cookiestr = document.cookie.length;
	}

	return unescape(document.cookie.substring(index, cookiestr)); 
}



// the getCookie function takes one arguement the name of 
// the cookie to retrieve
//
// pass in the cookiename to this function and it 
// will return the value for that cookie

function getCookie (cookiename,defaultvalue)
{
	var field= cookiename + "=";
	var fieldlength = field.length;
	var cookielength = document.cookie.length;
	var iteration = 0;
	var iteration2 = 0;
	while (iteration < cookielength)
	{
		iteration2 = iteration + fieldlength;
		if (document.cookie.substring(iteration, iteration2) == field)
		{
			return getCookieViaIndex (iteration2);
		};
		iteration = document.cookie.indexOf(" ", iteration) + 1; 
		//look for the space character and go to the next character
		if (iteration == 0) break; 
	}
	return defaultvalue;
}

// date - any instance of the Date object
// * you should hand all instances of the Date object to this function for "repairs"
// * this function is taken from Chapter 14, "Time and Date in JavaScript", in "Learn Advanced JavaScript Programming"
function fixDate(date)
{
	var base = new Date(0)
	var skew = base.getTime()
	if (skew > 0)
		date.setTime(date.getTime() - skew)
}


// Our stripped-down cookie function. Everyone gets the root path, so cookies
// are global to our system, since it appears that gettting a cookie doesn't matter
// for path. Domain is not used.
// Required: name, value.
// Optional: expires. If not set, defaults to 38 days. If set to ".", is for browser session
// only.
function setCookie (name,value,expires)
{
	if (!expires)
	{
		expires = new Date()
		fixDate(expires)
		expires.setTime(expires.getTime() + 38 * 24 * 60 * 60 * 1000)
	}
	else
	{
		if (expires=='.')
			expires=0;
	}
	
	var DaCookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") + "; path=/";

//   alert(DaCookie);

	document.cookie = DaCookie;
}

function m2(whome)
{
	writeMailtoDom(whome,"nopcode.com");
}

function writeMailtoDom(whome,domain)
{
	var mailme = whome + "&#064;" + domain
	var mailtome = "<" + "a " + "href= \"" + "mail" + "to:" + mailme + "\">";
	document.write(mailtome);
	document.write(whome);
	document.write("</a>");
}
