<?php
/**
* @copyright	Copyright(C) 2008-2010 Fabio Esteban Uzeltinger
* @license 		GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @email		admin@com-property.com
**/
// no direct access
defined('_JEXEC') or die;
$lang =& JFactory::getLanguage();
$thisLang = $lang->getTag();	
$templateWidth = (int)$templateDetailsWidth;
$imageWidth = 250;
$imageHeight = 190;
$divRightImageWidth = (($templateWidth - $imageWidth)-18);
$divRightImageHeight = $imageHeight+4;
$doc->addCustomTag('<link rel="stylesheet" href="components/com_properties/includes/css/pricelist.css" type="text/css" />');
?>
<div class="topbuttonslinks">
<?php
$propertyItemID=LinkHelper::getItemid('property',$thisLang);
$mapItemID=LinkHelper::getItemid('map',$thisLang);
$contactItemID=LinkHelper::getItemid('contact',$thisLang);
?>
	<div class="topbuttonslinks_details">           
		<div class="topbuttonslinks_image">
<?php
$statusp = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=600,directories=no,location=no';
$linkp = LinkHelper::getProductToolsLink('print', $Product, $this->langTag);
?>
<a href="javascript:void(0)" onclick="window.open('<?php echo $linkp;?>','win2','<?php echo $statusp; ?>');" title="<?php echo JText::_('Print'); ?>"><img src="<?php echo JURI::root().'components/com_properties/includes/img/icon-48-print.png'; ?>" alt="<?php echo JText::_('Print'); ?>" />
</a>
		</div>
		<div class="topbuttonslinks_image">
        
   
<?php 
$rutaF= JURI::base().'index.php?option=com_properties&id='.$Product->id.'&task=pdf.show&tmpl=component&'.JUtility::getToken().'=1';
$linkpdf = LinkHelper::getProductToolsLink('pdf', $Product, $this->langTag);
?>
<a href="<?php echo $linkpdf ;?>" class="modal" rel="{handler: 'iframe', size: {x: 500, y: 600}}" title="<?php echo JText::_('Download Pdf');?>">
<img src="<?php echo JURI::root().'components/com_properties/includes/img/pdfIcon.jpg'; ?>" alt="<?php echo JText::_('Download Pdf'); ?>" />
</a>
		</div>
		<div class="topbuttonslinks_image">
<?php
JHTML::_('behavior.modal'); 
$rutaC= $rutaG= JRoute::_('index.php?option=com_properties&view=contact&id='.$Product->id.'&Itemid='.$contactItemID);
?>
<a class="modal btnlnkDetail" rel="{handler: 'iframe', size: {x: 500, y: 600}}" href="<?php echo $rutaC ;?>"title="<?php echo JText::_('PROPERTIES_LIST_CONTACT'); ?>">
<img src="<?php echo JURI::root().'components/com_properties/includes/img/icon-48-send.png'; ?>" alt="<?php echo JText::_('Contact'); ?>" />
</a>
		</div>
        
        <div class="topbuttonslinks_image">
<?php
$statusp = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=600,directories=no,location=no';
$linkp = 'index.php?option=com_properties&view=property&id='.$Product->id.'&print=1&tmpl=component';
?>
<a href="javascript:void(0)" onclick="window.open('<?php echo $linkp;?>','win2','<?php echo $statusp; ?>');" title="<?php echo JText::_('Tell a friend'); ?>"><img src="<?php echo JURI::root().'components/com_properties/includes/img/tell_friend.png'; ?>" alt="<?php echo JText::_('Tell a friend'); ?>" />
</a>
		</div>
        
	</div>
