<?php
include('other_header2.php');

$url = $_POST['url'];
$urlmedia = $_POST['urlmedia'];
$adtype = $_POST['adtype'];
$LINK_adtype = $adtype;
$AD_adtype = $adtype;
$AD_generalurl = $url;
$AD_mediaurl = $urlmedia;
?>
	<nav id="top_navbar" class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="margin: 0px; width: 100%;"><!-- WHITE navbar-superhero -->
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header navbar-right">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <?php
			if($LINK_adtype == 'video') {
				?>
				<button onclick="javascript:manualfunc();" id="PlayPauseButton" style="position: fixed; width: 10%; max-width: 10%; padding: 10px; top: 0px; left: 45%;" class="btn btn-success"><i class="fa fa-play"></i></button>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonv" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; bottom: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Ready</button>
				</div>
				<?php
			}
		?>
		<?php
			if($LINK_adtype == 'interstitial') {
				?>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonint" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; top: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Loading please wait...</button>
				</div>
				<?php
			}
		?>
		<?php
			if($LINK_adtype == 'banner') {
				?>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonbanner" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; top: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Loading please wait...</button>
				</div>
				<a target="_blank" href="<?php echo $AD_generalurl; ?>"><img id="bannerimageid" style="" src="<?php echo $AD_mediaurl; ?>"></a>
				<?php
			}
		?>
      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="main-nav">
			<?php
			if($LINK_adtype == 'video') {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
			<li id="areav2">
				<a href="javascript:setmute();" id="muteButton"> <i class="fa fa-volume-up"></i> / <i class="fa fa-volume-off"></i></a>
			</li>
			<li id="areav4">
				<a href="javascript:window.open('<?php echo $AD_generalurl; ?>');" id="muteButton"> <?php echo $a015;?></a>
			</li>
			</ul>
			<?php
			}elseif($LINK_adtype == 'interstitial') {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<?php
			}elseif($LINK_adtype == 'banner') {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			</ul>
			<?php
			}else {
			?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
			<li>
				<a href="#"> <i class="fa fa-plus"></i> Showing <?php echo $AD_adtype;?> AD</a>
			</li>
			</ul>
			<?php
			}
			?>
      </div><!-- /.navbar-collapse -->
    </div>
  </nav>
<div id="fullweb" style="padding: 0px;height: 100%">
<?php 
if($adtype != 'video') {
?>
<div id="notloaded" style="background: none repeat scroll 0% 0% rgb(255, 255, 255); color: rgb(0, 0, 0); padding: 0px; padding-top: 40px; height: 100%; width: 100%;">
	<p style="margin-top: 100px;">
		<center>
			<h1 id="loadtext"><i class="fa fa-circle-o-notch fa-spin"></i> Loading ...</h1>
		</center>
	</p>
</div>
<?php
}
			if($LINK_adtype == 'video') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						?>
							<!-- /.VIDEO -->
							<div style="max-height: 100%" class="cont" id="container1">&nbsp; LOADING...</div>
						<?php
						}
			}
			if($LINK_adtype == 'interstitial') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						$AD_generalurl = str_replace('&','ANDTHISISJUSTJOKESOCOMEON',$AD_generalurl);
						$AD_generalurl = str_replace('?','QUESTIONSYMBOLRIGHTHERE',$AD_generalurl);
						?>
							<!-- /.INT -->
							<iframe id="i_frame" style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=<?php echo $AD_generalurl; ?>" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
			if($LINK_adtype == 'banner') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						?>
							<!-- /.BANNER -->
							<iframe id="i_frame" style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=http://wikipedia.com" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
			?>
