var bd_num = 0;


function bd( slideshow, couvs, titre, scenariste, dessinateur, coloriste, editeur, collection, prix, parus, aparaitre, sites, titre_id, texte_id )
{
	this.slideshow = slideshow;
	this.couvs = couvs;
	this.titre = titre;
	this.scenariste = scenariste;
	this.dessinateur = dessinateur;
	this.coloriste = coloriste;
	this.editeur = editeur;
	this.collection = collection;
	this.prix = prix;
	this.parus = parus;
	this.aparaitre = aparaitre;
	this.sites = sites;
	this.titre_id = titre_id;
	this.texte_id = texte_id;
	
	this.display = bd_display;
	this.display_title = bd_display_title;
	this.display_text = bd_display_text;
	
	this.id = "bd_" + ++bd_num;
	window[this.id] = this;
}


function bd_display()
{
	this.slideshow.reset();
	this.slideshow.play();
	this.display_title();
	this.display_text();
}


function bd_display_title()
{
	document.getElementById( this.titre_id ).innerHTML = this.titre;
}


function bd_display_text()
{
	var texte = "";
	
	if( this.scenariste == this.dessinateur && this.dessinateur == this.coloriste )
		texte += "Sc&eacute;nario, dessin & couleurs : " + this.scenariste + "<br /><br />";	
	
	else if( this.scenariste == this.dessinateur )
		texte += "Sc&eacute;nario & dessin : " + this.scenariste + "<br />Couleurs : " + this.coloriste + "<br /><br />";
	
	else if( this.scenariste == this.coloriste )
		texte += "Sc&eacute;nario & couleurs : " + this.scenariste + "<br />Dessin : " + this.dessinateur + "<br /><br />";
		
	else
		texte += "Sc&eacute;nario : " + this.scenariste + "<br />" + "Dessin : " + this.dessinateur + "<br />Couleurs : " + this.coloriste + "<br /><br />";

		
	if ( this.editeur != null )
	{
		texte += "Livre";
		if( this.parus != null && this.parus.length > 1 ) texte += "s";
		texte += " &eacute;dit&eacute;";
		if( this.parus != null && this.parus.length > 1 ) texte += "s";
		texte += " aux &eacute;ditions " + this.editeur;
		if( this.collection != null ) texte += "<br />dans la collection " + this.collection;
		texte += ".";
	}
	
	else
		texte += "Projet non &eacute;dit&eacute;.";
	
	if( this.parus != null )
	{	
		texte += "<br /><br />";
		texte += this.parus.length + " album";
		texte += (1 < this.parus.length) ? "s" : "";
		texte += " &eacute;dit&eacute;";
		texte += (1 < this.parus.length) ? "s" : "";
		texte += " :";
				
		for( i = 0; i < this.parus.length; i++ )
			texte += "<br />- " + this.parus[i].titre + " (" + this.parus[i].annee + ")";
	}
	
	
	if( this.aparaitre != null )
	{
		texte += "<br /><br />&Agrave; para&icirc;tre :";
				
		for( i = 0; i < this.aparaitre.length; i++ )
			texte += "<br />- " + this.aparaitre[i].titre + " (" + this.aparaitre[i].annee + ")";
	}
	
	
	if( this.prix != null )
		texte += "<br /><br />" + this.prix + ".";
		
	if( this.sites != null )
	{
		texte += "<br />";
		
		for( i = 0; i < this.sites.length; i++ )
			texte += "<br /><a href=\"" + this.sites[i].http + "\" class=\"lien\" target=\"_blank\">" + this.sites[i].tag + "</a>";
	}
		
		
	if( this.couvs != null )
	{
		texte += "<br />";
		
		for( i = 0; i < this.couvs.length; i++ )
			texte += "<br /><br /><img border=\"0\" src=\"" + this.couvs[i] + "\" />";
	}
	
	document.getElementById( this.texte_id ).innerHTML = texte;
}




function bd_album( titre, annee )
{
	this.titre = titre;
	this.annee = annee;
}


function bd_site( http, tag )
{
	this.http = http;
	this.tag = tag;
}


function bd_bonus( title, events )
{
	this.title = title;
	this.events = events;
}



function bd_one_shot( slideshow, couv, titre, scenariste, dessinateur, coloriste, editeur, collection, prix, sites, bonus, texte_libre, titre_id, texte_id )
{
	this.slideshow = slideshow;
	this.couv = couv;
	this.titre = titre;
	this.scenariste = scenariste;
	this.dessinateur = dessinateur;
	this.coloriste = coloriste;
	this.editeur = editeur;
	this.collection = collection;
	this.prix = prix;
	this.sites = sites;
	this.bonus = bonus;
	this.texte_libre = texte_libre;
	this.titre_id = titre_id;
	this.texte_id = texte_id;
	
	this.display = bd_one_display;
	this.display_title = bd_one_display_title;
	this.display_text = bd_one_display_text;
}


function bd_one_display()
{
	this.slideshow.reset();
	if (null != this.slideshow)	this.slideshow.play();
	
	this.display_title();
	this.display_text();
}


function bd_one_display_title()
{
	document.getElementById( this.titre_id ).innerHTML = this.titre;
}


function bd_one_display_text()
{		
	var texte = "";
	
	if( this.scenariste != null && this.dessinateur != null && this.coloriste != null )
	{
		if( this.scenariste == this.dessinateur && this.dessinateur == this.coloriste )
			texte += "Sc&eacute;nario, dessin & couleurs : " + this.scenariste + "<br /><br />";	
	
		else if( this.scenariste == this.dessinateur )
			texte += "Sc&eacute;nario & dessin : " + this.scenariste + "<br />Couleurs : " + this.coloriste + "<br /><br />";
	
		else if( this.scenariste == this.coloriste )
			texte += "Sc&eacute;nario & couleurs : " + this.scenariste + "<br />Dessin : " + this.dessinateur + "<br /><br />";
		
		else
			texte += "Sc&eacute;nario : " + this.scenariste + "<br />" + "Dessin : " + this.dessinateur + "<br />Couleurs : " + this.coloriste + "<br /><br />";
	}
		
	if ( this.editeur != null && this.editeur != "n/a" )
	{
		texte += "Livre &eacute;dit&eacute; aux &eacute;ditions " + this.editeur;
		if( this.collection != null ) texte += "<br />dans la collection " + this.collection;
		texte += ".";
	}
	
	else if( this.editeur = null )
		texte += "Projet non &eacute;dit&eacute;.";
		
	
	if( this.prix != null )
		texte += "<br /><br />" + this.prix + ".";
		
		
	if( this.sites != null )
	{
		texte += "<br />";
		
		for( i = 0; i < this.sites.length; i++ )
			texte += "<br /><a href=\"" + this.sites[i].http + "\" class=\"lien\" target=\"_blank\">" + this.sites[i].tag + "</a>";
	}
		
		
	if( this.bonus != null )
	{
		texte += "<br /><br />";		
		texte += "<a href=\"javascript:;\" class=\"lien\"><span" + this.bonus.events.to_string() + ">" + this.bonus.title + "</span></a>";
	}
		
		
	if( this.texte_libre != null )
	{
		texte += "<br /><br />";		
		texte += this.texte_libre;
	}
		
		
	if( this.couv != null )
	{
		texte += "<br /><br /><br /><img border=\"0\" src=\"" + this.couv + "\" />";
	}
	
	document.getElementById( this.texte_id ).innerHTML = texte;
}