</div>
<div class="property_details">
	<div class="details_title">
    	<h1><?php echo $Product->name;?></h1>
	</div>
	<div class="details_price">
		<h1>
		<?php
		if($ShowPriceInDetail){echo '<div class="product_price" >'.$show_price.'</div>';}
		?>
		</h1>
    </div>
    <div style="clear:both"></div>
        
	<div class="details_image">
	<img src="<?php echo $rout_image.$image1;?>" alt="<?php echo $Product->image1desc;?>" width="<?php echo $imageWidth;?>px" height="<?php echo $imageHeight;?>px">
	</div>
	<div class="details_left_right" style=" width:<?php echo $divRightImageWidth;?>px; height:<?php echo $divRightImageHeight;?>px;">
    	<div class="details_left">
       <?php if($Product->ref && $ShowReferenceInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_REFERENCE').' : '.$Product->ref;?>
			</div>
       <?php }?>         
       
       <?php if($Product->name_category && $ShowCategoryInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_CATEGORY').' : '.$Product->name_category;?>
			</div>
       <?php }?>
       
       <?php if($Product->name_type && $ShowTypeInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_TYPE').' : '.$Product->name_type;?>
			</div>
       <?php }?>
       
       <?php if($Product->name_country && $ShowCountryInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_COUNTRY').' : '.$Product->name_country;?>
			</div>
       <?php }?>  
			
       <?php if($Product->name_state && $ShowStateInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_STATE').' : '.$Product->name_state;?>
			</div>
       <?php }?>     
       
       <?php if($Product->name_locality && $ShowLocalityInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_LOCALITY').' : '.$Product->name_locality;?>
			</div>
       <?php }?> 
            
       <?php if($Product->address && $ShowAddressInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_ADDRESS').' : '.$Product->address;?>
			</div>
       <?php }?>        	 	
            
		</div>
        
        <div class="details_right">
		<?php if($Product->years && $ShowYearsInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_YEARS').' : '.$Product->years;?>
			</div>
		<?php }?> 
        <?php if($Product->bedrooms && $ShowBedroomsInDetail){?>        
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_BEDROOMS').' : '.$Product->bedrooms;?>
			</div>
		<?php }?> 
        
        
        <?php if($Product->bathrooms && $ShowBathroomsInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_BATHROOMS').' : '.$Product->bathrooms;?>
			</div>
		<?php }?>
        
        <?php if($Product->garage && $ShowGarageInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_GARAGE').' : '.$Product->garage;?>
			</div>
		<?php }?> 
        
        <?php if($Product->area && $ShowTotalAreaInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_TOTAL_AREA').' : '.$Product->area.' '.JText::sprintf('PROPERTIES_DETAIL_SIMBOL_AREA');?>
			</div>
		<?php }?>
        
        <?php if($Product->covered_area && $ShowCoveredAreaInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_COVERED_AREA').' : '.$Product->covered_area.' '.JText::sprintf('PROPERTIES_DETAIL_SIMBOL_AREA');?>
			</div>
		<?php }?>
        
         <?php if($Product->available && $ShowDetailsMarketInDetail){?>
			<div class="details_field">
			<?php echo JText::_('PROPERTIES_DETAIL_DETAILS_MARKET').' : '.JText::sprintf('PROPERTIES_DETAIL_DETAILS_MARKET'.$Product->available);?>
			</div>
		<?php }?>       	 	
            
        </div>
        
	</div><!-- details_image_right -->
    
    <div style="clear:both"></div>
    
    
    
          <?php
