--
-- Утилитные функции для составления письма
--

--
-- Возвращает строку с темой письма
--
function EmailGetSubject(senderName)
	return senderName.." sent you a photo."
end

--
-- Возвращает строку с содержимым поля From
--
function EmailGetFromField()
	return "Fishdom Seasons Under The Sea game"
end

--
-- Возвращает тело письма
--
function EmailGetContent(senderName, recipientName, attachmentName, content)
	local matches = { sender = senderName, name = recipientName, image = attachmentName, text = content }
	local html =
[[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<table bgcolor="#bbe2f4" width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<br><br>
			<table align="center" width="774" cellpadding="0" cellspacing="0">
				<tr height="243">
					<td colspan="3"><img src="cid:header" width="774" height="243" alt="" style="display:block;"></td>
				</tr>
				
				<tr height="74">
					<td colspan="3" background="cid:top-bg" valign="top">
						<table cellpadding="0" cellspacing="0" width="100%">
							<tr height="74">
								<td style="padding: 0px 60px 10px 60px;" background="cid:top-bg">
									<div style="font: bold 14px Arial; color: #ffffff;">
									Dear $name,<br>
									$sender is having fun playing Fishdom Seasons Under The Sea!<br>
									$sender sent you this photo of the splendid fish tank from the game along with this message:<br>
									$text
									</div>
								</td>
							</tr>
							<tr height="10">
								<td background="cid:top" style="font-size: 8px">
								</td>
							</tr>
						</table>
					</td>
				</tr>
				
				<tr height="480">
					<td width="63"><img src="cid:left" width="63" height="480" alt="" style="display:block;"></td>
					<td width="640"><img src="cid:$image" width="640" height="480" alt="" style="display:block;"></td>
					<td width="71"><img src="cid:right" width="71" height="480" alt="" style="display:block;"></td>
				</tr>
				
				<tr height="258">
					<td colspan="3" background="cid:footer" align="center" valign="top" style="padding: 0px 90px 0px 90px; background-repeat: no-repeat;">
						<br>
						<div style="font: bold 14px Arial; color: #ffffff;">
						Create your own brilliant aquarium! Have fun taking care of quirky tropical fishies and adding cool accessories to the virtual tank of your dreams!
						Download the game right now, it's free to try!
						</div>
						<br><br>
						<a href="http://www.playrix.com/games/pc/fishdom-seasons-under-the-sea.html"><img src="cid:download" width="246" height="72" alt="Download" border="0"></a>
						<br><br><br><br><br><br><br>
					</td>
				</tr>
			</table>
			<br><br>
		</td>
	</tr>
</table>
</body>
</html>
]]
	return string.gsub(html, "%$(%w+)", function(s) return matches[s] end)
end
