function CStringManager() {

	this.sStr=new Array();
	
	this.add = function(s) { 
		this.sStr.push(s);
	} 
	
	this.toString = function() { 
		return (this.sStr).join("");
	} 
}

var sMoisFrancais3  = ["Jan","Fév","Mars","Avril","Mai", "Juin","Juil","Août","Sept","Oct","Nov","Déc"];
var sMoisFrancais   = ["Janvier","Février","Mars","Avril","Mai", "Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"];

function yearDiff(d1,d2) {
	if ((d1.getMonth()>=d2.getMonth() && d1.getDate()>d2.getDate())  )  {
		return d1.getFullYear()-d2.getFullYear();
	} else  return d1.getFullYear()-d2.getFullYear()-1;
}


function dayDiff(d1,d2) {
	return Math.ceil((d1.getTime()-d2.getTime())/(1000*60*60*24))
}


function clearCookie(sName) {
	var now = new Date();
	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
	this.setCookie(sName, 'cookieValue', yesterday);
	this.setCookie(sName, 'cookieValue', yesterday);
}



function getCookie(sName,sDefaultValue) { 
	var sCookies = document.cookie;		
	var index = sCookies.indexOf(sName + "=");
	if (index != -1) {		
		index = sCookies.indexOf("=", index) + 1;
		var endstr = sCookies.indexOf(";", index);
		if (endstr == -1) endstr = sCookies.length;
		var retvalue = unescape(sCookies.substring(index, endstr));		
	} else retValue = sDefaultValue;		
	return retvalue;
}


function setCookie(sName, sValue, expires) { 
	document.cookie=sName + "=" + escape(sValue) + "; expires=" + (expires ? expires : new Date("December 31, 2023"));
}
  


function getPageCoordinates(element) {
  var x = y = 0;
  do {
    x+= element.offsetLeft;
    y += element.offsetTop;
  }
  while ((element = element.offsetParent));
  return {x: x, y: y};
}



function CPays (sNom,sArticle, sFileName,sNomFormel,sNomLocal,sNomLocalFormel,sDescription,fLongitude,fLatitude,fZoomLevel) {
	this.sNom 		= sNom;
	this.sArticle	= sArticle;
	this.sFileName  = sFileName;
	this.sNomFormel	= sNomFormel;
	this.sNomLocal	= sNomLocal;
	this.sNomLocalFormel = sNomLocalFormel;
	this.sDescription	 = sDescription;
	this.fLongitude		= fLongitude;
	this.fLatitude		= fLatitude;
	this.fZoomLevel		= fZoomLevel;
	this.iNbEntrees		= 0;
}



function CAuteur(sNom,sType,iAge,sSurnom,sDescription, sMoreDetail) {
	this.sNom			= sNom;
	this.sType			= sType;
	this.iAge			= iAge;
	this.sSurnom		= sSurnom;
	this.sDescription	= sDescription;
	this.sMoreDetail	= sMoreDetail;
	this.iNbEntrees		= 0;
}




function CLocalisation(sPays,sProvince,sVille, fLatitude, fLongitude,iEtoiles, sDescription) {
	this.sPays		= sPays;
	this.sProvince 	= sProvince;
	this.sVille		= sVille;
	this.fLatitude	= fLatitude;
	this.fLongitude	= fLongitude;
	this.iEtoiles	= iEtoiles ? iEtoiles : 0;
	this.sDescription = sDescription ? sDescription: "";

	oVilles[sVille] = this;
	
	this.toHTML = function()   {
		return "<div style='width:300;height:150;background-image:url(images/maps/mappemonde.jpg)'><img src=images/redbullet.gif style='position:relative;left:"+(145+this.fLongitude*300/360)+";top:"+(70-this.fLatitude*150/180)+";'></div>"; 
	}
	
	this.toRating =function() {
		var sStr="";
		for (i=0;i<this.iEtoiles;i++) sStr+="<img src=images/star.gif>";
		return sStr;
	}
}

