var currentDate = new Date();
var ExpiresDate = "";
currentDate.setTime(currentDate.getTime() + 90*24*60*60*1000);
ExpiresDate = currentDate.toGMTString();

function findCookie(szName)
{
	var i = 0;
	var nStartPosition = 0;
	var nEndPosition = 0;
	var szCookieString = document.cookie;

	if(szName.length==0)	return "";

	while( i <= szCookieString.length)
	{
		nStartPosition = i;
		nEndPosition   = nStartPosition + szName.length;

		if(szCookieString.substring(nStartPosition,nEndPosition) == szName)
		{
			nStartPosition = nEndPosition + 1;
			nEndPosition   = document.cookie.indexOf(";",nStartPosition);
			if(nEndPosition < nStartPosition)
				nEndPosition = document.cookie.length;
			return document.cookie.substring(nStartPosition,nEndPosition);
			break;
		}
		i++;
	}
	return "";
}

function mStart()
{
	if(!document.cookie)		return;
	document.mag.type_tth.checked = findCookie("type_tth");
	document.mag.city.value       = findCookie("city");
	document.mag.firm.value       = findCookie("firm");
	document.mag.face.value       = findCookie("face");
	document.mag.tel.value        = findCookie("tel");
	document.mag.mail.value       = findCookie("mail");
	if (typeof(document.mag.raspr)=="object") document.mag.raspr.value      = findCookie("raspr");
}

function mEnd()
{
	if(!document.cookie)		return;
	if(document.mag.city.value=="") document.mag.city.value="&nbsp;"
	if(document.mag.firm.value=="") document.mag.firm.value="&nbsp;"
	if(document.mag.face.value=="") document.mag.face.value="&nbsp;"
	if(document.mag.tel.value=="") document.mag.tel.value="&nbsp;"
	if(document.mag.mail.value=="") document.mag.mail.value="&nbsp;"

	document.cookie = 'type_tth=' + document.mag.type_tth.checked + ';expires=' + ExpiresDate + ';path=/;';
	document.cookie = 'city='     + document.mag.city.value       + ';expires=' + ExpiresDate + ';path=/;';
	document.cookie = 'firm='     + document.mag.firm.value       + ';expires=' + ExpiresDate + ';path=/;';
	document.cookie = 'face='     + document.mag.face.value       + ';expires=' + ExpiresDate + ';path=/;';
	document.cookie = 'tel='      + document.mag.tel.value        + ';expires=' + ExpiresDate + ';path=/;';
	document.cookie = 'mail='     + document.mag.mail.value       + ';expires=' + ExpiresDate + ';path=/;';
	if (typeof(document.mag.raspr)=="object") document.cookie = 'raspr='    + document.mag.raspr.value      + ';expires=' + ExpiresDate + ';path=/;';
}