// -----------------------------------------------------------------------------------
// SHOW RECENT POSTS (AFFIHCHER LES CONSIGNATIONS RÉCENTES)
// -----------------------------------------------------------------------------------
// This function takes a blogger-feed in JSON
// format and displays it.
//
// Version: 2.0                        (2fr.0 Mise en forme et adaptation francophone)
// Date:    2006-12-01                 (2007-01-25)
// Author:  Hans Oosting               (Alain Cloutier)
// URL:     beautifulbeta.blogspot.com (technofocus.blogspot.com)
// ------------------------------------------------------------------------------------
// Modifié par Sébastien TRANCHANT pour http://echiquier.niortais.free.fr/



function cellOver(o) {
   o.style.background='#FFFFCC';
}
function cellOut(o) {
   o.style.background='#FFFFFF';
}


function showrecentposts(json) {
  document.write('</br><a><strong>      Articles R&eacute;cents (' + numposts + ') :</strong></a></br></br>');
  for (var i = 0; i < numposts; i++) {
    var entry = json.feed.entry[i];
    var posttitle = entry.title.$t;
    var posturl;
    if (i == json.feed.entry.length) break;
    for (var k = 0; k < entry.link.length; k++) {
      if (entry.link[k].rel == 'alternate') {
        posturl = entry.link[k].href;
        break;
      }
    }
    posttitle = posttitle.link(posturl);
    
	var postdate = entry.published.$t;
    var cdyear = postdate.substring(0,4);
    var cdmonth = postdate.substring(5,7);
    var cdday = postdate.substring(8,10);
	var cdhour = postdate.substring(11,13);
	var cdminute = postdate.substring(14,16);
		
	var dtpost = new Date(0);
	dtpost.setFullYear(cdyear); 
	dtpost.setMonth(cdmonth-1);
	dtpost.setDate(cdday);
	var nmday = dtpost.getDay();
		
	var monthnames = new Array();
    monthnames[1] = "janvier";
    monthnames[2] = "f&eacute;vrier";
    monthnames[3] = "mars";
    monthnames[4] = "avril";
    monthnames[5] = "mai";
    monthnames[6] = "juin";
    monthnames[7] = "juillet";
    monthnames[8] = "ao&ucirc;t";
    monthnames[9] = "septembre";
    monthnames[10] = "octobre";
    monthnames[11] = "novembre";
    monthnames[12] = "d&eacute;cembre";
	var daynames = new Array();
    daynames[0] = "dimanche";
    daynames[1] = "lundi";
    daynames[2] = "mardi";
    daynames[3] = "mercredi";
    daynames[4] = "jeudi";
    daynames[5] = "vendredi";
    daynames[6] = "samedi";
    
    if ("content" in entry) {
      var postcontent = entry.content.$t;}
    else
    if ("summary" in entry) {
      var postcontent = entry.summary.$t;}
    else var postcontent = "";
    var re = /<\S[^>]*>/g; 
    postcontent = postcontent.replace(re, "");
    //main table
	document.write('<TABLE cellpadding="0" cellspacing="0" onMouseover="cellOver(this)" onMouseout="cellOut(this)">');
	document.write('<TR">');
	document.write('<TD WIDTH="100%"><a href="' + posturl + '" style="display: block;">');
	
		//title  table
		document.write('<TABLE cellpadding="0" cellspacing="0" WIDTH="100%">');
		document.write('<TR>');
		document.write('<TD><a href="' + posturl + '" style="display: block;">');
		//title part
		document.write('<DIV STYLE="float: Left;"><a href="' + posturl + '" style="display: block;">');
		document.write(posttitle);
		document.write('</a></DIV>');
		//date part
		document.write('<DIV STYLE="float: Right; font-size: 80%; color: #008000;"><a href="' + posturl + '" style="display: block;" class="fullgreenlink">');
		document.write(daynames[nmday] + ' ' + cdday + ' ' + monthnames[parseInt(cdmonth,10)]+ ' ' + cdyear + ' &agrave; ' + cdhour + ':' + cdminute); 
	    document.write('</a></DIV>');
	    document.write('</a></TD>');
		document.write('</TR>');
		document.write('</TABLE>');
		//end title table
	
		//description table
		document.write('<TABLE cellpadding="0" cellspacing="0">');
		document.write('<TR>');
		document.write('<TD WIDTH="30">');
		document.write('</TD>');
		document.write('<TD WIDTH="1000"><a href="' + posturl + '" style="display: block;" class="fullgreylink">');
		//document.write('<i>' + posturl + '</i>');
		document.write('<div STYLE="font-size: 80%;color: #808080;"><a href="' + posturl + '" style="display: block;" class="fullgreylink">');
		if (postcontent.length < numchars) {
	        document.write(postcontent);
		}
	    else {
			postcontent = postcontent.substring(0, numchars);
	        var quoteEnd = postcontent.lastIndexOf(" ");
	        postcontent = postcontent.substring(0,quoteEnd);
	        document.write(postcontent + '...');
		}
		document.write('</a></div>');
		document.write('</a></TD>');
		document.write('</TR>');
		document.write('</TABLE>');
		//end description table
	
	document.write('</A></TD>');
	document.write('</TR>');
	document.write('</TABLE>');
	//end main table
  }
}