</div>
<?php
// FOOTER FOR HOMEPGAGE
if($LINK_adtype == 'video') {
	?>
		<script type="text/javascript" src="<?php echo $mainurl?>system/general/components/videoplayer/jwplayer.js"></script>
		<script type="text/javascript">
jwplayer.key="N8zhkmYvvRwOhz4aTGkySoEri4x+9pQwR7GHIQ==";

jwplayer("container1").setup({
  file: "<?php echo $AD_mediaurl; ?>",
  wmode: "transparent",
  screencolor: "1CAFFF",
  controls: "false",
  autostart: true,
  primary: "html",
  width: "100%",
  height: "640px"
});
 
function Forever(){
   if (innerWidth > innerHeight) {
   	document.getElementById("top_navbar").setAttribute("style","width:100%;margin: 0px;");
   }
   if (innerHeight > innerWidth) {
   	document.getElementById("top_navbar").setAttribute("style","width:100%;margin: 0px;");
   }
   document.getElementById("fullweb").setAttribute("style","padding: 0px;max-height: 100%");
   	document.getElementById("container1").setAttribute("style","width: 100%; background-color: #2B3E50; opacity: 1; height: " + innerHeight + "px;");
   $(window).resize(function() {
    	var $height = $(document).height();
    	jwplayer().resize("100%",$height);
	});
}

window.setInterval(function(){
  Forever();
}, 1000);

var controlfirst = 0;
var duration = 0;
var skip = 0;
var did = 0;
var rotate = 0;
jwplayer().onTime(function(event) {
  var remaining = Math.round(event.duration-event.position);
  if (controlfirst < 1) {
	duration = remaining;
  }
  controlfirst++;
  if (duration > <?php echo $sa['viddur'];?>){
	  var skiptime = <?php echo $sa['viddur'];?>;
  }else{
	  var skiptime = duration-1;
  }
  var Continuea = document.getElementById("areav5");
  var BVideo = document.getElementById("buttonv");
  skip = (duration - remaining);
  skiptext = (skiptime - skip);
  if (rotate == 0) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 1;
  }else if (rotate == 1) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-90"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 2;
  }else if (rotate == 2) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-180"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 3;
  }else if (rotate == 3) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-270"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 0;
  }
  if (skip > skiptime) {
  		Continuea.innerHTML = '<button onclick="javascript:document.frmvideo.submit();" id="buttonv" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; bottom: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-angle-double-right"></i> Continue</button>';
		if (did == 0) {
			<?php
			if ($sa['autocontinue'] == '1') {
			?>
				manualfunc();
  				$('#skipmodal').modal('show');
  				did = 1;
  			<?php
			}
			?>		
		}
	}
		
  	
});

window.onPause = function () {
  var progress = document.getElementById("progress");
  progress.value = "Paused";
}; 

var vis = (function(){
	var stateKey, eventKey, keys = {
		hidden: "visibilitychange",
		webkitHidden: "webkitvisibilitychange",
		mozHidden: "mozvisibilitychange",
		msHidden: "msvisibilitychange"
	};
	for (stateKey in keys) {
		if (stateKey in document) {
			eventKey = keys[stateKey];
			break;
		}
	}
	return function(c) {
		if (c) document.addEventListener(eventKey, c);
		return !document[stateKey];
	}
})();

vis(function(){
	document.title = vis() ? 'Ready' : 'Paused';
});

// to set the initial state
document.title = vis() ? 'Ready' : 'Paused';

var t=setInterval(runFunction,200);
var manualpush = 0;

function manualfunc() {
	if (jwplayer().getState() === 'PAUSED') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'BUFFERING') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'IDLE') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'PLAYING') {//PAUSE
		jwplayer().play();
		manualpush = 1;
	}
}

function setmute() {
	if (jwplayer().getMute() === true) {//NO SOUND - MUTED
		jwplayer().setMute(false);
	}else if (jwplayer().getMute() === false) {//SOUND - UNMUTED
		jwplayer().setMute(true);
	}
}

function continuewatching() {
	$('#skipmodal').modal('hide');
	manualfunc();
}

function runFunction() {
	if (jwplayer().getState() === 'BUFFERING') {//PLAY
		jwplayer().play();
	}
	if (document.title === 'Ready') {
		if (jwplayer().getState() === 'PAUSED') {//PLAY
			if (manualpush === 0) {
				jwplayer().play();
			}
		}else if (jwplayer().getState() === 'IDLE') {//PLAY
			jwplayer().play();
		}
	} else if (document.title === 'Paused') {//PAUSE
		if (jwplayer().getState() === 'PLAYING') {
				jwplayer().play();
		}
	}
	
	if (jwplayer().getMute() === true) {//NO SOUND - MUTED
		document.getElementById('muteButton').innerHTML='<i class="fa fa-volume-off"></i> Unmute';
	}else if (jwplayer().getMute() === false) {//SOUND - UNMUTED
		document.getElementById('muteButton').innerHTML='<i class="fa fa-volume-up"></i> Mute';
	}
	
	if (jwplayer().getState() === 'PAUSED') {//PAUSED
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-play"></i>';
	}else if (jwplayer().getState() === 'IDLE') {//IDLE
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-play"></i>';
	}else if (jwplayer().getState() === 'PLAYING') {//PLAYING
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-pause"></i>';
	}
}

		</script>
	<?php
}
include('other_footer2.php');
?>
