function show_error(field, msg){
	modal_window({
		message: '<div class="alert alert-danger">' + msg + '</div>',
		title: 'Error in ' + field,
		close: function(){
			$j('#' + field).focus();
			$j('#' + field).parents('.form-group').addClass('has-error');
		}
	});
	
	return false;
}

$j(function(){
	$j('#amount').prop('readonly' , true);
	
	$j('#date_depart-dd, #date_depart-mm, #date_depart').change(function(){
		var dds = get_date('date_depart');
		var ddr = get_date('date_retour');
		
		var today = new Date();
		var jourdds = Math.floor((ddr - dds) / 1000 / 60 / 60 / 24);
		
		$j('#amount').val(jourdds);
	});
	
	$j('#date_depart').change();
	//$j('#date_fin').change();
	
});



$j(document).ready(function(){
	$j('#insert,#update').click(function(){
		var amount=$j('#amount').val();
		if($j.isNumeric(amount))
		{
			localStorage.setItem('expense_amount', amount);
		}
		else
		{
			localStorage.removeItem('expense_amount');
		}
	});
});