if($OpenHouse)
	{	
?>	    
<div style="width:100%; height:10px;"></div>
	<table class="general_details" width="100%" border="0">          
        <tr><td class="openhouse_title" colspan="2"><h3><?php echo JText::_('PROPERTIES_DETAIL_OPENHOUSE_DETAILS');?></h3></td></tr>
        <tr>
			<td class="calendar_icon">
				<div class="calendar_date">
					<div class="calendar_month">
						<span class="cal_mes">
						<?php echo JText::_(date('F',strtotime($OpenHouse->date)).'_SHORT');?>
						</span>
					</div>
					<div class="calendar_day">
						<span class="cal_dia">
						<?php echo date('d',strtotime($OpenHouse->date));?>
						</span>
					</div>
					<div style="clear:both"></div>
				</div>
			</td>
            <td valign="top">			
			<ul class="openhouse_ul">
				<li class="openhouse_li">
					<div class="openhouse_this"><?php echo JText::_('PROPERTIES_DETAIL_OPENHOUSE_THISCOMING');?> <?php echo JText::_(date('l',strtotime($OpenHouse->date)).'');?></div>
                    <div class="openhouse_datetime"><?php echo JHTML::_('date', $OpenHouse->date, JText::_('DATE_FORMAT_LC3')).', '.substr($OpenHouse->from,0,5).' '.JText::_('PROPERTIES_DETAIL_OPENHOUSE_TO').' '.substr($OpenHouse->to,0,5).' Hs.';?></div>
				</li>
			</ul>
			</td>
		</tr>
        <?php if($OpenHouse->text){ ?>
        <tr><td class="openhouse_text" colspan="2"><?php echo $OpenHouse->text; ?></td></tr>
        <?php } ?>		
	</table>   
	<div style="width:100%; height:10px;"></div>
<?php }?>  
<?php 
if($params->get('categoryToShowCalendar','-1') == $Product->cid)
{
	if($params->get('ShowPriceList'))
	{
		$rates = $Rates;
?>
<div style="padding:0px;">
	<fieldset class="adminform">    
	<legend><?php echo JText::_( 'Price List' ); ?></legend>	
    <table class="rateslist" border="0" cellpadding="0" cellspacing="0">
		<tr>    
			<td class="title"><?php echo JText::_( 'Name' ); ?></td>
			<td class="title"><?php echo JText::_( 'From' ); ?></td>
			<td class="title"><?php echo JText::_( 'To' ); ?></td>  
			<td class="title"><?php echo JText::_( 'PER_DAY' ); ?></td>
			<td class="title"><?php echo JText::_( 'PER_WEEK' ); ?></td>
	    </tr>    
<?php
	if(count($rates))
	foreach($rates as $rate)
	{
		if($rate->rateperday!=0)
		{
			$showprice = PropertiesHelper::getPriceText($rate->rateperday,'','');
		}
		echo '
		<tr>
			<td align="center">'.$rate->title.'</td>
			<td align="center">'.JHTML::_('date',$rate->validfrom, JText::_('DATE_FORMAT_LC3')).'</td>
			<td align="center">'.JHTML::_('date',$rate->validto, JText::_('DATE_FORMAT_LC3')).'</td>
			<td align="center">'.PropertiesHelper::getPriceText($rate->rateperday,'','').'</td>
			<td align="center">'.PropertiesHelper::getPriceText($rate->rateperweek,'','').'</td>
		</tr>';
	}
?>
    </table>
    </fieldset>
</div>
<div style="clear:both"></div>
<?php
	}
}
?>
    <div class="details_description"  style="width:<?php echo $templateWidth;?>px;text-align:justify">
    <div class="details_description_inner">
	<?php echo $Product->text; ?> 
    </div>
    </div>
    
    
     <div class="details_extras_text">
     <div class="details_extras_text_inner">
 <?php 
	 $ex = (array)$Product;	 
	 
	 $z=0;
	 for($i=41;$i<81;$i++)
	 	{		
		if($ex['extra'.$i])
			{
			 $extras[$z]['title'] = JText::_('PROPERTIES_DETAIL_EXTRA_'.$i).' : ';
			 $extras[$z]['value'] = $ex['extra'.$i];
			 $extras[$z]['id'] = $i;
			 $z++;
			}
	 	}
	 for($i=1;$i<41;$i++)
	 	{		
		if($ex['extra'.$i])
			{
			 $extras[$z]['title'] = '';
			 $extras[$z]['value'] = JText::_('PROPERTIES_DETAIL_EXTRA_'.$i);
			 $extras[$z]['id'] = $i;
			 $z++;
			}
	 	}	 
		$extrasTotal = count($extras);
		
		if($extrasTotal%2==0){$extrasMiddle = $extrasTotal/2;}else{$extrasMiddle = (int)(($extrasTotal/2)+1);}
		 ?> 
     <ul class="details_extras">
     <?php
	 for($x=0;$x<$extrasMiddle;$x++)
	 	{
		echo '<li>'.$extras[$x]['title'].$extras[$x]['value'].' </li>';		
		}	  	 
	 ?> 
     </ul>
     
     <ul class="details_extras">
     <?php
	 for($x=$extrasMiddle;$x<$extrasTotal;$x++)
	 	{
		echo '<li>'.$extras[$x]['title'].''.$extras[$x]['value'].' </li>';
		}	  	 
	 ?> 
     </ul>   
    </div>
    </div>
    <div style="clear:both"></div>
    
    <div class="details_images_list">           
   
   <div class="gallery clearfix"> 
<?php
foreach($this->itemimages as $image){
?>
<a href="<?php echo $rout_image.$image->name; ?>" rel="<?php echo $rel; ?>" title="<?php echo str_replace('"',' ',$image->text); ?>" >
<img width="<?php echo $WidthThumbsDetail; ?>" height="<?php echo $HeightThumbsDetail; ?>" src="<?php echo $rout_thumb.$image->name; ?>" alt="<?php echo str_replace('"',' ',$image->text); ?>"/></a>
<?php 
if($image->sector){echo JText::_('image_sector_'.$image->sector); }
?>
<?php
}
?>
<?php if ($ShowImagesSystemDetail==1) : ?> 
 <script type="text/javascript" charset="utf-8">
