// JavaScript Document

function poursuivre() {
	
	var themeTpr="";
	var themeNom="";
	$.ajax({
			type: "GET",
			url: domainecommunique+"communiques.xml",
			dataType: "xml",
			async: false,
			success: function(xml){
				$(xml).find('communique').each(function(){
				var untype = $(this).attr('gala');
				if(untype=="vrai")
				{
				listeCommunique.push($(this).text() + '.xml')
				}
				})
				},
			complete: function(){
			
		       $(listeCommunique).each(function(){
				   $.ajax({
					 type:"GET",
					  url: domainecommunique+this,
					  async: false,
					  dataType: "xml",
					  success: function(xml){
						  var commID = $(xml).find('id').text();
						  var titre = $(xml).find('titre').text();
							$('<dt></dt>')
							.html(commID)
							.appendTo('#communiques');
							$('<dd></dd>')
							.html('<a href="communiques.html?communiqueID='+commID+'">'+titre+'</a>')
							.appendTo('#communiques');
					  		} // fin 2e success
						  }) // fin 2e ajax 
					})  // fin each
			} // fin complete
			}) //fin ajax
}

function montrerCommunique(){
				//$('#gala_texte').html('<h1>COMMUNIQU&Eacute;</h1>');//uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
			   $.ajax({
					 type:"GET",
					  url: domainecommunique+communiqueID+'.xml',
					  async: false,
					  dataType: "xml",
					  success: function(xml){
						  var commID = $(xml).find('id').text();
						  var titre = $(xml).find('titre').text();
					  		var diffusion = $(xml).find('diffusion').text();
							var date = $(xml).find('date').text();
							var source = $(xml).find('source').text();
							var renseignement = $(xml).find('renseignement').text();
							var surtitre = $(xml).find('surtitre').text();
							var texteCommunique = $(xml).find('declaration').text();
							$('<p id="diffusion"></p>')
							.html(diffusion)
							.appendTo('#gala_texte');
							$('<p id="date"></p>')
							.html(date)
							.appendTo('#gala_texte');
							if(surtitre){
							$('<p id="surtitre"></p>')
							.html(surtitre)
							.appendTo('#gala_texte');
							}
							$('<p id="titre"></p>')
							.html(titre)
							.appendTo('#gala_texte');
							$('<div id="texte"></div>')
							.html(texteCommunique)
							.appendTo('#gala_texte');
							$('<p id="trente"></p>')
							.html('-- 30 --')
							.appendTo('#gala_texte');
							if(source){
							$('<p id="source"></p>')
							.html('<p><b>Source :</b></p> ' + source)
							.appendTo('#gala_texte');
							}
							if(renseignement){
							$('<p id="renseignement"></p>')
							.html('<p><b>Renseignements :</b></p> ' + renseignement)
							.appendTo('#gala_texte');
							}
							$('<p id="retour"></p>')
							.html('<a href="communiques.html">Retour aux communiqu&eacute;s</a>')
							.appendTo('#gala_texte');
							
					  		} // fin 2e success
						  }) // fin 2e ajax 
};


var listeCommunique = [];
var communiqueID = jQuery.url.param('communiqueID');
var typeCommunique = [];
var listeLien = [];
var domainecommunique = jQuery.url.attr("host"); // cette ligne lit la racine du site
//if(domainecommunique=="localhost"){domainecommunique="http://"+domainecommunique+":8888"};
if(domainecommunique=="localhost"){domainecommunique="http://"+domainecommunique+":8888"};
if(domainecommunique=="www.sergetardif.com"){domainecommunique="http://www.sergetardif.com/prod/dimanche"};
if(domainecommunique=="www.adisq.com"){domainecommunique="http://www.adisq.com"};
domainecommunique += '/presse-communiques/';

$(document).ready(
				  function(){

					  if (communiqueID){
						  montrerCommunique()
						  }
					  else{
						  poursuivre()
						  }
	}
				);


