<?php
// calculate account type to use for stats below
$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;
}
$daysToKeepFiles = 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-element').hide();
        $('.time2').show();
        if (seconds == 0)
        {
            $('.time2 .download-timer-seconds').remove();
			$('.time2 p').remove();
			$('#dol').removeClass("disabled");
        }
        else
        {
            $('.download-timer-seconds').html(seconds);
        }
        seconds--;
    }

    $(document).ready(function() {
        display();
        $('.download-timer-seconds').html(<?php echo (int) $additionalSettings['download_wait']; ?>);
        countdownTimer = setInterval('display()', 1000);
    });
-->
</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="download1">
	    <a href="<?php echo validation::safeOutputToScreen($file->getNextDownloadPageLink()); ?>" id="dol" class="btn btn-block disabled btn-download"><?php echo pluginHelper::pluginEnabled('mediaplayer') ? t("download_or_view_now", "download / view now") : t("download_now", "download now"); ?> <i class="la la-arrow-right"></i></a>
	  </div>
	</div>
  </div>
</div>
<div class="row">
  <div class="col-md-8">
    <div class="fileInfo">
	  <div class="icon">
	    <img src="<?php echo $file->getLargeIconPath(); ?>" width="70" alt="<?php echo strtolower($file->extension); ?>"/>
	  </div>
	  <div class="name">
	    <h4><?php echo wordwrap(validation::safeOutputToScreen($file->originalFilename), 28, ' ', true); ?></h4>
		<p><strong>( <?php echo wordwrap($file->fileType); ?> )</strong> <span><?php echo strtolower($file->extension); ?></span></p>
	  </div>
	</div>
	<ul class="link">
	  <li><strong>File size:</strong> <?php echo coreFunctions::formatSize($file->fileSize); ?></li>
	  <li><strong>Uploaded:</strong> <?php echo coreFunctions::formatDate($file->uploadedDate); ?></li>
	</ul>
  </div>
  <div class="col-md-4">
    <h4 class="compTime">Estimated download time:</h4>
	<div class="estim">
	  <div class="free">
	    <h5>Free Download</h5>
		<p><?php
                               echo coreFunctions::calculateDownloadSpeedFormatted($file->fileSize, UserPeer::getMaxDownloadSpeed());
                               ?></p>
	  </div>
	  <div class="pro">
	    <h5>Pro Download</h5>
		<p><?php echo coreFunctions::calculateDownloadSpeedFormatted($file->fileSize, 0); ?>    </p>
	  </div>
	</div>
  </div>
  <div class="clearfix"></div>
  <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>
