<?php

/**
 *
 * @copyright  2017-2018 izend.org
 * @version    3
 * @link       http://www.izend.org
 */
?>
<?php if ($sms_modified): ?>
<?php require_once 'dateen.php'; ?>
<p class="info" title="Last modification"><?php echo longdate_en($sms_modified); ?> at <?php echo date('H:i', $sms_modified); ?></p>
<?php endif; ?>
<p class="info">Press the assistance button <span class="btn_edit btn_help" title="Help">help</span> to toggle the display of help messages.</p>
<?php extract($errors); ?>
<form method="post" class="compact">
<input name="clang" type="hidden" value="<?php echo $clang; ?>" />
<?php if ($sms_modified): ?>
<input name="sms_modified" type="hidden" value="<?php echo $sms_modified; ?>" />
<?php endif; ?>
<p>
<?php echo $inlanguages; ?>
<span id="node_hidy" class="hidy">+</span>
</p>
<div id="node">
<p class="inlabel<?php if ($missing_title or $bad_title): ?> inerror<?php endif; ?>">Title:</p>
<p><input id="sms_title" name="sms_title" type="text" size="40" maxlength="100" value="<?php echo htmlspecialchars($sms_title, ENT_COMPAT, 'UTF-8'); ?>" title="Campaign title" onkeypress="return focusonenter(event, 'sms_cloud')"/></p>
<p class="inlabel">Cloud:</p>
<textarea id="sms_cloud" name="sms_cloud" cols="80" rows="2" title="Series of keywords for the search engine"><?php echo htmlspecialchars($sms_cloud, ENT_COMPAT, 'UTF-8'); ?></textarea>
<p class="help helptoggle">
Associate keywords to this campaign.
</p>
<p class="inlabel<?php if ($missing_subject): ?> inerror<?php endif; ?>">Subject:</p>
<textarea id="sms_subject" name="sms_subject" cols="80" rows="2" title="Just a paragraph"><?php echo htmlspecialchars($sms_subject, ENT_COMPAT, 'UTF-8'); ?></textarea>
<p class="help helptoggle">
Describe the subject of the campaign.
</p>
</div>
<p class="inlabel<?php if ($missing_text): ?> inerror<?php endif; ?>">Message:</p>
<textarea id="sms_text" name="sms_text" cols="80" rows="4" title="SMS" placeholder="Type in the text of the SMS..."><?php echo htmlspecialchars($sms_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
<p class="help helptoggle">
</p>
<p><input type="submit" class="submit submit_configure<?php if ($missing_title or $bad_title): ?> inerror<?php endif; ?>" name="sms_configure" id="sms_configure" value="Configure" title="Configure the campaign" /></p>
</form>
<?php if (!$missing_title): ?>
<?php head('javascript', 'jquery.cookie'); ?>
<script>
if ($.cookie('hidenode') == 1) {
	$('#node').hide();
}
$('#node_hidy').click(function() {
	$('#node').toggle();
	$.cookie('hidenode', $('#node').is(':hidden') ? 1 : 0, { path: '/' });
});
</script>
<?php endif; ?>
<?php
$focus=false;
if ($missing_title or $bad_title) {
	$focus='#sms_title';
}
else if ($missing_text) {
	$focus='#sms_text';
}
?>
<?php if ($focus): ?>
<script>
$(document).ready(function() {
	$('<?php echo $focus; ?>').focus();
});
</script>
<?php endif; ?>
<?php head('javascript', 'jquery.cookie'); ?>
<script>
function togglehelp() {
	$('.helptoggle').each(function() {
		$(this).toggle();
	});
	$.cookie('nommshelp', $.cookie('nommshelp') == 1 ? '0' : '1');
}

if ($.cookie('nommshelp') == 1) {
	$('.helptoggle').each(function() {
		$(this).hide();
	});
}

$('.btn_help').each(function() {
	$(this).click(function() {togglehelp();});
});
</script>
