<ul class="nav nav-tabs">
	<li class="active"><a href="#generalinfo" data-toggle="tab"><i class="icon-link"></i> <?php echo __('admin.url'); ?></a></li>
	<?php $i = 1; ?>
	<?php foreach($languages as $l): ?>
	<li><a href="#tab<?php echo  $i++; ; ?>" data-toggle="tab"><img src="<?php echo  URL::to_asset('image/flag_'.strtoupper($l->short)); ?>.png" title="<?php echo $l->short; ?>" style="margin-bottom:2px;" alt=""> <?php echo  $l->name ; ?></a></li>
	<?php endforeach; ?>
</ul>

<div class="tab-content">
	<div class="tab-pane active" id="generalinfo">
		<table class="table table-striped">
			<tr <?php if($errors->first('display_date')) echo 'class="error"'; ?>>
					<td style="width:300px"><?php echo __('admin.date'); ?></td>
					<td>
						<?php echo  Form::text('display_date', Input::old('display_date', str_replace('0000-00-00','',(isset($page) ? substr($page->display_date,0,10) : NULL))), array('placeholder' => 'Date', 'class' => 'datepicker')); ; ?>
						<?php echo  $errors->first('display_date', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
			<tr <?php if($errors->first('category_id')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.categorie_page_blog'); ?></td>
				<td>
					<?php echo  Form::select('category_id', $categories, Input::old('category_id', (isset($page) ? $page->category_id : NULL))); ; ?>
					<?php echo  $errors->first('category_id', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
			<tr <?php if($errors->first('url')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.adresse_page_url'); ?></td>
				<td>
					<?php echo  Form::text('url', Input::old('url', (isset($page) ? $page->url : NULL)), array('class' => 'input-xxlarge','placeholder'=>'Ex : nouveau-site-web')) ; ?>
					<?php echo  $errors->first('url', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
			<tr <?php if($errors->first('visible')) echo 'class="error"'; ?>>
				<td>En ligne?</td>
				<td>
					<?php echo  Form::select('visible', array('n'=>__('admin.non'),'y'=>__('admin.oui')) , Input::old('visible', (isset($page) ? $page->visible : NULL)),array('style'=>'width:80px')); ; ?>
					<?php echo  $errors->first('visible', '<span class="help-inline">:message</span>') ; ?>
				</td>			
			</tr>
			<tr <?php if($errors->first('is_une')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.a_la_une'); ?></td>
				<td>
					<?php echo  Form::select('is_une', array('n'=>__('admin.non'),'y'=>__('admin.oui')) , Input::old('is_une', (isset($page) ? $page->is_une : NULL)),array('style'=>'width:80px')); ; ?>
					<?php echo  $errors->first('is_une', '<span class="help-inline">:message</span>') ; ?>
				</td>			
			</tr>
			<tr <?php if($errors->first('photo')) echo 'class="error"'; ?>>
				<td style="width:300px">
					<?php if($page): ?>
					<?php echo __('admin.modifier_photo'); ?>
					<?php else: ?>
					<?php echo __('admin.ajouter_une_photo'); ?>
					<?php endif; ?>
				</td>
				<td>
					<div class="fileupload fileupload-new" data-provides="fileupload">
						<div class="input-append">
							<div class="uneditable-input span3"><i class="icon-file fileupload-exists"></i> <span class="fileupload-preview"></span></div>
							<span class="btn btn-file">
								<span class="fileupload-new"><?php echo __('admin.selectionner_photo'); ?></span><span class="fileupload-exists"><?php echo __('admin.mettre_a_jour'); ?></span>
								<input type="file" name="photo" />
							</span>
							<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><?php echo __('admin.supprimer'); ?></a>
						</div>
					</div>
			     	<span class="help-inline"><?php echo __('admin.important_photo_m'); ?></span>
			    </td>
			</tr>
			<?php if($page->photo): ?>
				<tr>
					<td><?php echo __('admin.photo_principale'); ?></td>
					<td><img src="<?php echo $photo_src; ?>?t=<?php echo time(); ?>" alt="" title="" /><br /><input type="checkbox" style="margin-bottom:4px" name="deletepicture" value="y" /> <?php echo __('admin.supprimer'); ?></td>
				</tr>
			<?php else: ?>
				<?php if($photo): ?>
				<tr>
					<td><?php echo __('admin.photo_principale'); ?></td>
					<td><b><?php echo __('admin.aucune_photo_page'); ?></b></td>
				</tr>
				<?php endif; ?>
			<?php endif; ?>
		</table>
	</div>
	<?php $i = 1; ?>
	<?php foreach($languages as $l): ?> 
	<div class="tab-pane" id="tab<?php echo $i; ?>">
		<table class="table table-striped">
			<tr <?php if($errors->first($l->short.'_title')) echo 'class="error"'; ?>>
				<td width="250px"><?php echo __('admin.nom_page'); ?> (<?php echo $l->name; ?>)</td>
				<td>
					<?php echo  Form::text($l->short.'_title', Input::old($l->short.'_title', (isset($page) ? $page->content[$l->id -1]->title : NULL)), array('class' => 'input-xxlarge')) ; ?>
					<?php echo  $errors->first($l->short.'_title', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
			<tr>
				<td colspan="2"><?php echo  Form::textarea($l->short.'_html', Input::old($l->short.'_html', (isset($page) ? $page->content[$l->id -1]->html : NULL)), array('id' => 'editor'.$l->id, 'class' => 'input-xxlarge', 'rows' => 10)) ; ?></td>
			</tr>
			<tr>
				<td colspan="2"><strong><?php echo __('admin.metadonnees'); ?></strong></td>
			</tr>
			<tr <?php if($errors->first($l->short.'_meta_titre')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.balise_meta_titre'); ?></td>
				<td>
					<?php echo  Form::textarea($l->short.'_meta_titre', Input::old($l->short.'_meta_titre', (isset($page) ? $page->content[$l->id -1]->meta_titre : NULL)), array('class' => 'input-xxlarge', 'rows' => 5)) ; ?>
					<?php echo  $errors->first($l->short.'_meta_titre', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
			<tr <?php if($errors->first($l->short.'_meta_description')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.balise_meta_description'); ?></td>
				<td>
					<?php echo  Form::textarea($l->short.'_meta_description', Input::old($l->short.'_meta_description', (isset($page) ? $page->content[$l->id -1]->meta_description : NULL)), array('class' => 'input-xxlarge', 'rows' => 5)) ; ?>
					<?php echo  $errors->first($l->short.'_meta_description', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
			<tr <?php if($errors->first($l->short.'_meta_keywords')) echo 'class="error"'; ?>>
				<td><?php echo __('admin.balise_meta_mots_cles'); ?></td>
				<td>
					<?php echo  Form::textarea($l->short.'_meta_keywords', Input::old($l->short.'_meta_keywords', (isset($page) ? $page->content[$l->id -1]->meta_keywords : NULL)), array('class' => 'input-xxlarge', 'rows' => 5)) ; ?>
					<?php echo  $errors->first($l->short.'_meta_keywords', '<span class="help-inline">:message</span>') ; ?>
				</td>
			</tr>
		</table>
	</div>
	<?php $i++; ?>
	<?php endforeach; ?>
</div>

<script type="text/javascript">
	var nb_editor = <?php echo $i; ?>;
	var cfg_editor = {
		fullPage : false,
		height : 500,
		language: '<?php echo Config::get('application.language'); ?>',
		contentsCss : '<?php echo URL::base(); ?>/bundles/backend/js/ckeditor/_samples/assets/output_xhtml.css',
		coreStyles_bold	: { element : 'span', attributes : {'class': 'Bold'} },
		coreStyles_italic : { element : 'span', attributes : {'class': 'Italic'} },
		extraPlugins : 'docprops',

		filebrowserBrowseUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/ckfinder.html',
		filebrowserImageBrowseUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/ckfinder.html?type=Images',
		filebrowserFlashBrowseUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/ckfinder.html?type=Flash',
		filebrowserUploadUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
		filebrowserImageUploadUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
		filebrowserFlashUploadUrl : '<?php echo URL::base(); ?>/bundles/backend/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
	}
	
	$('.datepicker').datepicker({
		dateFormat: 'yy-mm-d'
	});
</script>