function rmailDecode(v) {
	var r = "";
	for (i = 0; i < v.length; i++) {
		k = v.charCodeAt(i);
		if ((k >= 97 && k <= 109) || (k >= 65 && k <= 77)) {
			k += 13;
		} else {
			if ((k >= 110 && k <= 122) || (k >= 78 && k <= 90)) {
				k -= 13;
			}
		}
		r = r + String.fromCharCode(k);
	}
	return r;
}
function createCustomMarker(p) {
	var o = {};
	if (p.icon) {
		o.icon = new GIcon(G_DEFAULT_ICON);
		o.icon.image = p.icon;
		o.icon.shadow = "";
	}
	if (p.topmost) {
		o.zIndexProcess = function () {
			return GOverlay.getZIndex(-90) + 1;
		};
	}
	var m = new GMarker(new GLatLng(p.lat, p.lng), o);
	if (p.html) {
		GEvent.addListener(m, "click", function () {
			this.openInfoWindowHtml(p.html);
		});
	}
	return m;
}
function createFrameGallery(ts, ps) {
	var currentIndex = 0;
	var triggerLinks = $(ts).find("a");
	var playerFrame = $(ps).find("iframe")[0];
	var playerControls = $('<div class="easygallery-controls"></div>').insertAfter(ps);
	var done = function () {
		playerControls.find(".page").text(currentIndex + 1 + " of " + triggerLinks.length);
		if (triggerLinks.eq(currentIndex).attr("althref")) {
			playerControls.find(".zoom").show();
		} else {
			playerControls.find(".zoom").hide();
		}
	};
	triggerLinks.click(function () {
		currentIndex = $(this).parent().index();
		playerFrame.contentWindow.location = triggerLinks.eq(currentIndex).attr("href");
		done();
		return false;
	});
	$('<a href="#" class="prev"></a>').click(function () {
		if (triggerLinks.length > 1) {
			currentIndex = currentIndex == 0 ? triggerLinks.length - 1 : currentIndex - 1;
			playerFrame.contentWindow.location = triggerLinks.eq(currentIndex).attr("href");
			done();
		}
		return false;
	}).appendTo(playerControls);
	$('<span class="page"></span>').appendTo(playerControls);
	$('<a href="#" class="next"></a>').click(function () {
		if (triggerLinks.length > 1) {
			currentIndex = currentIndex == triggerLinks.length - 1 ? 0 : currentIndex + 1;
			playerFrame.contentWindow.location = triggerLinks.eq(currentIndex).attr("href");
			done();
		}
		return false;
	}).appendTo(playerControls);
	$('<a href="#" class="zoom"></a>').click(function () {
		playerFrame.contentWindow.location = "about:blank";
		var w = 800, h = 600, l = (screen.width - w) / 2, t = (screen.height - h - 80) / 2;
		var p = window.open(triggerLinks.eq(currentIndex).attr("althref"), "easygalleryPOPUP", "width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",scrollbars,resizable");
		if (p.focus) {
			p.focus();
		}
		return false;
	}).appendTo(playerControls);
	done();
}

