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

--
-- Возвращает строку с темой письма
--
function EmailGetSubject(senderName)
	return "Photo from your friend - "..senderName
end

--
-- Возвращает строку с содержимым поля From
--
function EmailGetFromField()
	return "Fishdom: Spooky Splash 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=""></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;">
									<font face="Arial" color="#ffffff" size="3"><b>
									Dear $name,<br>
									$sender is having fun playing Fishdom: Spooky Splash!<br>
									$sender sent you this photo of the spooktacular fish tank from the game along with this message:<br>
									$text
									</b></font>
								</td>
							</tr>
							<tr height="10">
								<td background="cid:top">
								</td>
							</tr>
						</table>
					</td>
				</tr>
				
				<tr height="480">
					<td width="63"><img src="cid:left" width="63" height="480" alt=""></td>
					<td width="640"><img src="cid:$image" width="640" height="480" alt=""></td>
					<td width="71"><img src="cid:right" width="71" height="480" alt=""></td>
				</tr>
				
				<tr height="258">
					<td colspan="3" background="cid:footer" align="center" valign="top" style="padding: 0px 90px 0px 90px;">
						<br>
						<font face="Arial" color="#ffffff" size="3"><b>
						Create your own spooky aquarium! Have fun taking care of quirky tropical fishies and adding boo-tiful accessories to the virtual tank of your dreams! 
						Download the game right now – it’s free to try!
						</b></font>
						<br><br>
						<a href="http://playrix.com/fishdom-spooky-splash.html"><img src="cid:download" width="246" height="72" alt="Download" border="0"></a>
					</td>
				</tr>
			</table>
			<br><br>
		</td>
	</tr>
</table>
</body>
</html>
]]
	return string.gsub(html, "%$(%w+)", function(s) return matches[s] end)
end
