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

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

--
-- Возвращает строку с содержимым поля From
--
function EmailGetFromField()
	return "Fishdom 2 Game by Playrix"
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="237">
					<td colspan="3"><img src="cid:header" width="774" height="237" alt="" style="display:block;"></td>
				</tr>
			
				<tr height="93">
					<td width="63"><img src="cid:top-left" width="63" height="93" alt="" style="display:block;"></td>
					<td bgcolor="#54d4f1" valign="top">
						<table cellpadding="0" cellspacing="0" width="100%">
							<tr height="80">
								<td style="padding: 0px 0px 0px 0px;" bgcolor="#54d4f1">
									<div style="font: bold 14px Arial; color: #ffffff;">
									Dear $name!<br>
									$sender is enjoying Fishdom 2 and sent you a fun photo of their tank along with this message:<br>
									$text
									</div>
								</td>
							</tr>
							<tr height="13">
								<td style="font-size: 8px"><img src="cid:top" width="640" height="13" alt="" style="display:block;"></td>
							</tr>
						</table>
					</td>
					<td width="71"><img src="cid:top-right" width="71" height="93" alt="" style="display:block;"></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="86">
					<td colspan="3"><img src="cid:footer-top" width="774" height="86" alt="" style="display:block;"></td>
				</tr>
			
				<tr height="72">
					<td colspan="3" align="center" valign="top">
						<table cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td width="260"><img src="cid:footer-left" width="260" height="72" alt="" style="display:block;"></td>
								<td width="246"><a href="http://www.playrix.com/games/pc/fishdom-2.html?utm_source=fishdom2&utm_medium=link&utm_campaign=gameemail"><img src="cid:download" width="246" height="72" alt="Download Now" border="0" style="display:block;"></a></td>
								<td width="268"><img src="cid:footer-right" width="268" height="72" alt="" style="display:block;"></td>
							</tr>
						</table>
					</td>
				</tr>
				
				<tr height="100">
					<td colspan="3"><img src="cid:footer-bottom" width="774" height="100" alt="" style="display:block;"></td>
				</tr>
			</table>
			<br><br>
		</td>
	</tr>
</table>
</body>
</html>
]]
	return string.gsub(html, "%$(%w+)", function(s) return matches[s] end)
end
