<?php
mt_srand();
$index = mt_rand(1, 9999);
$listing_for = __('listing_for', true);
?>
<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']) . ' <span>' . __('front_per_week', true) . '</span>';
								}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']) . ' <span>' . __('front_per_week', true) . '</span>';
								}
							}
						}
						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">
								<a href="<?php echo $url;?>"><img src="<?php echo $image;?>" alt="<?php echo $listing_title;?>"></a>
							</div><!-- /.ylProductMedia -->
			
							<div class="ylProductContent">
								<ul>
									<?php
									if($price != '')
									{ 
										?><li class="price"><strong><?php __('front_price');?>:</strong> <?php echo $price;?></li><?php 
									}
									if(!empty($build))
									{
										?><li><strong><?php __('front_build');?>:</strong> <?php echo join(', ', $build);?></li><?php 
									}
									if($v['listing_length'] != '')
									{
										$enum_arr = __('enum_arr', true);
										?><li><strong><?php __('front_length');?>:</strong> <?php echo pjSanitize::html($v['listing_length']);?><?php echo $enum_arr[$tpl['option_arr']['o_length']];?></li><?php
									}
									?>
								</ul>
			
								<p class="ylProductControls">
									<a href="<?php echo $url;?>" class="ylBtn"><?php __('front_more_details');?></a>
								</p>
							</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';?>