<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php $allParams = $this->allParams; ?>
<div class="landing_banner">
  <div class="landing_banner_img" id="landing_banner_img">
		<?php for($i=1;$i<=4;$i++) { ?>
			<?php $bannerImage = @$allParams['bannerimage'.$i] ? @$allParams['bannerimage'.$i] : ''; ?>
			<?php if(!empty($bannerImage)) { ?>
				<div class="_img" style="opacity:<?php if($i == 1) { ?>1<?php } else { ?>0<?php } ?>;background-image: url('<?php echo $this->layout()->staticBaseUrl . $bannerImage; ?>');"></div>
			<?php } ?>
		<?php } ?>
  </div>
  <div class="landing_banner_content">
    <?php if($allParams['heading']) { ?>
      <h1 class="wow slideInDown"><?php echo $this->translate($allParams['heading']); ?></h1>
    <?php } ?>
    <?php if($allParams['description1'] || $allParams['description2'] || $allParams['description3'] || $allParams['description4']): ?>
			<div class="container">
				<?php $typewrite = '';
					$counter = 0;
					if($allParams['description1']) {
						$counter++;
						$typewrite .= '"'.$this->string()->escapeJavascript($this->translate($allParams['description1'])).'"';
					}
					if($allParams['description2']) {
						$counter++;
						$typewrite .= ', "'.$this->string()->escapeJavascript($this->translate($allParams['description2'])).'"';
					}
					if($allParams['description3']) {
						$counter++;
						$typewrite .= ', "'.$this->string()->escapeJavascript($this->translate($allParams['description3'])).'"';
					}
					if($allParams['description4']) {
						$counter++;
						$typewrite .= ', "'.$this->string()->escapeJavascript($this->translate($allParams['description4'])).'"';
					}
				?>
				<?php if($counter != 1) { ?>
					<p class=" typewrite" data-period="2000" data-type='[ <?php echo $typewrite ?> ]'><span class="wrap"></span></p>
				<?php } else { ?>
					<p data-period="2000"><span class="wrap"><?php echo $typewrite; ?></span></p>
				<?php } ?>
			</div>
    <?php endif; ?>
  </div>
</div>
<script>
	en4.core.runonce.add(function() {
		if(scriptJquery('#landing_banner_img').find('._img').length > 1) {
			/* settings */
			var showDuration = 6000;
			var currentIndex<?php echo $this->identity; ?> = 0;
			var interval;
			/* worker */
			var showBannerImages = function() {
					var elem = scriptJquery('.landing_banner_img').children();
					elem.eq(currentIndex<?php echo $this->identity; ?>).animate({ opacity: 0 });
					currentIndex<?php echo $this->identity; ?> = currentIndex<?php echo $this->identity; ?> < elem.length - 1 ? currentIndex<?php echo $this->identity; ?>+1 : 0;
					scriptJquery(elem).eq(currentIndex<?php echo $this->identity; ?>).animate({ opacity: 1 })
			};
			/* start once the page is finished loading */
			
					interval = setInterval(showBannerImages, showDuration);
			
		} else {
			scriptJquery('#landing_banner_img').css('background-color', '#<?php echo $allParams["backgroundcolor"]; ?>');
		}
	});

	/*typewrite */
	var TxtType = function(el, toRotate, period) {
		this.toRotate = toRotate;
		this.el = el;
		this.loopNum = 0;
		this.period = parseInt(period, 10) || 2000;
		this.txt = '';
		this.tick();
		this.isDeleting = false;
	};
	TxtType.prototype.tick = function() {
		var i = this.loopNum % this.toRotate.length;
		var fullTxt = this.toRotate[i];
		if(fullTxt != '') {
			if (this.isDeleting) {
				this.txt = fullTxt.substring(0, this.txt.length - 1);
			} else {
				this.txt = fullTxt.substring(0, this.txt.length + 1);
			}
			this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
			var that = this;
			var delta = 200 - Math.random() * 100;
			if (this.isDeleting) { delta /= 2; }
			if (!this.isDeleting && this.txt === fullTxt) {
			delta = this.period;
			this.isDeleting = true;
			} else if (this.isDeleting && this.txt === '') {
			this.isDeleting = false;
			this.loopNum++;
			delta = 500;
			}
			setTimeout(function() {
			that.tick();
			}, delta);
		}
	};
	window.onload = function() {
		var elements = document.getElementsByClassName('typewrite');
		for (var i=0; i<elements.length; i++) {
		
				var toRotate = elements[i].getAttribute('data-type');
				var period = elements[i].getAttribute('data-period');
				if (toRotate) {
					new TxtType(elements[i], JSON.parse(toRotate), period);
				}
		}
		// INJECT CSS
		var css = document.createElement("style");
		css.type = "text/css";
		css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
		document.body.appendChild(css);
	};
</script>
