<?php
/**
 * Joomla! component creativesocialwidget
 *
 * @version $Id: default.php 2012-04-05 14:30:25 svn $
 * @author creative-solutions.net
 * @package Creative Social Widget
 * @subpackage com_creativesocialwidget
 * @license GNU/GPL
 *
 */

$document = JFactory::getDocument();

// JHtml::_('formbehavior.chosen', 'select');

if(!J4) {
	JHtml::_('behavior.tooltip');
}

if(!J4) {
	JHtml::_('behavior.formvalidation');
}
else {
	$wa = $this->document->getWebAssetManager();
	$wa->useScript('keepalive')
		->useScript('form.validate');
}
?>
<script type="text/javascript">
<?php if(!J4) {?>
Joomla.submitbutton = function(task) {
	var form = document.adminForm;
	if (task == 'creativesocialwidgetblock.cancel') {
		submitform( task );
	}
	else {
		if (form.jform_name.value != ""){
			form.jform_name.style.border = "1px solid green";
		} 
		
		if (form.jform_name.value == ""){
			form.jform_name.style.border = "1px solid red";
			form.jform_name.focus();
		} 
		else {
			submitform( task );
		}
	}
	
}
<?php }?>
</script>

<?php if(true) {?>
<?php 
// JHtml::_('behavior.tooltip');
// JHtml::_('behavior.formvalidation');
// JHtml::_('formbehavior.chosen', 'select');
?>
<form action="<?php echo JRoute::_('index.php?option=com_creativesocialwidget&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-horizontal">
	<div class="row-fluid">
		<!-- Begin Newsfeed -->
		<div class="span10 form-horizontal">
			<fieldset>
				<div class="tab-content">
					<div class="tab-pane active" id="details">
						<div class="control-group">
							<?php 
							$k = 0;
							foreach($this->form->getFieldset() as $field): ?>
							<?php if($this->item->id == 0 && $k == 4) {$k++;continue;}?>
								<div class="control-label" style="position: relative;">
									<?php 
										echo $field->label;
										if($k == 4) {
											$db = JFactory::getDBO();
											$query = " SELECT url from #__creativesocialwidget_link_types WHERE id = '".$this->item->id_type."'";
											$db->setQuery($query);
											$url = $db->loadResult();
											$url = $url == '#' ? '' : $url;
											echo '<div style="text-decoration: underline;width: 150px;text-align: right;position: absolute;top: 5px;left: 26px;color: #08c">'.$url.'</div>';
										}
									?>
								</div>
								<div class="controls"><?php echo $field->input;?></div>
								<div style="clear: both;height: 8px;">&nbsp;</div>
							<?php 
							$k ++;
							endforeach; ?>
						</div>
					</div>
				</div>
			</fieldset>
		</div>
	</div>
<input type="hidden" name="task" value="creativesocialwidgetitem.edit" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php include (JPATH_BASE.'/components/com_creativesocialwidget/helpers/footer.php'); ?>
<?php }?>
