<?php
/**
 * @package Sj Contact Ajax
 * @version 1.3.2
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2013 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */

defined('_JEXEC') or die;

$tag_id = 'contact_ajax' . time() . rand();
JHtml::stylesheet('modules/' . $module->module . '/assets/css/jquery-ui.min.css');
//JHtml::stylesheet('modules/' . $module->module . '/assets/css/font-awesome.css');
JHtml::stylesheet('modules/' . $module->module . '/assets/css/styles.css');

JHtml::script('modules/' . $module->module . '/assets/js/bootstrap-tooltip.js');
JHtml::script('modules/' . $module->module . '/assets/js/jquery-ui.min.js');
//JHTML::_('behavior.calendar');
$cls = 'map-canvas-' . time() . rand();
ob_start();
?>

<?php
$css = ob_get_contents();
ob_end_clean();
$document = JFactory::getDocument();
$document->addStyleDeclaration($css);
?>

<?php
$uri = JURI::getInstance();
$uri->setVar('contact_ajax', rand(100000, 999999) . time());
$uri->setVar('ctajax_modid', $module->id);
$options = $params->toObject();
?>

<?php if (!empty($options->pretext)) { ?>
	<div class="pre-text"><?php echo $options->pretext; ?></div>
<?php } ?>

	<!--[if lt IE 9]>
	<div class="contact-ajax msie lt-ie9" id="<?php echo $tag_id; ?>"><![endif]-->
	<!--[if IE 9]>
	<div class="contact-ajax msie" id="<?php echo $tag_id; ?>"><![endif]-->
	<!--[if gt IE 9]><!-->
	<div class="contact-ajax contact-popup" id="<?php echo $tag_id; ?>"><!--<![endif]-->
		<a class="btn-contact btn-default" data-bs-toggle="modal" data-bs-target="#contact-popup" href="#contact-popup" title="<?php echo JText::_('CONTACT_US');?>"><?php echo JText::_('CONTACT_US');?></a>
		<!-- Modal -->
		<div class="modal fade" id="contact-popup" tabindex="-1" aria-labelledby="login" aria-hidden="true">
		  <div class="modal-dialog">
			<div class="modal-content">			  
				<div class="modal-body">
					<div class="ctajax-wrap">
						<div class="ctajax-element">
							<div class="el-inner cf">
								<div class="el-form cf">
									<form class="el-ctajax-form" id="el_ctajax_form" method="post" action="#">
										<div class="el-control">
											<label for="cainput_name"><?php echo JText::_('NAME_LABEL'); ?></label>
											<input type="text" autocomplete="off" name="cainput_name" class="el-input" id="cainput_name">
											<span class="ca-tooltip" title="" data-toggle="tooltip"
												  data-original-title="<?php echo JText::_('NAME_ERROR'); ?>">
												<i class="fa fa-exclamation-circle el-error"></i>
											</span>
											<i class="fa fa-check-circle-o el-ok"></i>
										</div>
										<div class="el-control ">
											<label for="cainput_email"><?php echo JText::_('EMAIL_LABEL'); ?></label>
											<input autocomplete="off" type="text" name="cainput_email" class="el-input" id="cainput_email">
											<span class="ca-tooltip" title="" data-toggle="tooltip"
												  data-original-title="<?php echo JText::_('EMAIL_ERROR'); ?>">
												<i class="fa fa-exclamation-circle el-error"></i>
											</span>
											<i class="fa fa-check-circle-o el-ok"></i>
										</div>
										<div class="el-control">
											<label for="cainput_subject"><?php echo JText::_('SUBJECT_LABEL'); ?></label>
											<input type="text" autocomplete="off" name="cainput_subject" class="el-input" id="cainput_subject">
											<span class="ca-tooltip" title="" data-toggle="tooltip"
												  data-original-title="<?php echo JText::_('SUBJECT_ERROR'); ?>">
												<i class="fa fa-exclamation-circle el-error"></i>
											</span>
											<i class="fa fa-check-circle-o el-ok"></i>
										</div>
										<div class="el-control">
											<label for="cainput_date"><?php echo JText::_('DATE_LABEL'); ?></label>
											<input type="text" autocomplete="off" name="cainput_date" class="el-input" id="cainput_date">
											<span class="ca-tooltip" title="" data-toggle="tooltip"
												  data-original-title="<?php echo JText::_('DATE_ERROR'); ?>">
												<i class="fa fa-exclamation-circle el-error"></i>
											</span>
											<i class="fa fa-check-circle-o el-ok"></i>
										</div>
										<div class="el-control">
											<label for="cainput_message"><?php echo JText::_('MESSAGE_LABEL'); ?></label>
											<textarea name="cainput_message" maxlength="1000" class="el-input" id="cainput_message"></textarea>
											<span class="ca-tooltip" title="" data-toggle="tooltip"
												  data-original-title="<?php echo JText::_('MESSAGE_ERROR'); ?>">
												<i class="fa fa-exclamation-circle el-error"></i>
											</span>
											<i class="fa fa-check-circle-o el-ok"></i>
										</div>
										
										<?php
										if ($captcha_dis == 1) {
											if ($captcha_disable == 1 && $user->id != 0) {
											} else {
												if ($captcha_type == 1) {
													?>
													<div class="el-control captcha-form">
														<?php JFactory::getApplication()->triggerEvent('showCaptcha', array($module->id)); ?>
													</div>
													<div class="el-control ">
														<label for="cainput_captcha"><?php echo JText::_('CAPTCHA_LABEL'); ?></label>
														<input type="text" name="cainput_captcha" maxlength="6" class="el-input" id="cainput_captcha"
															   placeholder="<?php echo JText::_('CAPTCHA_LABEL'); ?>">
														<i class="icon-spinner  icon-large icon-spin el-captcha-loadding"></i>
														<span class="ca-tooltip" title="" data-toggle="tooltip"
															  data-original-title="<?php echo JText::_('CAPTCHA_ERROR'); ?>">
															<i class="fa fa-exclamation-circle el-error"></i>
														</span>
														<i class="fa fa-check-circle-o el-ok"></i>
													</div>
												<?php } else { ?>
													<div class="el-control">
														<?php
														JPluginHelper::importPlugin('captcha');
														$dispatcher = \Joomla\CMS\Factory::getApplication();
														$dispatcher->triggerEvent('onInit', ['dynamic_recaptcha_1']);
														$recaptcha = $dispatcher->triggerEvent('onDisplay', array(null, 'dynamic_recaptcha_1', 'class=""'));
														echo (isset($recaptcha[0])) ? $recaptcha[0] : '';
														?>
														
														<span class="ca-tooltip" title="" data-toggle="tooltip"
															  data-original-title="<?php echo JText::_('CAPTCHA_ERROR'); ?>">
															<i class="fa fa-exclamation-circle el-error"></i>
														</span>
														<i class="fa fa-check-circle-o el-ok"></i>
													</div>
												<?php }
											}
										}
										?>
										<?php if ($params->get('email_copy_dis') == 1) { ?>
											<div class="el-control ">
												<input type="checkbox" value="" id="contact_email_copy" name="contact_email_copy">
												<label title="" class="el-label-email-copy"
													   for="contact_email_copy"><?php echo JText::_('SEND_MAIL_COPY'); ?></label>
											</div>
										<?php } ?>
										<div class="el-control submit-bottom">
											<span class="require-check"><?php echo JText::_('REQUIRED_FIELDS'); ?></span>
											<input type="submit" value="<?php echo JText::_('SEND_MESSAGE'); ?>" id="cainput_submit">
											<span class="el-ctajax-loadding"></span>
											<span class="el-ctajax-return return-error">
												<i class="fa fa-exclamation-circle icon-large">&nbsp;&nbsp;<?php echo JText::_('MAIL_IS_NOT_SENT'); ?></i>
											</span>
											<span class="el-ctajax-return return-success">
												<i class="fa fa-check-circle-o icon-large">&nbsp;&nbsp;<?php echo JText::_('MAIL_IS_SENT'); ?></i>
											</span>
										</div>
									</form>
								</div>
							</div>
						</div>						
					</div>
				</div>			  
			</div>
		  </div>
		</div>
		<!-- EndModal -->		
	
	</div>


<?php if (!empty($options->posttext)) { ?>
	<div class="post-text"><?php echo $options->posttext; ?></div>
<?php } ?>