function escapeQuote(s) { return s.replace(/\'/g,"&rsquo;"); }
function formatDate(a,m,j) { return a+"/"+(m<10 ? "0"+m: m)+"/"+(j<10 ? "0"+j: j); }
oCurrentPhoto=null;
oPhoto=null;
function CPhoto(iDateAnnee,iDateMois,iDateJour,sFileName,sTexte,oTags,oLocalisation) {
	this.iIndex 		= oJournal.oPhotos.length;
	this.iDateAnnee 	= iDateAnnee;
	this.iDateMois		= iDateMois;
	this.iDateJour  	= iDateJour;
	this.sFileName		= sFileName;
	this.sTexte			= sTexte;
	this.oLocalisation  = null; 
	this.oCommentaires	= new Array();
	this.oTags			= oTags ? oTags : new Array();
	this.oLocalisation  = oLocalisation;
		
	this.affichePhotoDetail = function() {
		oPhoto=this;
		setTimeout("mapPhoto()",500);
		return  "<h1 align=right>Détail Photo</H1><img class=photo src=photos/"+this.sFileName+".jpg width=400><br><b>"+formatDate(this.iDateAnnee, this.iDateMois, this.iDateJour ) +"</b>: "+this.sTexte + "<br><br><h3>"+this.oLocalisation.sVille+", "+this.oLocalisation.sPays+"</h3><div id=map style='width:390;height:125px'></div>";	
	}

		
	this.toPreview = function(sTaille,sGroupe) {
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) return "<img src=images/spacer.gif width=4px><a class=cadrephoto_ie href=photos/"+this.sFileName+".jpg rel=\"lytebox"+(sGroupe ? "[_"+sGroupe+"]" : "")+"\" title='"+formatDate(this.iDateAnnee, this.iDateMois, this.iDateJour )+": "+escapeQuote(this.sTexte)+ (this.oLocalisation? " ("+this.oLocalisation.sVille+", "+this.oLocalisation.sPays+")" : "")+"'><img class=photo_ie src=photos/"+this.sFileName+"_preview.jpg width="+sTaille+"></a> ";
		else return "<a href=photos/"+this.sFileName+".jpg rel='lytebox"+(sGroupe ? "[_"+sGroupe+"]" : "")+"'  title='"+formatDate(this.iDateAnnee, this.iDateMois, this.iDateJour )+": "+escapeQuote(this.sTexte)+ (this.oLocalisation? " ("+this.oLocalisation.sVille+", "+this.oLocalisation.sPays+")" : "")+"'><img class=photo src=photos/"+this.sFileName+"_preview.jpg width="+sTaille+"></a> ";
	}

	this.toPreviewAlbum = function(sTaille,sGroupe) {
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) return "<img src=images/spacer.gif width=4px><a class=cadrephoto_ie href=photos/"+this.sFileName+".jpg rel=\"lytebox"+(sGroupe ? "[_"+sGroupe+"]" : "")+"\" onmousemove='if (oCurrentPhoto != this) { oCurrentPhoto=this; rightpanel.innerHTML =oJournal.oPhotos["+this.iIndex+"].affichePhotoDetail();}' caption='"+formatDate(this.iDateAnnee, this.iDateMois, this.iDateJour )+": "+escapeQuote(this.sTexte)+ (this.oLocalisation? " ("+this.oLocalisation.sVille+", "+this.oLocalisation.sPays+")" : "")+"'><img class=photo_ie src=photos/"+this.sFileName+"_preview.jpg width="+sTaille+"></a> ";
		else return "<a caption='"+formatDate(this.iDateAnnee, this.iDateMois, this.iDateJour )+": "+escapeQuote(this.sTexte)+ (this.oLocalisation? " ("+this.oLocalisation.sVille+", "+this.oLocalisation.sPays+")" : "")+"' href=photos/"+this.sFileName+".jpg caption= "+escapeQuote(this.sTexte)+ " rel='lytebox"+(sGroupe ? "[_"+sGroupe+"]" : "")+"' onmousemove='if (oCurrentPhoto != this) { oCurrentPhoto=this; rightpanel.innerHTML =oJournal.oPhotos["+this.iIndex+"].affichePhotoDetail();}' ><img class=photo src=photos/"+this.sFileName+"_preview.jpg width="+sTaille+"></a> ";
	}

	
	this.ajouteCommentaire = function(c) {
		this.oCommentaires.push(c);
	}		
}

function CCommentaire(iDateAnnee,iDateMois,iDateJour,sAuteur,sTexte) {
	this.iDateAnnee 	= iDateAnnee;
	this.iDateMois		= iDateMois;
	this.iDateJour  	= iDateJour;
	this.sAuteur		= sAuteur;
	this.sTexte			= sTexte;

	oJournal.iNbCommentaires++;
	this.toHTML = function() { 
		return " <li><font size=1> <b>" +this.sAuteur +"</b> ("+formatDate(this.iDateAnnee,this.iDateMois,this.iDateJour)+"):<i> "+this.sTexte+"</font></i>"; 	
	} 
}

