var MindMapperDownload = null;
var MindMapperDownloadTitle = null;
var TitleToInt = new Array();
TitleToInt["MM50ProSpn.exe"] = 0;
TitleToInt["MM50ProEng.exe"] = 1;
TitleToInt["MM2008ProEng.exe"] = 2;
TitleToInt["MM2008STDEng.exe"] = 3;
TitleToInt["MM2008BasicEng.exe"] = 4;
TitleToInt["guia.ppt"] = 5;
TitleToInt["MM2009ProEng.exe"] = 6;
var cookies = new Array();
document.cookie = "cookiesenabled=yes";
getCookies();
var expiration = null;
if (cookies.cookiesenabled) {
	if (!cookies.returninguser) {
		deleteCookie("name");
		deleteCookie("email");
		deleteCookie("check");
		expiration = new Date();
		expiration.setMinutes(expiration.getMinutes() + 30);
		document.cookie = "returninguser=true; expires="
				+ expiration.toGMTString()
	}
}
function downloadFocus(B, A) {
	B.style.border = "4px dashed orange";
	if (A) {
		B.style.border = "4px dashed purple"
	}
}
function downloadBlur(A) {
	A.style.border = "none"
}
function getCookies() {
	var A, E;
	var D, C, B;
	for (A in cookies) {
		cookies = new Array();
		break
	}
	D = 0;
	while (D < document.cookie.length) {
		C = document.cookie.indexOf("=", D);
		B = document.cookie.indexOf(";", D);
		if (B == -1) {
			B = document.cookie.length
		}
		if (C > B || (C == -1)) {
			A = document.cookie.substring(D, B);
			E = ""
		} else {
			A = document.cookie.substring(D, C);
			E = document.cookie.substring(C + 1, B)
		}
		cookies[A] = unescape(E);
		D = B + 2
	}
}
function deleteCookie(A) {
	document.cookie = A + "=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	document.cookie = A + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT"
}
var COOKIES_MAP = new Array();
COOKIES_MAP.name = "mm.user";
COOKIES_MAP.email = "mm.email";
COOKIES_MAP.contact = "mm.info";
function addCookie(A, B) {
	if (!expiration) {
		expiration = new Date();
		expiration.setMinutes(expiration.getMinutes() + 30)
	}
	document.cookie = A + "=" + escape(B) + "; expires="
			+ expiration.toGMTString();
	cookies[A] = B
}
function showTooltipForDownload(A, B) {
	MindMapperDownload = A;
	MindMapperDownloadTitle = B;
	if (cookies.cookiesenabled && cookies[COOKIES_MAP.name]) {
		$("name").value = cookies[COOKIES_MAP.name];
		$("email").value = cookies[COOKIES_MAP.email];
		$("check").checked = cookies[COOKIES_MAP.contact];
		downloadMM(false)
	} else {
		window.scroll(0, 0);
		Modalbox.show("fillToDownload.html", {
			title : B,
			width : 500
		})
	}
	return false
}
var DOWNLOAD_TIMER = null;
function downloadMM(A) {
	if ($("version")) {
		$("version").value = TitleToInt[MindMapperDownload]
	}
	if ($("check")) {
		if ($("check").checked) {
			$("contact").value = "true"
		} else {
			$("contact").value = "false"
		}
	}
	if (cookies.cookiesenabled && !cookies[COOKIES_MAP.name]) {
		addCookie(COOKIES_MAP.name, $("name").value);
		addCookie(COOKIES_MAP.email, $("email").value);
		addCookie(COOKIES_MAP.contact, $("contact").value)
	}
	if ($("downloadForm")) {
		$("downloadForm").target = "iFrame"
	} else {
		if ($("downloadFormHidden")) {
			$("downloadFormHidden").target = "iFrame";
			$("downloadFormHidden").submit()
		}
	}
	setTimeout(
			function() {
				Modalbox
						.show(
								"<div align='center' style='font-size:small;'><br/><p>Su descarga comenzara automáticamente en 5 segundos,</p><br/><p> Si no lográ visualizar la ventana de descarga siga este <a onclick='alternDownload();' style='text-decoration:underline;color:blue;cursor:pointer;'>link</a>.</p><br/><img id='spineer' src='../img/spinner.gif'/> <div align='right' style='width:100%;float:left;'><a style='text-decoration:underline;cursor:pointer;color:blue;' onclick='Modalbox.hide();return false;'>Cerrar</a></div></div>",
								{
									title : "Mimapamental.com",
									width : 400
								});
				if (DOWNLOAD_TIMER) {
					clearTimeout(DOWNLOAD_TIMER)
				}
				DOWNLOAD_TIMER = setTimeout(
						function() {
							window.open("downloads/" + MindMapperDownload,
									"_self", "");
							$("spineer").style.visibility = "hidden"
						}, 5000)
			}, 500);
	return true
}
function alternDownload() {
	Modalbox.hide();
	window.open("../pages/downloads/" + MindMapperDownload, "_self", "");
	clearTimeout(DOWNLOAD_TIMER);
	return false
};