<?php
/**
 * @version		$Id: edit.php 115 2009-06-17 07:20:36Z eddieajau $
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.DS.'helpers'.DS.'html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::stylesheet('default.css', 'administrator/components/com_quanta/media/css/');

$fields	= $this->form->getFields('jxform');

jimport('joomla.html.pane');
$pane =& JPane::getInstance('tabs');
?>

<script type="text/javascript">
function submitbutton(task)
{
	if (task == 'record.cancel' || document.formvalidator.isValid(document.adminForm)) {
		<?php echo $fields['description']->editor->save('jxform[description]'); ?>
		submitform(task);
	}
}
</script>

<?php echo $this->form->getHead(); ?>
	<fieldset>
		<?php if (is_object($this->item) && $this->item->id > 0) : ?>
		<legend><?php echo JText::sprintf('Quanta_Record_Number', $this->item->id); ?></legend>
		<?php endif; ?>

		<table class="adminform">
			<tbody>
				<tr>
					<td>
						<?php echo $fields['title']->label; ?><br />
						<?php echo $fields['title']->field; ?>
					</td>
					<td>
						<?php echo $fields['alias']->label; ?><br />
						<?php echo $fields['alias']->field; ?>
					</td>
					<td>
						<?php echo $fields['created_time']->label; ?><br />
						<?php echo $fields['created_time']->field; ?>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $fields['label']->label; ?><br />
						<?php echo $fields['label']->field; ?>
					</td>
					<td>
						<?php echo $fields['category_id']->label; ?><br />
						<?php echo $fields['category_id']->field; ?>
					</td>
					<td>
						<?php echo $fields['modified_time']->label; ?><br />
						<?php echo $fields['modified_time']->field; ?>
					</td>
				</tr>
			</tbody>
		</table>
		<div class="clr"></div>
<?php echo $pane->startPane('item-edit');
	  echo $pane->startPanel(JText::_('Quanta_Tab_Content'), 'editor-page'); ?>
		<table width="100%">
			<tbody>
				<tr valign="top">
					<td width="70%">
						<fieldset>
							<div>
								<?php echo $fields['description']->label; ?><br />
								<?php echo $fields['description']->field; ?>
							</div>
						</fieldset>
					</td>
					<td width="30%">
						<fieldset class="clearfix">
							<legend><?php echo JText::_('Quanta_Fieldset_Settings'); ?></legend>

							<ol>
								<li>
									<?php echo $fields['published']->label; ?><br />
									<?php echo $fields['published']->field; ?>
								</li>
								<li>
									<?php echo $fields['maximum_value']->label; ?><br />
									<?php echo $fields['maximum_value']->field; ?>
								</li>
								<li>
									<?php echo $fields['latest_value']->label; ?><br />
									<?php echo $fields['latest_value']->field; ?>
								</li>
								<li>
									<?php echo $fields['latest_time']->label; ?><br />
									<?php echo $fields['latest_time']->field; ?>
								</li>
							</ol>
						</fieldset>
						<fieldset class="clearfix">
							<legend><?php echo $fields['params']->label; ?></legend>

							<?php echo $fields['params']->field; ?>
						</fieldset>
					</td>
				</tr>
			</tbody>
		</table>
	<?php echo $pane->endPanel(); ?>
<?php echo $pane->endPane(); ?>

	<?php echo $fields['id']->field; ?>
	<input type="hidden" name="task" value="" />
	</fieldset>
<?php echo $this->form->getFoot(); ?>
<div class="clr"></div>

<script type="text/javascript">
// Attach the onblur event to auto-create the alias
e = document.getElementById('jxform_title');
e.onblur = function(){
	title = document.getElementById('jxform_title');
	alias = document.getElementById('jxform_alias');
	if (alias.value=='') {
		alias.value = title.value.replace(/[\s\-]+/g,'-').replace(/&/g,'and').replace(/[^A-Z0-9\~\.\-\_]/ig,'').toLowerCase();
	}
}
</script>
