/**
 * Initialisation des pages
 */
$(document).ready(function()
{
	/*
	 * SHADOWBOX
	 */
	Shadowbox.init({
		handleOversize: "drag"
	});
	
	/*
	 * Initialisation des champs date
	 */
	initDatepicker();
});


/**
 * Initialise les champs input de classe date
 */
function initDatepicker()
{	
	$('input.date, div.datepicker-inline').datepicker({
		closeText: 			'Fermer',
		prevText: 			'Précédent',
		nextText: 			'Suivant',
		currentText: 		'Courant',
		monthNames: 		['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'], 
		monthNamesShort: 	['Jan','Fév','Mar','Avr','Mai','Jun', 'Jul','Aoû','Sep','Oct','Nov','Déc'],
		dayNames: 			['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
		dayNamesShort: 		['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
		dayNamesMin: 		['Di','Lu','Ma','Me','Je','Ve','Sa'],
		weekHeader: 		'Sm',
		dateFormat: 		'dd/mm/yy',
		firstDay: 			1,
		isRTL: 				false,
		showMonthAfterYear: false,
		yearSuffix: 		'',
		changeYear: 		true,
		showOn: 			"both",
		buttonImage: 		"datepicker-btn.gif",
		buttonImageOnly: 	true,
		
		// A la selection de la date, on vérifie si le datepicker est inline (affiche un calendrier au lieu d'un champ)
		// Si c'est le cas, on met à jour le champ caché permettant de récuéprer la date sélectionnée
		onSelect: function(date, inst) {
			if ($(this).hasClass('datepicker-inline')) {
				$(this).next('.datepicker-input').val(date);
				$(this).parents('form:first').submit();
			}
		}
	});	
}


/**
 * Ouvre une fenêtre popup
 *
 * @param String 	url 	l'url de la page à afficher
 * @param String 	nom 	identifiant de la popup
 * @param int 		height 	la hauteur le la popup
 * @param int 		width 	la hauteur le la popup
 */
function popup(url, nom, height, width)
{
    window.open(url, nom, config='height=' + height + ', width=' + width + ', toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}
