<?php
mt_srand();
$index = mt_rand(1, 9999);
$listing_for = __('listing_for', true);
?>
<br/>
<div id="ylContainer_<?php echo $index;?>" class="ylContainer">
	<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout']. '/elements/header.php';?>
	<div class="ylMain">
		<?php
		if(!empty($tpl['arr']))
		{ 
			?>
			<div class="ylProducts">
				<div class="ylProductsInner">
					<?php
					foreach($tpl['arr'] as $v)
					{
						$image = PJ_INSTALL_URL . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout'] . '/img/no_img.png';
						if(!empty($v['image']))
						{
							if(is_file(PJ_INSTALL_PATH . $v['image']))
							{
								$image = PJ_INSTALL_URL . $v['image'];
							}
						}
						$listing_title = pjSanitize::html(stripslashes($v['title']));
						if ($tpl['option_arr']['o_seo_url'] == 'No')
						{
							$url = $_SERVER['SCRIPT_NAME'] . '?controller=pjListings&amp;action=pjActionView&amp;id=' . $v['id'] .(isset($_GET['iframe']) ? '&amp;iframe' : NULL);
						} else {
							$path = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
							$path = $path == '/' ? '' : $path;
							$url = $path .'/'. $controller->friendlyURL($v['title']) . "-". $v['id'] . ".html";
						}
						$price = '';
						$build = array();
						if($v['for'] == 'sale' && !empty($v['listing_price']))
						{
							$price = pjUtil::formatCurrencySign(number_format($v['listing_price'], 0, '.', ','), $tpl['option_arr']['o_currency']);
						}else{
							if($v['min_price'] != '' || $v['max_price'] != '')
							{
								if($v['min_price'] == $v['max_price'])
								{
									$price = pjUtil::formatCurrencySign(number_format($v['min_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' ' . __('front_per_week', true);
								}else{
									$price = pjUtil::formatCurrencySign(number_format($v['min_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' - ' . $price = pjUtil::formatCurrencySign(number_format($v['max_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' ' . __('front_per_week', true);
								}
							}
						}
						if(!empty($v['listing_year']))
						{
							$build[] = $v['listing_year'];
						}
						if(!empty($v['listing_model']))
						{
							$build[] = $v['listing_model'];
						}
						?>
						<div class="ylProduct">
							<div class="ylProductHead">
								<h2><?php echo $listing_title;?></h2>
							</div><!-- /.ylProductHead -->
			
							<div class="ylProductMedia">
								<img src="<?php echo $image;?>" alt="<?php echo $listing_title;?>">
							</div><!-- /.ylProductMedia -->
			
							<div class="ylProductContent">
								<p class="ylProductControls">
									<a href="<?php echo $url;?>" class="ylBtn ylBtnDetails"><?php __('front_more_details');?></a>
								</p>
								<div class="ylProductStat">
									<ul>
										<?php
										if($price != '')
										{ 
											?><li><?php echo $price;?></li><?php 
										}
										
										if(!empty($build))
										{
											?><li><?php echo join(', ', $build);?></li><?php 
										}
										if($v['listing_length'] != '')
										{
											$enum_arr = __('enum_arr', true);
											?><li><?php echo pjSanitize::html($v['listing_length']) . ' ' .  $enum_arr[$tpl['option_arr']['o_length']];?></li><?php
										}
										?>
									</ul>
								</div>
							</div><!-- /.ylProductContent -->
						</div><!-- /.ylProduct -->
						<?php
					} 
					?>
				</div>
			</div><!-- /.ylProducts -->
		
			<?php 
			include_once ROOT_PATH . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout']. '/elements/paginator.php';
		}else{
			__('front_yachts_not_found');
		} 
		?>
	</div><!-- /.ylMain -->
</div>
<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout']. '/elements/loadjs.php';?>