
var nouvelleFenetre = false

function dp (obj){
	var rep = "";
	for (var i in obj){
		rep += i+" : "+obj[i]+"\n";
	}
	return rep;
}

function swapImage (nomImage){
	var im = document.images[nomImage];
	var source = im.src;
	var extension = source.slice(source.length-4)
	var source = source.slice(0, source.length-4)
	var lastCaract = source.charAt(source.length-1)
	if (lastCaract == "2") {
		source = source.slice(0, source.length - 1)+extension;			
	}
	else {
		source = source + "2" + extension;
	}
	im.src = source;
};

var indexFen = 0;

function ecrirePhoto(photo){
	document.write ("<td valign=\"center\" align=\"center\" width=\"400\">");
	if (! nouvelleFenetre)
		document.write ("<a href=\""+top.repAffich+"afficheCreation.html?titre="+photo.titre+"&prix="+photo.prix+"&description="+photo.description+"&fichier="+photo.fichier+"&horizontale="+photo.horizontale+"&repPhotos="+top.repPhotos+"\">");
	else {
		document.write ("<a target=\"window.open('fen'+"+indexFen+")\" href=\""+top.repAffich+"afficheCreation.html?titre="+photo.titre+"&prix="+photo.prix+"&description="+photo.description+"&fichier="+photo.fichier+"&horizontale="+photo.horizontale+"&repPhotos="+top.repPhotos+"\">");
		indexFen ++;
	}
	
	document.write ("<img src=\""+top.repVignettes+photo.fichier+"\" width=\"255\" border=\"0\"> ");
	document.write ("<br><b align=\"left\">"+photo.titre+"    </b>");
	document.write ("</a>");
	document.write ("<font size=\"-1\"><b align=\"right\"><i>"+photo.prix+"</i></b></font>");
	document.write ("</td>");
}

function ecrireLesPhotos (tabPhotos) {
	document.write ("<table class=\"titre\">");
	var photo;
	for (var i = 0; i < tabPhotos.length; i++) {
		photo = tabPhotos[i];
		if ((i%2)==0) document.write ("<tr valign=\"center\" >");
		ecrirePhoto(photo)
		if ((i%2)!=0) document.write ("</tr>");
	};
	document.write ("</table>");
};


function ecrireBouton(nomBouton, page){
	document.write ("<td width=\"150\" >");
	document.write ("<a href=\""+page+"\" target=\"mainFrame\" onmouseover=\"swapImage('"+nomBouton+"')\" onmouseout=\"swapImage('"+nomBouton+"')\"  > ");
	document.write ("<img id=\""+nomBouton+"\" border=\"0\" name=\""+nomBouton+"\" src=\"../../images/"+nomBouton+".jpg\" width=\"115\" height=\"30\"> ");
	document.write ("</a>");
	document.write ("</td>");
}


function ecrireLesBoutons (tabNomsBoutons) {
	document.write ("<table class=\"titre\"  align=center>");
	var nomBouton;
	var nomPage;
	document.write ("<tr>");
	for (var i = 0; i < tabNomsBoutons.length; i++) {
		nomBouton = tabNomsBoutons[i][0];
		page = tabNomsBoutons[i][1];
		ecrireBouton (nomBouton, page)
	};
	document.write ("</tr>");
	document.write ("</table>");
};


