function getCalendar(periode){
	$.ajax({
			type: 		"POST",
			url: 		"_lib/calendrier.php",
			data:		"periode=" + periode,
			success: function(result){
				$('#MYcalendrier').html(result);
						
				$('#next').click( function(){
					getCalendar($(this).attr('name'))
				});
				
				$('#prev').click( function(){
					getCalendar($(this).attr('name'))
				});
				
						
				$('li.itemExistingItem a').click( function(){
					$('#date').val($(this).text() + ' ' + $('#MYcalendrier h2').text());
					$('#MYcalendrier').fadeOut(500);
				});	
			}
	});
}

function sendMail(){
	$('#confirmationContent #mailfornews').val($('#mail').val());
	
	/*Forme de RDV*/
	var params = 'RDVtype='+  $('.typeRDV:checked').val();
	params += '&dateSouhaite='+ $('#date').val();
	params += '&heureDeb='+ $('#hdeb').val() + 'h' + $('#mindeb').val()
	params += '&heureFin='+ $('#hfin').val() + 'h' + $('#minfin').val()
	/* Besoin exprimés */
	params += '&matiere='+ $('#matiere').val();
	params += '&niveau='+ $('#niveau').val();
	params += '&complement='+ $('#complement').val();
	params += '&type='+ $('.is:checked').val();
	/* Coordonnées */
	params += '&civilite='+ $('#civilite').val();
	params += '&nom='+ $('#nom').val();
	params += '&prenom='+ $('#prenom').val();
	params += '&adresse='+ $('#adresse').val();
	params += '&cp='+ $('#cp').val();
	params += '&ville='+ $('#ville').val();
	params += '&mail='+ $('#mail').val();
	params += '&phone='+  $('#phone').val();
	params += '&complement2='+ $('#complement2').val();

	$.ajax({
			type: 		"POST",
			url: 		"_lib/sendContact.php5",
			data:		params,
			success: function(result){
			if (navigator.appName != "Microsoft Internet Explorer")
			{
				$.nyroModalManual({
					bgColor: '#ffffff',
					minWidth: '200px',
					minHeight: '192px',
					url: '#confirmation',
					beforeHideContent: function(elts, settings, callback){
						if ($('.confirmationContent#notIE input:checked').val() == 'yes')
						{
									$.ajax({
										type: 		"POST",
										url: 		"_lib/sendNewsletter.php",
										data:		"mail=" + $('#confirmationContent #mailfornews').val(),
										success : function(result){
											callback();
											document.location.href="index.php?validation=contact&mail=" + $('#mail').val() +"&nom="+$('#nom').val()+"&cp="+$('#cp').val();
										}
									})
						}else{	
							callback();
							document.location.href="index.php?validation=contact&mail=" + $('#mail').val() +"&nom="+$('#nom').val()+"&cp="+$('#cp').val();
						}
					}
					});
			}else{
					$('#confirmationIE').fadeIn(1000);
					$('#closeConfirmation').click( function(){
						if ($('#confirmationIE input:checked').val() == 'yes')
								{
											$.ajax({
												type: 		"POST",
												url: 		"_lib/sendNewsletter.php",
												data:		"mail=" + $('#mail').val(),
												success : function(result){
													document.location.href="index.php?validation=contact&mail=" + $('#mail').val() +"&nom="+$('#nom').val()+"&cp="+$('#cp').val();	
												}
											})
								}else{	
									document.location.href="index.php?validation=contact&mail=" + $('#mail').val() +"&nom="+$('#nom').val()+"&cp="+$('#cp').val();
								}
					
					
					});
			}
			}
	});
}