<?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']) . ' ' . __('front_per_week', true);
								}else{
									$price = pjUtil::formatCurrencySign(number_format($v['min_price'], 0, '.', ','), $tpl['option_arr']['o_currency']) . ' - ' . 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="ylProductMedia">
								<a href="<?php echo $url;?>">
									<img src="<?php echo $image;?>" alt="<?php echo $listing_title;?>">
								</a>
							</div><!-- /.ylProductMedia -->
							
							<div class="ylProductContent">
								<h2><a href="<?php echo $url;?>"><?php echo $listing_title;?></a></h2>
								<p>
									<?php
									if($price != '')
									{
										?><strong><?php echo $price;?></strong><?php
									}
									if(!empty($build))
									{
										echo join(', ', $build);
									}
									if($v['listing_length'] != '')
									{
										$enum_arr = __('enum_arr', true);
										echo '<br/>' . __('front_length', true) . ': ' . pjSanitize::html($v['listing_length']) . $enum_arr[$tpl['option_arr']['o_length']];
									} 
									?>
								</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';?>