<?php
/**
* @version		1.1
* @package		DJ Classifieds
* @subpackage	DJ Classifieds Component
* @copyright	Copyright (C) 2010 Blue Constant Media LTD, All rights reserved.
* @license		http://www.gnu.org/licenses GNU/GPL
* @autor url    http://design-joomla.eu
* @autor email  contact@design-joomla.eu
* @Developer    Lukasz Ciastek - lukasz.ciastek@design-joomla.eu
* 
* 
* DJ Classifieds is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DJ Classifieds is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DJ Classifieds. If not, see <http://www.gnu.org/licenses/>.
* 
*/

defined ('_JEXEC') or die('Restricted access');

$main_id= JRequest::getVar('cid','0','int');
$order = JRequest::getVar('order', 'name', '', 'string');

$Itemid = JRequest::getVar('Itemid', 0, 'int');
$menus	= &JSite::getMenu();
foreach($menus->_items as $m){
	if($m->link == 'index.php?option=com_djclassifieds&view=show&cid=0'){
		$Itemid=$m->id;
		break;
	}
}

?>
<div id="dj-classifieds" class="clearfix">
	<?php $modules_breadcrumb = &JModuleHelper::getModules('dj_breadcrumb');
			if(count($modules_breadcrumb)>0){
				echo '<div class="dj_breadcrumb clearfix">';
				foreach (array_keys($modules_breadcrumb) as $m){
					echo JModuleHelper::renderModule($modules_breadcrumb[$m]);
				}
				echo'</div>';		
			}
			?>
<div class="dj-category_main">
	<h2><?php echo $this->cat->name; ?></h2>
</div>
		<?php $modules = &JModuleHelper::getModules('banner_items');
			if(count($modules)>0){
				echo '<div class="banner_items clearfix">';
				$i=1;
				foreach (array_keys($modules) as $m){
					echo '<div class="banner'.$i++.'">';
					echo JModuleHelper::renderModule($modules[$m]);
					echo '</div>';
				}
				echo'</div>';		
			}
			?>
<div class="items">
<?php	
	$r=TRUE;
	?>
	<table class="dj-items" width="100%">
	<tr class="main_title">
		<th colspan="2" class="name">
			<?php if($order=="name"){$class="active";}else{$class="normal";}?><a class="<?php echo $class; ?>" href="index.php?option=com_djclassifieds&view=showlist&cid=<?php echo $main_id; ?>&order=title<?php if($sw){ echo '&search='.$sw; }?>"><?php echo JText::_('Title');?></a> 
		</th>
		<th>
			<?php if($order=="description"){$class="active";}else{$class="normal";}?><a class="<?php echo $class; ?>" href="index.php?option=com_djclassifieds&view=showlist&cid=<?php echo $main_id; ?>&order=description<?php if($sw){ echo '&search='.$sw; }?>"><?php echo JText::_('Description');?></a>			 
		</th>
		<th>
			<?php if($order=="date"){$class="active";}else{$class="normal";}?><a class="<?php echo $class; ?>" href="index.php?option=com_djclassifieds&view=showlist&cid=<?php echo $main_id; ?>&order=date<?php if($sw){ echo '&search='.$sw; }?>"><?php echo JText::_('Added');?></a> 
		</th>		
		<th colspan="2">
			<?php if($order=="display"){$class="active";}else{$class="normal";}?><a class="<?php echo $class; ?>" href="index.php?option=com_djclassifieds&view=showlist&cid=<?php echo $main_id; ?>&order=display<?php if($sw){ echo '&search='.$sw; }?>"><?php echo JText::_('Displayed');?></a>			 
		</th>	
	</tr>		
	<?php
	foreach($this->items as $i){
		$row = $r==TRUE ? '0' : '1';
		$r=!$r;
		if($i->special==1){$row.=' special';}
		echo '<tr class="row'.$row.'">';	
		echo '<td class="icon">';
		if($i->image_url!=''){
			$images=explode(';',$i->image_url);
			echo '<a href="index.php?option=com_djclassifieds&view=showitem&cid='.$i->cat_id.'&id='.$i->id.'">';			
			echo '<img src="'.JURI::base().'/components/com_djclassifieds/images/'.$images[0].'.ths.jpg"  />';
			echo '</a>';
		}else{
			echo '<img src="'.JURI::base().'/components/com_djclassifieds/images/no-image.png"  />';
		}
		echo '</td>';
		echo '<td class="name">';
		echo '<a class="title" href="index.php?option=com_djclassifieds&view=showitem&cid='.$i->cat_id.'&id='.$i->id.'&Itemid='.$Itemid.'">'.$i->name.'</a>';
		echo '</td>';
		echo '<td class="description"><a class="title" href="index.php?option=com_djclassifieds&view=showitem&cid='.$i->cat_id.'&id='.$i->id.'&Itemid='.$Itemid.'">'.$i->intro_desc.'</a></td>';
		echo '<td class="date_start">'.$i->date_start.'</td>';
		echo '<td class="display" align="center" colspan="2">'.$i->display.'</td>';			
		echo '</tr>';
	}
	?>	
	<?php
		$row = $r==TRUE ? '0' : '1';
		echo '<tr class="row'.$row.'"><td class="pag" colspan="6" >';	     
			echo $this->pagination->getPagesLinks(); 
		echo '</td></tr>';
	?>
	</table>

</div>	
</div>


