// JavaScript Document
	function AfficheProgramme(ID){
			$.ajax({
			url: "ajax/modeles.php",
			global: false,
      type: "POST",
      data: ({id_formation : ID}),
      dataType: "html",
			success: function(reponse){
								document.getElementById('ajax_fiche').innerHTML=reponse;
						}
		 });
	}

	function SwitchProgramme(ID,id_categorie){
			$.ajax({
			url: "ajax/modeles.php",
			global: false,
      type: "POST",
      data: ({id_courant : ID,id_categorie : id_categorie}),
      dataType: "html",
			success: function(reponse){
								document.getElementById('ajax_fiche').innerHTML=reponse;
						}
		 });
	}
	
	function CreateSwitch(ID){
			$.ajax({
			url: "ajax/switch.php",
			global: false,
      type: "POST",
      dataType: "html",
			success: function(reponse){
								//$("#pagination").html(reponse);
								document.getElementById('pagination').innerHTML=reponse;
						}
		 });
	}
	
// Agenda
// Fonction pour différentes actions sur les enregsitrements videos
	function Sauvegarde_agenda(champ,valeur){
		if (champ=='mois'){document.getElementById('select_mois').value = valeur;}
		for(i=0;i<document.frm_options.select_categorie.length;++i){
			if(document.frm_options.select_categorie.options[i].selected == true)
				{
					var categorie = document.frm_options.select_categorie.options[i].value
				}
		}
		for(i=0;i<document.frm_options.select_years.length;++i){
			if(document.frm_options.select_years.options[i].selected == true)
				{
					var annee = document.frm_options.select_years.options[i].value
				}
		}
		for(i=0;i<document.frm_options.select_tri.length;++i){
			if(document.frm_options.select_tri.options[i].selected == true)
				{
					var tri = document.frm_options.select_tri.options[i].value
				}
		}
		var mois = document.getElementById('select_mois').value;
		$.ajax({
			 type: "GET",
			 url: "ajax/agenda.php?action=sauvegarde&champ="+champ+"&valeur="+valeur+"&id_categorie="+categorie+"&annee="+annee+"&mois="+mois+"&tri="+tri,
			 success: function(msg){
			 var reponse=msg.split('@');
			 	 $('#liste_agenda').html(reponse[0]);
				 document.getElementById('liste_agenda').innerHTML=reponse[0];
				 document.getElementById('liste_mois').innerHTML=reponse[1];
			 	 $('#liste_mois').html(reponse[1]);
			 }
		 });
	}
	
	function CheckFormContact(formulaire)
{
        var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
				var dn = /[0-3]\d\/[01]\d\/\d{4}/;///\b(0?[1-9]-|[12][0-9]-|3[01]\/)(0?[1-9]-|1[0-2]\/)(\d{2}|\d{4})\b/;
				if (formulaire=='frm_rappel'){
					if (document.frm_rappel['txt_nom'].value.length < 3 )
					{
									jAlert("Votre nom est obligatoire.", "Erreur", function() {
											document.frm_rappel['txt_nom'].focus();
									});
									return false;
					}
					if (document.frm_rappel['txt_telephone'].value.length < 3 )
					{
									jAlert("Votre numéro de téléphone est obligatoire.", "Erreur", function() {
											document.frm_rappel['txt_telephone'].focus();
									});
									return false;
					}
				}else if (formulaire=='frm_contact'){
						if (document.frm_contact['txt_nom'].value.length < 3 )
					{
									jAlert("Votre nom est obligatoire.", "Erreur", function() {
											document.frm_contact['txt_nom'].focus();
									});
									return false;
					}
						if (document.frm_contact['txt_prenom'].value.length < 3 )
					{
									jAlert("Votre prenom est obligatoire.", "Erreur", function() {
											document.frm_contact['txt_prenom'].focus();
									});
									return false;
					}
						if (document.frm_contact['txt_adresse'].value.length < 3 )
					{
									jAlert("Votre adresse est obligatoire.", "Erreur", function() {
											document.frm_contact['txt_adresse'].focus();
									});
									return false;
					}
						if (document.frm_contact['txt_cp'].value.length < 5 )
					{
									jAlert("Veuillez indiquer votre code postal.", "Erreur", function() {
											document.frm_contact['txt_cp'].focus();
									});
									return false;
					}
						if (document.frm_contact['txt_ville'].value.length < 3 )
					{
									jAlert("Votre ville est obligatoire.", "Erreur", function() {
											document.frm_contact['txt_ville'].focus();
									});
									return false;
					}

						if (!document.frm_contact['txt_email'].value.match(re))
					{
									jAlert("L'adresse email n'est pas valide.", "Erreur", function() {
											document.frm_contact['txt_email'].focus();
									});
									return false;
					}
				}else  if (formulaire=='frm_newsletter'){
										if (document.frm_newsletter['txt_nom'].value.length < 3 )
					{
									jAlert("Votre nom est obligatoire.", "Erreur", function() {
											document.frm_newsletter['txt_nom'].focus();
									});
									return false;
					}
						if (document.frm_newsletter['txt_prenom'].value.length < 3 )
					{
									jAlert("Votre prenom est obligatoire.", "Erreur", function() {
											document.frm_newsletter['txt_prenom'].focus();
									});
									return false;
					}

						if (!document.frm_newsletter['txt_email'].value.match(re))
					{
									jAlert("L'adresse email n'est pas valide.", "Erreur", function() {
											document.frm_newsletter['txt_email'].focus();
									});
									return false;
					}
				<!-- Formulaire d'inscription -->
				}else if (formulaire=='frm_inscription'){
						if (document.frm_inscription['txt_nom'].value.length < 3 )
					{
									jAlert("Votre nom est obligatoire.", "Erreur", function() {
											document.frm_inscription['txt_nom'].focus();
									});
									return false;
					}
						if (document.frm_inscription['txt_prenom'].value.length < 3 )
					{
									jAlert("Votre prenom est obligatoire.", "Erreur", function() {
											document.frm_inscription['txt_prenom'].focus();
									});
									return false;
					}
						if (document.frm_inscription['txt_cp'].value.length < 5 )
					{
									jAlert("Veuillez indiquer votre code postal.", "Erreur", function() {
											document.frm_inscription['txt_cp'].focus();
									});
									return false;
					}
						if (document.frm_inscription['commune'].value.length < 3 )
					{
									jAlert("Votre ville est obligatoire.", "Erreur", function() {
											document.frm_inscription['commune'].focus();
									});
									return false;
					}
						if (document.frm_inscription['txt_telephone'].value.length < 3 )
					{
									jAlert("Votre téléphone est obligatoire.", "Erreur", function() {
											document.frm_inscription['txt_telephone'].focus();
									});
									return false;
					}

						if (!document.frm_inscription['txt_email'].value.match(re))
					{
									jAlert("L'adresse email n'est pas valide.", "Erreur", function() {
											document.frm_inscription['txt_email'].focus();
									});
									return false;
					}
						if (!document.frm_inscription['txt_date_naissance'].value.match(dn))
					{
									jAlert("La date de naissance doit être sous la forme: 31/01/1965.", "Erreur", function() {
											document.frm_inscription['txt_date_naissance'].focus();
									});
									return false;
					}
				}
				
}