jQuery.noConflict();
		jQuery(document).ready(function(){
			jQuery(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'<?php echo $params->get('pretty_photo_style','facebook');?>'});
		});
		//dark_rounded facebook dark_square light_rounded light_square
		</script>
<?php endif; ?> 
    
    </div>
	</div><!-- details_images_list -->
    <div style="clear:both"></div>
    
    
    
<div class="calendarwrap">    
<?php 
if($params->get('categoryToShowCalendar','-1') == $Product->cid)
	{
$AmountMonthsCalendar=$params->get('AmountMonthsCalendar',12);
$PeriodStartDay=$params->get('PeriodStartDay',1);
$StartMonthCalendar=$params->get('StartMonthCalendar',date('m'));
$StartYearCalendar=$params->get('StartYearCalendar',date('Y'));
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'Calendar.php' ); 
$cal = new Calendar; 
$cal->setStartMonth($StartMonthCalendar);
$cal->setAmountMonths($AmountMonthsCalendar);
$cal->setPropertyId($Product->id);
echo $cal->getCurrentYearView($StartYearCalendar);	
	}
?>    
</div>   
    
<?php if($ActiveMap == 1 & $ShowMapInDetail) : 
$MapApiKey=$params->get('MapApiKey');
$MapDistance=$params->get('MapDistance',15);
$lat = $Product->lat;
$lng = $Product->lng;
if ($lat != 0 && $lng != 0) {
?> 
	<div class="details_map">
<script src="http://www.google.com/jsapi"></script>	
    <script type="text/javascript">
      Google.load('maps', '3', {
        other_params: 'sensor=false&language=<?php echo $thisLang;?>'
      });
      Google.setOnLoadCallback(initialize);	  
  function initialize() {
        map = new Google.maps.Map(document.getElementById('map'), {
          zoom: <?php echo $MapDistance;?>,
		  scrollwheel: false,
          center: new Google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>),
          mapTypeId: Google.maps.MapTypeId.ROADMAP
        });  		
		base_Icon = "<?php echo JURI::base();?>components/com_properties/includes/img/house.png";		
		shadow_Icon = "<?php echo JURI::base();?>components/com_properties/includes/img/house-shadow.png";	  
		var myLatlng = new Google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
		var marker = new Google.maps.Marker({
     	position: myLatlng, 
     	map: map,	
		shadow: shadow_Icon,
	 	icon: base_Icon 
		});		
      }
	  
</script> 
		<div id="map" style="width: 100%; height: 420px;"></div>		
		<div style="clear: both;"></div>
	</div>
<?php } ?> 
<?php endif; ?> 
<div class="details_contact">
<?php if($ShowContactInfoDetail == 1) :?> 
<?php if($Product->pf_image and $Product->pf_name and $Product->pf_phone) :?> 
<?php //print_r($Product);?>
	<div class="tools_agent">
		<div class="tools_company"><?php echo $Product->pf_name;?></div>
		<div class="tools_address"><?php echo $Product->pf_pcode. ' ' .$Product->pf_locality.', '.$Product->pf_address1;?></div>
		<div class="tools_image">
		<img class="agent" align="left" src="<?php echo JURI::root().'images/properties/profiles/'.$Product->pf_image; ?>" />
		</div>
		<div class="tools_info">
		<img align="left" src="<?php echo JURI::root().'components/com_properties/includes/img/phone-icon.jpg'; ?>" width="20" height="20">
<?php echo $Product->pf_phone;?>
		</div>
		<div class="tools_info">
		<img align="left" src="<?php echo JURI::root().'components/com_properties/includes/img/fax-icon.jpg'; ?>" width="20" height="20">
<?php echo $Product->pf_fax;?>
		</div>
		<div class="tools_info">
        <img align="left" src="<?php echo JURI::root().'components/com_properties/includes/img/2email-icon.jpg'; ?>" width="20" height="20">        
<?php $mail_img='<img class="at" align="absmiddle" src="'.JURI::root().'components/com_properties/includes/img/at.png" width="20" height="15">'; $css=str_replace('@',$mail_img,$Product->pf_email);
echo $css;?>
		</div>
	</div>
<?php endif; ?> 
<?php endif; ?> 
</div>
</div><!-- property_details -->
<div style="clear:both"></div>
<?php
/*
echo '<pre>';
print_r($this->item);
echo '</pre>';
*/
?>