function CEntreeJournal(iDateAnnee,iDateMois,iDateJour,sAuteur, sCategorie, sTitre, sTexte,oLocalisation) {
	this.iDateAnnee 		= iDateAnnee;
	this.iDateMois			= iDateMois;
	this.iDateJour  		= iDateJour;
	this.sAuteur			= sAuteur;
	this.sCategorie 		= sCategorie;
	this.sTitre				= sTitre;
	this.sTexte				= sTexte;
	this.oLocalisation  	= (oLocalisation? oLocalisation : this.oLocalisation = new CLocalisation("","",""));
	this.oPhotos			= new Array();
	this.oCommentaires		= new Array();

	this.ajouteCommentaire = function(c) {
		this.oCommentaires.push(c);
	}		
	
	this.nouveauCommentaire = function(c) {
		this.oCommentaires.push(c);
		if (getCookie("Asie2008ID")==undefined) setCookie("Asie2008ID", c.sAuteur); 
		eval("entree_"+this.iIndex).innerHTML = c.toHTML();
	}		
	
	this.ajoutePhoto = function (p) {
		this.oPhotos.push(p);
		p.oEntreeJournal = this;
		if (p.oLocalisation == undefined) p.oLocalisation=this.oLocalisation;
		oJournal.oPhotos.push(p);
		
		for (t in p.oTags) { 
			if (oJournal.oPhotosTaggees[p.oTags[t]]==undefined) { 
				oJournal.oPhotosTaggees[p.oTags[t]] = new Array();
			}	
			oJournal.oPhotosTaggees[p.oTags[t]].push(p);
		}
	}
	
	
	this.toHTML = function(bShowPhotos, iTexteLength) {
		bShowPhotos = (bShowPhotos==undefined ? true : bShowPhotos);
		iTexteLength = (iTexteLength ? iTexteLength: 10000000);
		var sTexte = (this.sTexte.length<=iTexteLength ? this.sTexte :this.sTexte.substr(0,iTexteLength)+" <i>...<font size=1>(suite dans le journal)</font></i>");
		//var sStr= "<div class=post><p class=date><span class=day>"+iDateJour+"</span><span class=month>"+sMoisFrancais3[iDateMois-1].substr(0,4)+"</span><span class=year>"+iDateAnnee+"</span></p><h2 class=title>"+this.sTitre+"</h2><img onmouseout='javascript:this.src=\"images/mail.gif\";'  onmouseover='javascript:this.src=\"images/mail_high.gif\";' src=images/mail.gif title='Envoyez moi un commentaire' align=left style='margin-top:10px;' valign=bottom border=0 onclick='oJournal.displayComment("+this.iIndex+");'><div class=meta><p>Publié par <a href=javascript:afficheAuteur('"+this.sAuteur+"'); title='Voir toutes les entrées postées par "+this.sAuteur+"'>"+this.sAuteur+"</a>.  (<a href=javascript:afficheVille('"+this.oLocalisation.sVille+"');>""+this.oLocalisation.sVille+"</a>, <a href=javascript:affichePays('"+this.oLocalisation.sPays+"');>"+this.oLocalisation.sPays+"</a>)"+(dayDiff(new Date(this.iDateAnnee,this.iDateMois,this.iDateJour),g_LastVisit)>0 ? " <font color=red><b>NEW</b></font>" : "")+"</p></div><div class=entry><p /><p>"+sTexte+"</p></div>";
		var sStr= "<div class=post><p class=date><span class=day>"+(iDateJour==1 ? "1<font size=-1><sup>er</sup></font>" : iDateJour)+"</span><span class=month>"+sMoisFrancais3[iDateMois-1].substr(0,5)+"</span><span class=year>"+iDateAnnee+"</span></p><h2 class=title>"+this.sTitre+"</h2><img src=images/mail.gif  align=left style='margin-top:10px;' valign=bottom border=0 ><div class=meta><p>Publié par <a href=javascript:afficheAuteur('"+this.sAuteur+"'); title='Voir toutes les entrées postées par "+this.sAuteur+"'>"+this.sAuteur+"</a>.  (<a href=\"javascript:affichePays('"+this.oLocalisation.sPays+"','"+this.oLocalisation.sVille+"');\">"+this.oLocalisation.sVille+"</a>, <a href=javascript:affichePays('"+this.oLocalisation.sPays+"');>"+this.oLocalisation.sPays+"</a>) "+(dayDiff(new Date(this.iDateAnnee,this.iDateMois-1,this.iDateJour),g_LastVisit)>=0 ? " <font color=red><b><span title='Nouvelle entrée depuis votre dernière visite'>nouveau</span></b></font>" : "")+"</p></div><div class=entry><p /><p>"+sTexte+"</p></div>";
		if (bShowPhotos && this.oPhotos.length>0) {	
			var i=0;
			var iMax= 409 % 110;
			for (p in this.oPhotos) {		
				sStr+=this.oPhotos[p].toPreview(110,"A");  
				if (i++ > iMax) { sStr+="<br clear=all>"; i==0; }
			}
			sStr+="<br clear=all><br clear=all>";
		} 
		sStr+="<div id=entree_"+this.iIndex+"></div>";
		if (bShowPhotos && this.oCommentaires.length>0) {
			for (c in this.oCommentaires) {
				sStr+=this.oCommentaires[c].toHTML();
			}	
			sStr+="<br>";
		}
		return sStr+"<br></div>";
	}
}


