$(document).ready(function () {
	$(".datepicker").datepicker({ prevText: '', nextText: '', dateFormat: 'dd/mm/yy' });
	$('.requis').each(function(){
		$(this).filter('.checkbox2, .checkboxes').parent().parent().children('label').each(function(){
			texte = $(this).html() + ' <span style="color:#FF0000;">*</span>';
			$(this).html(texte);
		});
		$(this).not('.checkbox2, .checkboxes').parent().find('label').each(function(){
			texte = $(this).html() + ' <span style="color:#FF0000;">*</span>';
			$(this).html(texte);
		});
	});
	$('input[readonly=readonly]').css('background-color', '#EEEEEE').css('border', '0px').css('padding', '2px');
	$('form#AccountEditForm, form.controle').submit(function(){
		var autorise = true;
		
		$('.requis', this).each(function(){
			$(this).filter('select, input, textarea').css('background-color', '');
			
			$(this).filter('input[type=text], input[type=password]').each(function(){
				if($(this).val()=='') {
					autorise = false;
					$(this).css('background-color', '#FF9999');
				}
			});
			$(this).filter('select').each(function(){
				if($(this).val()==0) {
					autorise = false;
					$(this).css('background-color', '#FF9999');
					$('option', this).css('background-color', '#FF9999');
				}
			});
			$(this).filter('textarea').each(function(){
				if($(this).val()=='') {
					autorise = false;
					$(this).css('background-color', '#FF9999');
				}
			});
		});
		
		return autorise;
	});
	$('#btn_cancel').click(function(){
		history.back();
	});
	$('.numeric').numeric();
});