$(document).ready(function() 
    { 
		init();
    } 
); 

// add new widget called repeatHeaders 

function init(){
	$(".fancy").fancybox();

	$("a[rel=fancybox]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});

	$("input[name=1ZFIDate_de_depart]").jdPicker({
		'date_format':'dd/mm/YYYY',
		'month_names':new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"),
		'short_day_names':new Array("D","L","M","M","J","V","S")
	});
	$('.date_clearer').remove();
	$('.dob').each(function(data) {
		$(this).mask("99/99/9999");
	});

}

function formOnglet1(){
	$('#f_onglet_b_contenu').fadeOut();
	$('#f_onglet_a_v').hide();
	$('#f_onglet_b').hide();
	$('#f_onglet_a_contenu').fadeIn();
	$('#f_onglet_a').show();
	$('#f_onglet_b_v').show();
}

function formOnglet2() {
	var testSend = true;
	$('.oblchmp').each(function(data) {
		$(this).remove();
	});
	$('#f_onglet_a_contenu .c_oblig')
			.each(
					function() {
						if ($(this).val() == '') {

							$(this)
									.parent()
									.append(
											'<div class="oblchmp" style="font-size: 11px; color: rgb(255, 0, 0);">Le champ \''
													+ $(this)
															.attr('name')
															.replace('1ZFI', '')
													+ '\'<br/>est obligatoire.</div>');
							testSend = false;
						}
					});
	if (testSend) {
		$('#f_onglet_a_contenu').fadeOut();
		$('#f_onglet_b_v').hide();
		$('#f_onglet_a').hide();
		$('#f_onglet_b_contenu').fadeIn();
		$('#f_onglet_b').show();
		$('#f_onglet_a_v').show();
			//$("input[name='1ZFIAdulte_1_dob']").mask("99/99/9999");
			$('.dob').each(function(data) {
				$(this).mask("99/99/9999");
			});
	}
}

function createAdult() {
	$('#f_adultes').empty();
	var html='<legend>Adulte(s) </legend>';
	for(var i=1;i<=$('#Nombre_d_adultes').val();i++){
		html+='<div class="f_label f_label1">'+i+') Civilité</div>';
		html+='<div class="f_champ f_oblig"><input type="hidden" value="" name="1ZFIAdulte_' + i + '_civ"/>';
		html+='<select class="c_oblig" size="1" name="1ZFIAdulte_' + i + '_civ" style="" class="">&nbsp;*';
		html+='<option value="">- - - - -</option>';
		html+='<option value="Mr">Mr</option>';
		html+='<option value="Mme">Mme</option>';
		html+='<option value="Melle">Melle</option>';
		html+='</select>&nbsp;*';
		html+='</div>';
		html+='<div class="f_label f_label2">Nom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIAdulte_' + i + '_nom" size="40" style="width: 125px;" class=""/>&nbsp;*';
		html+='</div>';
		html+='<div class="f_label f_label2">Prénom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIAdulte_' + i + '_prenom" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='<br style="clear: both;"/>';
		html+='<div class="f_label f_label1" style="width:68px;"></div>';
		html+='<div class="f_label f_label2">Date de naissance</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig dob" value="" name="1ZFIAdulte_'+ i +'_dob" size="40" style="width: 125px;"/>&nbsp;*';
		//html+='<input class="c_oblig" value="" name="_dob'+ i +'" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='</div>';
		html+='<br style="clear: both;"/><br/>';
	}
	$('#f_adultes').html(html);
	/*for(var i=1;i<=$('#Nombre_d_adultes').val();i++){
		$("input[name='1ZFIAdulte_"+i+"_dob']").mask("99/99/9999");
	}*/
	$('.dob').each(function(data) {
		$(this).mask("99/99/9999");
	});
}

function createBebe() {
	$('#f_bebes').empty();
	var html='<legend>Bébés(s) </legend>';
	for(var i=1;i<=$('#Nombre_bebes').val();i++){
		html+='<div class="f_label f_label1">'+i+')</div>';
		html+='<div class="f_champ f_oblig">';
		html+='</div>';
		html+='<div class="f_label f_label2">Nom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIBebe_' + i + '_nom" size="40" style="width: 125px;" class=""/>&nbsp;*';
		html+='</div>';
		html+='<div class="f_label f_label2">Prénom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIBebe_' + i + '_prenom" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='<br style="clear: both;"/>';
		html+='<div class="f_label f_label1" style="width:68px;"></div>';
		html+='<div class="f_label f_label2">Date de naissance</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig dob" value="" name="1ZFIBebe_'+ i +'_dob" size="40" style="width: 125px;"/>&nbsp;*';
		//html+='<input class="c_oblig" value="" name="_dob'+ i +'" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='</div>';
		html+='<br style="clear: both;"/><br/>';
	}
	$('#f_bebes').html(html);
	/*for(var i=1;i<=$('#Nombre_d_adultes').val();i++){
		$("input[name='1ZFIAdulte_"+i+"_dob']").mask("99/99/9999");
	}*/
	$('.dob').each(function(data) {
		$(this).mask("99/99/9999");
	});
}

function createEnfant() {
	$('#f_enfants').empty();
	var html='<legend>Enfant(s) </legend>';
	for(var i=1;i<=$('#Nombre_d_enfants').val();i++){
		html+='<div class="f_label f_label1">'+i+')</div>';
		html+='<div class="f_champ f_oblig">';
		html+='</div>';
		html+='<div class="f_label f_label2">Nom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIEnfant_' + i + '_nom" size="40" style="width: 125px;" class=""/>&nbsp;*';
		html+='</div>';
		html+='<div class="f_label f_label2">Prénom</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig" value="" name="1ZFIEnfant_' + i + '_prenom" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='<br style="clear: both;"/>';
		html+='<div class="f_label f_label1" style="width:68px;"></div>';
		html+='<div class="f_label f_label2">Date de naissance</div>';
		html+='<div class="f_champ f_oblig">';
		html+='<input class="c_oblig dob" value="" name="1ZFIEnfant_'+ i +'_dob" size="40" style="width: 125px;"/>&nbsp;*';
		//html+='<input class="c_oblig" value="" name="_dob'+ i +'" size="40" style="width: 125px;"/>&nbsp;*</div>';
		html+='</div>';
		html+='<br style="clear: both;"/><br/>';
	}
	$('#f_enfants').html(html);
	/*for(var i=1;i<=$('#Nombre_d_adultes').val();i++){
		$("input[name='1ZFIAdulte_"+i+"_dob']").mask("99/99/9999");
	}*/
	$('.dob').each(function(data) {
		$(this).mask("99/99/9999");
	});
}	