function CJournal() {
	this.oEntreesJournal 		= new Array();
	this.oFilterResult   		= new Array();
	this.oPhotos		 		= new Array();
	this.sFiltreAuteur	 		= null;	
	this.sFiltreMois	 		= null;
	this.sCategorie	 	 		= null;
	this.oAuteurs		 		= new Array();	
	this.oDerniereEntree 		= undefined;
	this.oPays		 	 		= new Array();	
	this.nbEntreesParAuteur		= new Array();
	this.nbEntreesParPays		= new Array();
	this.iNbCommentaires		= 0;
	this.oPhotosTaggees			= new Array();


	this.ajoutePhoto = function (p) {
		this.oPhotos.push(p);
		p.oEntreeJournal = null;
		
		for (t in p.oTags) { 
			if (this.oPhotosTaggees[p.oTags[t]]==undefined) { 
				this.oPhotosTaggees[p.oTags[t]] = new Array();
			}	
			this.oPhotosTaggees[p.oTags[t]].push(p);
		}
	}

	this.entreesVillesDistinctes = function(sPays) {
		var v=new Array();
		var sCurrentVille 		= "";
		for (o in this.oEntreesJournal) if (this.oEntreesJournal[o].oLocalisation.sPays==sPays || sPays==undefined) {
			if (this.oEntreesJournal[o].oLocalisation.sVille != sCurrentVille) {
				sCurrentVille = this.oEntreesJournal[o].oLocalisation.sVille;
				v.push(this.oEntreesJournal[o]);
			} 
		}				
		return v;		
	}
	
	this.displayComment = function(i) {
		eval("entree_"+i).innerHTML = "<li><b>Nouveau commentaire</b><br><input style='width:50%' class=smallgray id=commentairenom value='"+(getCookie("Asie2008ID")? getCookie("Asie2008ID") : "Ecrire votre nom ici")+"' onclick='this.value=\"\";' > <input class=smallgray type=button value='Ajouter' onclick='var d= new Date();oJournal.oEntreesJournal["+i+"].nouveauCommentaire(new CCommentaire(d.getFullYear(),d.getMonth(),d.getDate(),commentairenom.value,commentaire.value))'><br><input class=smallgray style='width:90%' id=commentaire value='Ecrire votre commentaire ici' onclick='this.value=\"\"; ><br>";
		if (getCookie("Asie2008ID")) commentaire.focus() 
		else commentairenom.focus(); 
	}
		
	this.ajoutePays = function(pp,p) {
		this.oPays[pp]=p;
		return p;
	}

	this.ajouteAuteur = function(sNom,o) {
		this.oAuteurs[sNom]=o;
		return o;
	}
	
	this.ajouteEntree = function(o) {
		o.iIndex = this.oEntreesJournal.length;
		if (this.oDerniereEntree == undefined) this.oDerniereEntree = o;
		this.oEntreesJournal.push(o);
		
		this.oAuteurs[o.sAuteur].iNbEntrees++;		
		this.oPays[o.oLocalisation.sPays].iNbEntrees++;

		return o;
	}

	this.toJournal = function(iAnnee,iMois) {
		iMois++;
		var sStr="";
		for (o in this.oEntreesJournal) { if (iAnnee==this.oEntreesJournal[o].iDateAnnee && iMois==this.oEntreesJournal[o].iDateMois) sStr+=this.oEntreesJournal[o].toHTML(); }
		return sStr;
	}


	this.toJournalImprime = function() {
		var sStr="";
		for (i=this.oEntreesJournal.length-1;i>=0; i--) { 
			sStr+= "<div class=post><p class=date><span class=day>"+this.oEntreesJournal[i].iDateJour+"</span><span class=month>"+sMoisFrancais3[this.oEntreesJournal[i].iDateMois-1].substr(0,4)+"</span><span class=year>"+this.oEntreesJournal[i].iDateAnnee+"</span></p><h2 class=title>"+this.oEntreesJournal[i].sTitre+"</h2><img src=images/mail.gif  align=left style='margin-top:10px;' valign=bottom border=0 ><div class=meta><p>Publié par <a href=javascript:afficheAuteur('"+this.oEntreesJournal[i].sAuteur+"'); title='Voir toutes les entrées postées par "+this.oEntreesJournal[i].sAuteur+"'>"+this.oEntreesJournal[i].sAuteur+"</a>.  ("+this.oEntreesJournal[i].oLocalisation.sVille+", <a href=javascript:affichePays('"+this.oEntreesJournal[i].oLocalisation.sPays+"');>"+this.oEntreesJournal[i].oLocalisation.sPays+"</a>)</p></div><div class=entry><p /><p>"+this.oEntreesJournal[i].sTexte+"</p></div>";
			if (this.oEntreesJournal[i].oPhotos.length>0) {	
				var ii=0;
				sStr+="<table><tr>";

				for (p in this.oEntreesJournal[i].oPhotos) {		
					var pp = this.oEntreesJournal[i].oPhotos[p];  
					sStr+="<td class=smallgray style='vertical-align:top;'><img border=2 class=photo_ie src=photos/"+pp.sFileName+".jpg width=320><br>";
					sStr+=formatDate(pp.iDateAnnee, pp.iDateMois, pp.iDateJour )+": "+escapeQuote(pp.sTexte)+ (pp.oLocalisation? " ("+pp.oLocalisation.sVille+", "+pp.oLocalisation.sPays+")" : "");
					sStr+="</td>";
				}
				sStr+="</tr></table><br clear=all><br clear=all>";
			} 
			sStr+="<div id=entree_"+this.oEntreesJournal[i].iIndex+"></div>";
			if (this.oEntreesJournal[i].oCommentaires.length>0) {
				for (c in this.oEntreesJournal[i].oCommentaires) {
					sStr+=this.oEntreesJournal[i].oCommentaires[c].toHTML();
				}	
				sStr+="<br>";
			}
			sStr+="</div><br clear=all>";
		}
		return sStr;
	}


	this.toJournalParPays = function(sPays) {
		var sStr="";
		for (o in this.oEntreesJournal) { if (sPays==this.oEntreesJournal[o].oLocalisation.sPays) sStr+=this.oEntreesJournal[o].toHTML(); }
		return sStr;
	}

	this.toJournalParVille = function(oLocalisation) {
		var sStr="";
		for (o in this.oEntreesJournal) { if (oLocalisation.sVille==this.oEntreesJournal[o].oLocalisation.sVille) sStr+=this.oEntreesJournal[o].toHTML(); }
		return sStr;
	}

	this.toDerniereEntree = function() {
		return this.oEntreesJournal[0].toHTML(false,200); 
	}


	this.trierParDate = function () {
		function sortCallback(o1,o2) { 
			if (o1.iDateAnnee > o2.iDateAnnee) return 1;
			else if (o1.iDateAnnee < o2.iDateAnnee) return -1;
			else if (o1.iDateMois > o2.iDateMois) return 1;
			else if (o1.iDateMois < o2.iDateMois) return -1;
			else if (o1.iDateJour < o2.iDateJour) return 1;
			else return -1;
		}
		
		this.oEntreesJournal.sort(sortCallback);
	}


	this.toItineraireMappemonde = function() {
		var iMapWidth		= 870;
		var iMapHeight		= 540;
		var iMapOffsetTop 	= 30;
		var iDotRayon		= 10;
		
		function latitudeToXY(fLatitude) {
			return (iMapHeight/2-iDotRayon)-fLatitude*iMapHeight/180+2;
		}

		function longitudeToXY(fLongitude) {
			return (iMapWidth/2-iDotRayon/2)+fLongitude*iMapWidth/360;
		}
		
		
		var sStr = "<div style='z-index:999;position:absolute;width:"+iMapWidth+";height:"+iMapHeight+";left:"+getPageCoordinates(leftpanel).x+";top:"+(getPageCoordinates(leftpanel).y+30)+";background-image:url(images/maps/mappemondelarge.jpg);'/>";
			
		sStr+="<br><br>";
		var sCurrentVille 		= "";
		var oLastLocalisation	= this.oEntreesJournal[0].oLocalisation;
		var bFirst				= true;		
		var i					= 0;
		for (o in this.oEntreesJournal)  {
			if (this.oEntreesJournal[o].oLocalisation.sVille != sCurrentVille) {
				i++;
				sCurrentVille = this.oEntreesJournal[o].oLocalisation.sVille ;

				if (bFirst) {
					sStr+="<img src=images/redbullet.gif style='position:relative;left:"+longitudeToXY(oLastLocalisation.fLongitude)+";top:"+latitudeToXY(oLastLocalisation.fLatitude)+";' title='"+oLastLocalisation.sVille+"'/>"; 
				}
				
				sStr+='<v:polyline filled=false; style="position:relative;"  strokecolor=blue strokeweight="3px" points="M '+longitudeToXY(oLastLocalisation.fLongitude)+  ',' + latitudeToXY(oLastLocalisation.fLatitude) + ' , ' + (longitudeToXY(this.oEntreesJournal[o].oLocalisation.fLongitude)-iDotRayon*i) + ',' + latitudeToXY(this.oEntreesJournal[o].oLocalisation.fLatitude) + ' ,  E" /></v:polyline>';

				sStr+="<img src=images/redbullet.gif style='position:relative;left:"+(longitudeToXY(this.oEntreesJournal[o].oLocalisation.fLongitude)-iDotRayon*i)+";top:"+latitudeToXY(this.oEntreesJournal[o].oLocalisation.fLatitude)+";' title='"+this.oEntreesJournal[o].oLocalisation.sVille+"'/>"; 
				
				bFirst = false;		
			} 
		}		
		return sStr+"</div>";

		//return sStr+"<img src=images/redbullet.gif style='position:relative;left:"+longitudeToXY(0)+";top:"+latitudeToXY(0)+";' title='TEST'></div>";
	
	}
	
	this.toItineraireVilleSeulement = function (sPays) {
		var sStr="";
		var sCurrentVille 	= "";				
		var bFirst			= true;		
		for (o in this.oEntreesJournal) if (this.oEntreesJournal[o].oLocalisation.sPays == sPays ) {
			if (this.oEntreesJournal[o].oLocalisation.sVille != sCurrentVille) {
				sCurrentVille = this.oEntreesJournal[o].oLocalisation.sVille ;
				sStr+=" <img src=images/bullet.jpg>" +this.oEntreesJournal[o].oLocalisation.sVille;
				bFirst = false;		
			} 
		}		

		return sStr+"<br>";
	}
	
	 
	this.toItineraireVille = function (sPays) {
		var sStr="";
		var sCurrentVille 	= "";				
		var iNbEntree		= 0;
		var bFirst			= true;		
		for (o in this.oEntreesJournal) if (this.oEntreesJournal[o].oLocalisation.sPays == sPays || sPays==undefined) {
			if (this.oEntreesJournal[o].oLocalisation.sVille != sCurrentVille) {
				if (!bFirst) {sStr+="  : "+(iNbEntree+1)+" entrée"+(iNbEntree==0 ? "" :"s")+".<br>"}
				sCurrentVille = this.oEntreesJournal[o].oLocalisation.sVille ;
				sStr+="<span class=commeh3>"+this.oEntreesJournal[o].oLocalisation.sVille+"</span>, <b>"+this.oEntreesJournal[o].oLocalisation.sProvince+(sPays ==undefined ? ", "+this.oEntreesJournal[o].oLocalisation.sPays : "")+"</b><br><img src=images/bullet.jpg> "+(bFirst ? " jusqu'à aujourd'hui... " : " jusqu'au "+this.oEntreesJournal[o].iDateAnnee+"/"+this.oEntreesJournal[o].iDateMois+"/"+this.oEntreesJournal[o].iDateJour);
				iNbEntree= 0; bFirst = false;		
			} else iNbEntree++;
		}		
		sStr+="  : "+(iNbEntree+1)+" entrée"+(iNbEntree==0 ? "" :"s")+".<br>";
		return sStr;
	}
	
	this.toItinerairePays = function () {
		var sStr			= "";
		var sCurrentPays 	= "";				
		var iNbEntree		= 0;
		var bFirst			= true;		
		ss="";
		for (o in this.oEntreesJournal) {
			ss+=this.oEntreesJournal[o].oLocalisation.sPays +":"+this.oEntreesJournal[o].iDateAnnee+"/"+this.oEntreesJournal[o].iDateMois+"/"+this.oEntreesJournal[o].iDateJour+"<br>";
			if (this.oEntreesJournal[o].oLocalisation.sPays != sCurrentPays) {
				if (!bFirst) {sStr+="  : "+(iNbEntree+1)+" entrée"+(iNbEntree==0 ? "" :"s")+".<br clear=all><img src=images/spacer.gif height=5><br>"}
				sCurrentPays = this.oEntreesJournal[o].oLocalisation.sPays ;
				sStr+="<img class=imageplain src=images/flags/"+this.oPays[this.oEntreesJournal[o].oLocalisation.sPays].sFileName+" align=left><span class=commeh3><a href=javascript:affichePays('"+this.oEntreesJournal[o].oLocalisation.sPays+"');>"+this.oEntreesJournal[o].oLocalisation.sPays+"</a><br></span><img src=images/bullet.jpg> "+(bFirst ? " jusqu'à aujourd'hui... " : " jusqu'au "+this.oEntreesJournal[o].iDateAnnee+"/"+this.oEntreesJournal[o].iDateMois+"/"+this.oEntreesJournal[o].iDateJour);
				iNbEntree= 0; bFirst = false;						
								
			} else iNbEntree++;
		}				
		sStr+="  : "+(iNbEntree+1)+" entrée"+(iNbEntree==0 ? "" :"s")+".<br clear=all><img src=images/spacer.gif height=5><br>"
		return sStr;
	}
	
	this.toJournalParAuteur = function (sAuteur) {
		var sStr="";
		var i=0;
		for (o in this.oEntreesJournal) if (this.oEntreesJournal[o].sAuteur == sAuteur) { i++; sStr+=this.oEntreesJournal[o].toHTML(); }
		if (i==0) return "<font size=1><i>Il n'y a pas encore de messages pour le moment...</i></font>";		
		else return sStr;

	}

	
	
	this.toDernieresPhotos = function () {		
		var sStr="";
		var i=0;
		var iMax= 409 % 65;
		for (ii=0;ii<Math.min(6,this.oPhotos.length);ii++) {		
			sStr+=this.oPhotos[ii].toPreview(65,"A");  
			if (i++ > iMax) { sStr+="<br clear=all>"; i=0; }
		}
		
		if (this.oPhotos.length==0) return "<font size=1><i>Il n'y a pas encore de photos pour le moment...</i></font>";		
		else return sStr+(i!=0 ? "<br clear=all>" :"")+"<a href=javascript:afficheAlbumPhoto();>Afficher l'album photos</a>";
	}
	
	this.sFiltrePhotos = "toute";
	this.toPhotoAlbum = function () {
		var sTaille		= 62;
		var sStrIndex	="";
		var sStr		= ((/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ? "" : "");
		var sCurrentPays="askdjaskhdskajhkjashd";
		var bFirst 		= true;
		var i			= 0;
		var iMax		= 410 % sTaille;
		var c = new CStringManager();
		c.add("<div id=_photoalbumwww><select class=smallgray onchange='oJournal.sFiltrePhotos=this.options[this.selectedIndex].value; afficheAlbumPhoto();'><option value=toute>Afficher toutes les photos</option>");
		for (t in this.oPhotosTaggees) {
			c.add("<option value='");
			c.add(t);
			c.add("' ");
			c.add((this.sFiltrePhotos==t ? "SELECTED" : ""));
			c.add(" >");
			c.add(t);
			c.add("</option>");
		}
		c.add("</select><br>"); //+(this.sFiltrePhotos =="toute" ? "" : "<font color=red><-Filtre actif</font>")+  "<br>";
		
		var oListeDesPhotos = this.sFiltrePhotos =="toute" ? this.oPhotos: this.oPhotosTaggees[this.sFiltrePhotos];  
		
		for (p in oListeDesPhotos) {
			if (sCurrentPays!= oListeDesPhotos[p].oLocalisation.sPays) {
				sCurrentPays= oListeDesPhotos[p].oLocalisation.sPays;
				var oPays = oJournal.oPays[oListeDesPhotos[p].oLocalisation.sPays];
				c.add((bFirst ? "" : "<br clear=all>"));
				c.add("<br clear=all><br><h3><img class=imageplain heigth=10 src=images/flags/"+oPays.sFileName+" align=left> ");
				c.add(sCurrentPays);
				c.add("</h3><a href=javascript:affichePays('"+sCurrentPays+"')>Afficher tous les messages "+oPays.sArticle+oPays.sNom+"</a><br clear=all>"); //<img src=images/flags/"+oJournal.oPays[oListeDesPhotos[p].oLocalisation.sPays].sFileName +" height=15>
				bFirst=false;
			}
			
			c.add(oListeDesPhotos[p].toPreviewAlbum(sTaille,"A"));
			if (i++ > iMax) { c.add("<br clear=all>"); i=0; }
		}

		if (oListeDesPhotos.length==0) c.add("<font size=1><i>Il n'y a pas encore de photos pour le moment...</i></font>");
		c.add("</div>");
		return c.toString();
	}


	this.toListePhotos = function (sTaille, sPays, sGroupe) {		
		var sStr="";
		var i=0;
		var bAuMoinsUnePhoto = false;
		var iMax= 409 % sTaille;
		
		for (p in this.oPhotos)  { 
			if (sPays ==undefined || sPays== this.oPhotos[p].oLocalisation.sPays ) {
				this.oPhotos[p].toPreview(sTaille,sGroupe);
				bAuMoinsUnePhoto = true;
				if (i++ > iMax) { sStr+="<br clear=all>"; i=0; }
			}
		}

		if (!bAuMoinsUnePhoto) return "<font size=1><i>Il n'y a pas encore de photos pour le moment...</i></font>";		
		else return sStr;
	}
}


mapItineraire = function() {
	function RGB2HTML(red, green, blue){
	    var decColor = red + 256 * green + 65536 * blue;
	    return decColor.toString(16);
	}

	
	if(document.implementation.hasFeature(
			"http://www.w3.org/TR/SVG11/feature#SVG","1.1")){ 
		  _mSvgEnabled = true;
		  _mSvgForced  = true;
		}

	// Set up the map.
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GScaleControl());
	map.setCenter(new GLatLng(0, 15), 1);
	
	// Prepare for encoding!
	var polylineEncoder = new PolylineEncoder();

	  
    GEvent.addListener(map, "click", function(marker, point) {
	  if (marker) {
	  	var str = marker.getTitle();	  	
	    //rightpanel.innerHTML="<br><br><div align=right><h1>Journal par ville</h1><h3>"+marker.sVille+ ", "+marker.sPays+"</h3></div><br>"+oJournal.toJournalParVille(marker.oLocalisation);
	    afficheEntreesVille(marker.sPays,marker.sVille);
	    newLyteBox = new LyteBox();
		newLyteBox.updateLyteboxItems();		
	  } 
	});

	 function importanceOrder (marker,b) {
        return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000;
      }


	var iconRed = new GIcon(); 
	iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
	iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconRed.iconSize = new GSize(12, 20);
	iconRed.shadowSize = new GSize(22, 20);
	iconRed.iconAnchor = new GPoint(6, 20);
	iconRed.infoWindowAnchor = new GPoint(5, 1);

	var iconBlue = new GIcon(); 
	iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
	iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconBlue.iconSize = new GSize(12, 20);
	iconBlue.shadowSize = new GSize(22, 20);
	iconBlue.iconAnchor = new GPoint(6, 20);
	iconBlue.infoWindowAnchor = new GPoint(5, 1);

	
	var sCurrentVille = "asdkjasldkj";
	var points = new Array();	
	var j=-1;
	var bFirst = true;

	var oVilles = oJournal.entreesVillesDistinctes();

	var sCurrentVille = "asdkjasldkj";
	for (i=oVilles.length-1;i>=0;i--) {		
			sCurrentVille = oVilles[i].oLocalisation.sVille;
			sCurrentPays = oVilles[i].oLocalisation.sPays;
			oLocalisation = oVilles[i].oLocalisation;
		    if (bFirst) {
		    	point = points[0] = new GLatLng(oVilles[i].oLocalisation.fLatitude,oVilles[i].oLocalisation.fLongitude);
		    	bFirst=false;
		    }
		    else {		    
		    	var s = Math.floor(50+(i/oVilles.length*180)).toString(16);
				point = points[1] = new GLatLng(oVilles[i].oLocalisation.fLatitude,oVilles[i].oLocalisation.fLongitude);
				//polyline = polylineEncoder.dpEncodeToGPolyline(points,"#"+s+s+"00", 3+Math.floor((j+2)/iNbVilles*5)); //{)RGB2HTML(50+(j/iNbVilles)*150,50+(j/iNbVilles)*150,50+(j/iNbVilles)*150));
				polyline = polylineEncoder.dpEncodeToGPolyline(points,"#"+s+s+"00", 3+Math.floor((i+2)/oVilles.length*5)); 
				map.addOverlay(polyline);
				points[0] = points[1];				
		    }
	}					
	
	for (i=0;i<oVilles.length;i++) {
	    oIcon = (i==0 ? iconRed : iconBlue);
	    g=new GMarker(new GLatLng(oVilles[i].oLocalisation.fLatitude,oVilles[i].oLocalisation.fLongitude),{zIndexProcess:importanceOrder, title: oVilles[i].oLocalisation.sVille +" ("+formatDate(oVilles[i].iDateAnnee,oVilles[i].iDateMois,oVilles[i].iDateJour)+")",icon: oIcon});
	    g.importance = oVilles.length-i;
	    g.oLocalisation = oVilles[i].oLocalisation;
	    g.sVille = oVilles[i].oLocalisation.sVille;
	    g.sPays = oVilles[i].oLocalisation.sPays;
	    map.addOverlay(g);		    
	}					
	
}

		
mapVilles = function () {
    var sPays			= oPays.sNom;
	var sCurrentVille 	= "";				
	var bFirst			= true;		
	var previousmarker  = null;
	
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(oPays.fLongitude,oPays.fLatitude),oPays.fZoomLevel);
	  
    GEvent.addListener(map, "click", function(marker, point) {
	  if (marker) {
	    //rightpanel.innerHTML="<br><br><div align=right><h1>Journal par ville</h1><h3>"+marker.getTitle()+"</h3></div><br>"+oJournal.toJournalParVille(marker.oLocalisation);	  	
	    afficheEntreesVille(marker.oLocalisation.sPays,marker.oLocalisation.sVille);
	    newLyteBox = new LyteBox();
		newLyteBox.updateLyteboxItems();		

	  } else {
	  	afficheEntreesPays(marker.sPays);
	   	//rightpanel.innerHTML="<br><br><div align=right><h1>Journal par pays</h1><h3>"+oJournal.oPays[sPays].sNom+"</h3></div><br>"+oJournal.toJournalParPays(sPays);
	  	newLyteBox = new LyteBox();
		newLyteBox.updateLyteboxItems();		
	  }
	});

	var iconRed = new GIcon(); 
