<?php
// calculate account type to use for stats below
$nonLevelId = 0;
$nonLevelIdRs = (int)$db->getValue('SELECT id FROM user_level WHERE level_type = \'nonuser\' ORDER BY id ASC LIMIT 1');
if($nonLevelIdRs)
{
	$nonLevelId = (int)$nonLevelIdRs;
}
$freeLevelId = 1;
$freeLevelIdRs = (int)$db->getValue('SELECT id FROM user_level WHERE level_type = \'free\' AND id > 0 ORDER BY id ASC LIMIT 1');
if($freeLevelIdRs)
{
	$freeLevelId = (int)$freeLevelIdRs;
}
$paidLevelId = 2;
$paidLevelIdRs = (int)$db->getValue('SELECT id FROM user_level WHERE level_type = \'paid\' AND id > 0 ORDER BY id ASC LIMIT 1');
if($paidLevelIdRs)
{
	$paidLevelId = (int)$paidLevelIdRs;
}
$daysToKeepFilesNon = UserPeer::getDaysToKeepInactiveFiles($nonLevelId);
$daysToKeepFilesFree = UserPeer::getDaysToKeepInactiveFiles($freeLevelId);
$daysToKeepFilesPaid = UserPeer::getDaysToKeepInactiveFiles($paidLevelId);
$maxUploadSizeFree = UserPeer::getMaxUploadFilesize($freeLevelId);
$maxUploadSizePaid = UserPeer::getMaxUploadFilesize($paidLevelId);
?>

<script>
    var milisec = 0;
    var seconds = <?php echo (int) $additionalSettings['download_wait']; ?>;

    function display()
    {
        $('.btn-free').hide();
        $('.download-timer').show();
        if (seconds == 0)
        {
            $('#para').removeClass('disabled');
			$('#container').removeClass('hidden');
			var bar = new ProgressBar.Path('#check', {
			  easing: 'easeInOut',
			  duration: 1400
			});
    
			bar.set(0);
			bar.animate(1.0);  // Number from 0.0 to 1.0
			$('.download-timer-seconds').remove();
			$('.download-timer').html("<a href='<?php echo validation::safeOutputToScreen($file->getNextDownloadPageLink()); ?>'><?php echo pluginHelper::pluginEnabled('mediaplayer') ? t("download_view_now", "download/view now") : t("download_now", "download now"); ?></a>");
        }
        else
        {
            $('.download-timer-seconds').html(seconds);
        }
        seconds--;
    }

    $(document).ready(function() {
    <?php if ((int) $additionalSettings['download_wait'] > 0): ?>
            $('.download-timer-seconds').html(<?php echo (int) $additionalSettings['download_wait']; ?>);
    <?php endif; ?>
        display();
        countdownTimer = setInterval('display()', 1000);
    });
    
   $(document).ready(function() {
    var timer = (seconds * 1100) + 1000;
	var circle = new ProgressBar.Circle('#progress', {
        color: '#C9E1FF',
        duration: timer,
		trailColor: '#4a8bfc',
		trailWidth: 2,
		strokeWidth: 3,
		easing: 'easeInOut',
    });

    circle.animate(1);
    });
</script>
<?php
if (isset($downloadPage['additional_javascript_code']))
{
    echo $downloadPage['additional_javascript_code'];
}
?>
<?php
// figure out upgrade url
$auth = Auth::getAuth();
$url  = coreFunctions::getCoreSitePath() . "/register." . SITE_CONFIG_PAGE_EXTENSION . "?f=" . urlencode($file->shortUrl);
if ($auth->loggedIn == true)
{
    $url = coreFunctions::getCoreSitePath() . "/upgrade." . SITE_CONFIG_PAGE_EXTENSION;
}
$report = coreFunctions::getCoreSitePath() . "/report_file." . SITE_CONFIG_PAGE_EXTENSION;
?>
<div class="download">
  <div class="row">
    <div class="file-info">
	  <div class="icon">
	    <img src="<?php echo $file->getLargeIconPath(); ?>" width="100" alt="<?php echo strtolower($file->extension); ?>"/>
	  </div>
	  <div class="name">
	    <h4><?php echo wordwrap(validation::safeOutputToScreen($file->originalFilename), 28, ' ', true); ?> <small><?php echo coreFunctions::formatSize($file->fileSize); ?></small></h4>
	  </div>
	  <div class="share">
	    <!-- Go to www.addthis.com/dashboard to customize your tools --> <div class="addthis_inline_share_toolbox"></div>
	  </div>
	  <div class="report">
	    <a href="<?php echo $report; ?>">Report <i class="la la-arrow-right"></i></a>
	  </div>
	</div>
  </div>
</div>
<div class="col-md-12">
  <div class="row">
	<div class="col-md-4">
	  <div class="relk">
		 ADS HERE
	  </div>
	</div>
	<div class="col-md-4">
	  <div class="relk">
		 ADS HERE
	  </div>
	</div>
	<div class="col-md-4">
	  <div class="relk">
		 ADS HERE
	  </div>
	</div>
  </div>
</div>
</div>
</div>
<div class="clearfix pt50"></div>
<div class="dl-continue">
  <div class="container">
	  <div class="col-md-12">
	    <div class="next">
		  <div class="time">
		    <div class="circle" id="progress"></div>
			<div class="download-timer-seconds"></div>
			<div id="container" class="hidden">
              <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" version="1.1" height="64" viewBox="0 0 64 64" enable-background="new 0 0 64 64">
                <g>
                  <path fill-opacity="0" stroke-width="2" stroke="#eee" d="m16.074,55.049c0.369,0.534 0.975,0.838 1.615,0.838 0.133,0 0.269-0.049 0.404-0.076 0.098,0.016 0.193,0.064 0.292,0.064 0.575,0 1.134-0.249 1.526-0.681l43.514-43.521c0.785-0.784 0.785-2.056 0-2.841-0.784-0.784-2.056-0.784-2.84,0l-42.52,42.526-14.34-14.337c-0.784-0.785-2.056-0.785-2.84,0-0.785,0.784-0.785,2.056 0,2.841l15.189,15.187z"/>
                  <path id="check" fill-opacity="0" stroke-width="3" stroke="#C9E1FF" d="m16.074,55.049c0.369,0.534 0.975,0.838 1.615,0.838 0.133,0 0.269-0.049 0.404-0.076 0.098,0.016 0.193,0.064 0.292,0.064 0.575,0 1.134-0.249 1.526-0.681l43.514-43.521c0.785-0.784 0.785-2.056 0-2.841-0.784-0.784-2.056-0.784-2.84,0l-42.52,42.526-14.34-14.337c-0.784-0.785-2.056-0.785-2.84,0-0.785,0.784-0.785,2.056 0,2.841l15.189,15.187z"/>
                </g>
              </svg>
            </div>
		  </div>
		  <div class="text">
		    <h4>Do you hate waiting !?</h4>
			<a href="<?php echo $url; ?>"> Get Premium & Download Directly <i class="la la-arrow-right"></i></a>
		  </div>
		  <div class="para">
		    <a href="<?php echo $file->getNextDownloadPageLink(); ?>" id="para" class="btn btn-dl-first btn-block disabled"> Get Download Link <i class="la la-download"></i></a>
		  </div>
		</div>
	</div>
  </div>
</div>