<?php	
if( ! defined( 'DATALIFEENGINE' ) ) {die( "Hacking attempt!" );}
		$gallery = '';
		$gallarr=array();
		$freeimg=array();
		$freelink=array();
		$freethumb=array();
		$im = 0;
		
	$img_query = $db->query("SELECT * FROM ". PREFIX ."_covers WHERE newsid = '".$row['id']."' ORDER BY id DESC");
    
    while ($img = $db->get_row($img_query)) {
    
    if ($img['thumb'] != '') {
    $img_thumb = "<img src='{$config['http_home_url']}uploads{$img['thumb']}' alt='{$row['title']}' />";
    } else {
    $img_thumb = "<img src='{$config['http_home_url']}uploads{$img['link']}' alt='{$row['title']}' />";
    }

if ($im == 0) {
$gallery .= <<<HTML
<li class="slide0" id="slide_s{$im}_{$row['id']}"><a href='{$config['http_home_url']}uploads{$img['link']}' onclick="return hs.expand(this)" alt='{$row['title']}'>{$img_thumb}</a></li>
HTML;
 } else {
$gallery .= <<<HTML
<li class="slide" id="slide_s{$im}_{$row['id']}"><a href='{$config['http_home_url']}uploads{$img['link']}' onclick="return hs.expand(this)" alt='{$row['title']}'>{$img_thumb}</a></li>
HTML;
 
 }
  
    $im = $im+1;
    $gallarr[]=$im;
    
    $freeimg[$im] = "<a href='{$config['http_home_url']}uploads{$img['link']}' onclick='return hs.expand(this)' alt='{$row['title']}'>{$img_thumb}</a>";
    
    $freelink[$im] = $img['link'];
    $freethumb[$im] = $img['thumb'];
    
	  }

if ($gallery != ''){
$tpl->set( '[img]', "" );
$tpl->set( '[/img]', "" );

  if (count($gallarr) == '1') {
    $radio = '';
    } else {
    $radio = '<div class="navigation">';
      for ($jm=0;$jm<count($gallarr);$jm++) {
if ($jm==0) {
$radio .= <<<HTML
<a href="#" class="slink" id="s{$jm}_{$row['id']}">{$gallarr[$jm]}</a>
HTML;
} else {
$radio .= <<<HTML
<a href="#" class="slink" id="s{$jm}_{$row['id']}">{$gallarr[$jm]}</a>
HTML;
}
      }
     $radio .= '</div>';
   }

$gall = '<ul class="gall">'.$gallery.'</ul>';

$gallblock = <<<HTML
<style>.slide{display:none;}</style>
<div class="newsslider" id="newsslider_{$row['id']}">
{$gall}{$radio}
</div>
HTML;

$tpl->set('{gallery}', $gallblock);
} else {
$tpl->set_block( "'\\[img\\](.*?)\\[/img\\]'si", "" );
}

?>		