//	iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
//	iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
	iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconRed.iconSize = new GSize(12, 20);
	iconRed.shadowSize = new GSize(22, 20);
	iconRed.iconAnchor = new GPoint(6, 20);
	iconRed.infoWindowAnchor = new GPoint(5, 1);
	
	
	for (o in oJournal.oEntreesJournal) if (oJournal.oEntreesJournal[o].oLocalisation.sPays == sPays ) {
		if (oJournal.oEntreesJournal[o].oLocalisation.sVille != sCurrentVille) {							    
		    var point = new GLatLng(oJournal.oEntreesJournal[o].oLocalisation.fLatitude,oJournal.oEntreesJournal[o].oLocalisation.fLongitude);
		    var m = new GMarker(point,{title: oJournal.oEntreesJournal[o].oLocalisation.sVille ,icon: iconRed})
		    m.oLocalisation = oJournal.oEntreesJournal[o].oLocalisation;
		    map.addOverlay(m);
		} 
	}						
}

mapPhoto = function () {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(oPhoto.oLocalisation.fLatitude,oPhoto.oLocalisation.fLongitude),3);
	  
	var iconRed = new GIcon(); 
	iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
	iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconRed.iconSize = new GSize(12, 20);
	iconRed.shadowSize = new GSize(22, 20);
	iconRed.iconAnchor = new GPoint(6, 20);
	iconRed.infoWindowAnchor = new GPoint(5, 1);
		
    var point = new GLatLng(oPhoto.oLocalisation.fLatitude,oPhoto.oLocalisation.fLongitude);
    map.addOverlay(new GMarker(point,{icon: iconRed}));
}



oJournal = new CJournal();
