<?php
/**
 * @version		$Id: view.feed.php 10381 2008-06-01 03:35:53Z pasamio $
* @package		Contact_Enhanced
 * @subpackage	Contact
 * @copyright	Copyright (C) 2006 - 2010 Ideal Custom Software Development
 * @author     Douglas Machado {@link http://ideal.fok.com.br}
 * @author     Created on 28-Jul-09
 * @license		GNU/GPL, see license.txt
 * Contact Enhanced  is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses. 
 */defined( '_JEXEC' ) or die( 'Restricted access' );

$cparams = JComponentHelper::getParams ('com_media');

if ( isset($this->msgs[0]) ) {
	if( count($this->msgs) > 1 ){
		$this->msgs = implode("\n",$this->msgs);
	}else{
		$this->msgs	= $this->msgs[0];
	}
	?>
		<script type="text/javascript">
			window.addEvent('domready', function(){
				alert('<?php echo $this->msgs;  ?>');
			});
		</script>
<?php
}

?>
<a name="ce-header"></a>
<div id="component-contact-enhanced" 
	class="ce-container<?php echo $this->params->get( 'pageclass_sfx' ) 
		. (JRequest::getVar('tmpl') ? ' ce-modal-container' : ''); ?>">
<?php
if ( $this->params->get( 'show_print', 0 )){
	require_once JPATH_COMPONENT.DS.'helper'.DS.'icon.php';
	echo '<div class="ce-print-icon-container">';
		echo JHTMLCEIcon::print_popup($this->contact,$this->params,1);
	echo '</div>';
}
?>
<?php if ( $this->params->get( 'show_page_title', 1 ) && !$this->contact->params->get( 'popup' ) && $this->params->get('page_title') != $this->contact->name ) : ?>
	<h1 class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
		<?php echo $this->params->get( 'page_title' ); ?>
	</h1>
<?php endif; ?>

<?php if ( $this->params->get( 'show_contact_list' ) && count( $this->contacts ) > 1 ) : ?>
	<div class="ce-select-contact">
		<form action="<?php echo JRoute::_('index.php?option=com_contact_enhanced&view=contact') ?>" method="post" name="selectForm" id="selectForm">
		<?php echo JText::_( 'Select Contact' ); ?>:
			<?php echo JHTML::_('select.genericlist',  $this->contacts, 'contact_id', 'class="inputbox" onchange="this.form.submit()"', 'id', 'name', $this->contact->id);?>
			<option type="hidden" name="option" value="com_contact_enhanced" />
			<?php if(JRequest::getVar('tmpl')):?>
				<input type="hidden" name="tmpl" value="<?php echo JRequest::getVar('tmpl')?>" />
			<?php endif; ?>
		</form>
	</div>
<?php endif; ?>

<?php if ( $this->contact->name && $this->contact->params->get( 'show_name' ) ) : ?>
	<div class="contentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
			<?php echo $this->contact->name; ?>
	</div>
<?php endif; ?>

<?php if ( trim($this->contact->con_position) && $this->contact->params->get( 'show_position' ) ) : ?>
	<div id="ce-con_position">
		<?php echo $this->contact->con_position; ?>
	</div>
<?php endif; ?>


<?php 
	if($this->contact->params->get( 'details_location','top' ) == 'top'){
		echo $this->loadTemplate('details');
	}
 ?>

<table width="100%" cellpadding="0" cellspacing="0" border="0" class="contentpaneopen<?php echo $this->params->get( 'pageclass_sfx' ); ?>">


<?php 
$sidebarWidth	= (int) $this->contact->params->get( 'sidebar_width','40' );
$formWidth		= 99-$sidebarWidth;
$show_sidebar	= $this->contact->params->get( 'show_sidebar',false );
?>
<tr>
	<td colspan="2">
<?php 
		if ( $this->params->get('show_map', 'beforeform') == 'beforeform' ){
			echo $this->loadTemplate('map');
		}
?>
	<table id="ce-form-container">
		<tr>
	<?php //endif;
		
		if ( ($show_sidebar == 'left' AND $this->params->get( 'show_map') == 'sidebar') OR $show_sidebar == 'left' ){
			echo $this->loadTemplate('sidebar');
		}
		
		if ( $this->contact->params->get('email_form_access_level',0) <= $this->user->aid && ($this->contact->email_to || $this->contact->user_id)){
			echo $this->loadTemplate('form');
		}else if(!$this->contact->email_to AND !$this->contact->user_id){
			echo JText::_('Please either set an email to this contact or link it to a registered user');
		}
		if ( ( $this->params->get( 'show_map') == 'sidebar') OR $show_sidebar == 'right' ){
			echo $this->loadTemplate('sidebar');
		}
		
		
	?>
		</tr>
	</table>
	<?php 
		if ( $this->params->get( 'show_map') == 'afterform' ){
			echo ''. $this->loadTemplate('map');
		}
		if($this->contact->params->get( 'details_location','top' ) == 'afterform'){
			echo $this->loadTemplate('details');
		}
		
	?>
	</td>
</tr>
</table>
</div>