function afficheCreationVerticale (photo){
	document.write ("<table>");
	if (! nouvelleFenetre) {
//		document.write ("<tr><td align=\"left\" colspan=\"2\"><a href=\""+top.rep+"\">Retour</a></td></tr>");
		document.write ("<tr><td align=\"left\"><a href=\""+top.rep+"\">Retour</a></td>")
		document.write ("<td align=\"right\"><a href=\"../mail/mail.html\" target=\"frameDroite\"><img src=\"../../images/mail.gif\" border=\"0\"></a></td></tr>");
	}

	document.write ("<tr><td align=\"center\" colspan=\"2\">");
	document.write ("<font size=\"+4\"><B>");
	document.write (photo.titre);
	document.write ("</B></font>");
	document.write ("</td></tr>");
	document.write ("<tr>");

	document.write ("<td  align=\"center\">");
	document.write ("<img src=\""+top.repPhotos+photo.fichier+"\"> ");
	document.write ("</td>");

	document.write ("<td><table><tr><td align=\"center\" class=texte >");
	document.write ("<font size=\"+1\">");
	document.write (photo.description);
	document.write ("</font>");
	document.write ("</td></tr>");
	document.write ("<tr><td align=\"right\" class=texte >");
	document.write ("<font>");
	document.write (photo.prix);
	document.write ("</font>");
	document.write ("</td></tr></table>");

	document.write ("</td></tr>");
	if (! nouvelleFenetre) {
//		document.write ("<tr><td align=\"left\" colspan=\"2\"><a href=\""+top.rep+"\">Retour</a></td></tr>");
		document.write ("<tr><td align=\"left\"><a href=\""+top.rep+"\">Retour</a></td>")
		document.write ("<td align=\"right\"><a href=\"../mail/mail.html\" target=\"frameDroite\"><img src=\"../../images/mail.gif\" border=\"0\"></a></td></tr>");
	}
	document.write ("</table>");
};

function afficheCreationHorizontale (photo){
	document.write ("<table align=\"center\">");
	if (! nouvelleFenetre) {
//		document.write ("<tr><td align=\"left\" colspan=\"2\"><a href=\""+top.rep+"\">Retour</a></td></tr>");
		document.write ("<tr><td align=\"left\"><a href=\""+top.rep+"\">Retour</a></td>")
		document.write ("<td align=\"right\"><a href=\"../mail/mail.html?imRep="+top.repPhotos+"vignettes/&imName="+photo.fichier+"&imTitre="+photo.titre+"\" target=\"frameDroite\"><img src=\"../../images/mail.gif\" border=\"0\"></a></td></tr>");
	}
	document.write ("<tr><td align=\"center\"  >");
	document.write ("<font size=\"+4\"><B>");
	document.write (photo.titre);
	document.write ("</B></font>");
	document.write ("</td></tr>");
	document.write ("<tr><td  align=\"center\">");
	document.write ("<img src=\""+top.repPhotos+photo.fichier+"\"> ");
	document.write ("</td></tr>");
	document.write ("<tr><td align=\"center\" class=texte >");
	document.write ("<font size=\"+1\">");
	document.write (photo.description);
	document.write ("</font>");
	document.write ("</td></tr>");
	document.write ("<tr><td align=\"right\" class=texte >");
	document.write ("<font>");
	document.write (photo.prix);
	document.write ("</font>");
	document.write ("</td></tr>");
	if (! nouvelleFenetre) {
//		document.write ("<tr><td align=\"left\" colspan=\"2\"><a href=\""+top.rep+"\">Retour</a></td></tr>");
		document.write ("<tr><td align=\"left\"><a href=\""+top.rep+"\">Retour</a></td>")
		document.write ("<td align=\"right\"><a href=\"../mail/mail.html\" target=\"frameDroite\"><img src=\"../../images/f\" border=\"0\"></a></td></tr>");
	}
	document.write ("</table>");
};


function afficheCreation (photo){
	if (photo.horizontale) {
		afficheCreationHorizontale (photo)
	}
	else {
		afficheCreationVerticale (photo)
	}
}
	
	
function photo (titre, prix, description, fichier, horizontale) {
	if (horizontale == null ) horizontale = true;
	this.titre = unEspace (titre);
	this.prix = unEspace (prix);
	this.description = unEspace (description);
	this.fichier = fichier;
	this.horizontale = horizontale;
	this.nouvelleFenetre = nouvelleFenetre
};
	
function unEspace (chaine) {
	chaine = new String (chaine)
	var rep = chaine.replace (/%20/ig," ")
	return rep;
}

function tabPhotos () {
	this.tab = new Array ()
}

tabPhotos.prototype.addPhoto = addPhoto
tabPhotos.prototype.toutes = toutes

function addPhoto (titre, prix, description, fichier, horizontale) {
	var p = new photo (titre, prix, description, fichier, horizontale);
	this.tab [this.tab.length] = p;
}

function toutes (){
	return this.tab;
}
	
	
	
	
	
	
	
	
	
