function maGetCookie (name) {
	var maArg = name + "=";
	var maAlen = maArg.length;
	var maClen = document.cookie.length;
	var i = 0;
	while (i < maClen) {
		var j = i + maAlen;
		if (document.cookie.substring(i, j) == maArg)
		return maGetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function maGetCookieVal(offset) {
	var maEndstr = document.cookie.indexOf (";", offset);
	if (maEndstr == -1)
	maEndstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, maEndstr));
}

function maSetCookie (name, value) {
	var maArgv = maSetCookie.arguments;
	var maArgc = maSetCookie.arguments.length;
	var maExpires = (maArgc > 2) ? maArgv[2] : null;
	var maPath = (maArgc > 3) ? maArgv[3] : null;
	var maDomain = (maArgc > 4) ? maArgv[4] : null;
	var maSecure = (maArgc > 5) ? maArgv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((maExpires == null) ? "" : ("; expires=" + maExpires.toGMTString())) +
	((maPath == null) ? "" : ("; path=" + maPath)) +
	((maDomain == null) ? "" : ("; domain=" + maDomain)) +
	((maSecure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
	var maExp = new Date();
	maExp.setTime (maExp.getTime() - 1);
	var maCval = maGetCookie (name);
	document.cookie = name + "=" + maCval + "; expires=" + maExp.toGMTString();
}

function maCheckCookie() { // check for cookie support
	if ( maGetCookie("_maCID") ) {
		return true;
	} else {
		maExp = new Date();
		maPTime = 15552000; // in seconds
		maExp.setTime(maExp.getTime() + maPTime*1000);
		maSetCookie("_maCID", "true", maExp, "/");
	}
	return false;
}
