function Fanart(id,titre,auteur,date,genre,descr,type,aobj,hobj)
{
	this.id=id
	this.titre=titre
	this.auteur=auteur
	this.date=date
	this.genre=genre
	this.descr=descr
	this.type=type
	this.aobj=aobj
	this.hobj=hobj || false
	this.points=0
	this.shortDate=date.getDate()+"/"+(date.getMonth()>9?date.getMonth():"0"+date.getMonth())+"/"+date.getFullYear()
	var shortTitre=(titre.length>31)?titre.substr(0,30)+String.fromCharCode(8230):titre
		var shortAuth=(auteur.length>15)?auteur.substr(0,14)+String.fromCharCode(8230):auteur
	this.TR=document.createElement("TR")
	var newTD0=document.createElement("TD")
	newTD0.appendChild(document.createTextNode(shortTitre))
	var newTD1=document.createElement("TD")
	newTD1.appendChild(document.createTextNode(this.shortDate))
	var newTD2=document.createElement("TD")
	newTD2.appendChild(document.createTextNode(shortAuth))
	var newTD3=document.createElement("TD")
	newTD3.appendChild(document.createTextNode(types[this.type]))
	var newTD4=document.createElement("TD")
	newTD4.appendChild(document.createTextNode(genres[this.genre]))
	this.TR.appendChild(newTD0)
	this.TR.appendChild(newTD1)
	this.TR.appendChild(newTD2)
	this.TR.appendChild(newTD3)
	this.TR.title=id
	this.TR.onclick=fa_se
	this.TR.ondblclick=fa_op
	return this
}

function fa_se(e)
{
	fa_sh(this.title)
}

function fa_op(e)
{
	window.location="fanart/detail.php?id="+this.title
}

function FanartData(h,w,mem,format,depht)
{
	this.h=h
	this.w=w
	this.mem=mem || 30
	this.format || 0
	this.depht || (format==0||format==2)?5:format==2?1:4
	return this
}

var genres=['scène du livre','portrait','scène fictive','décor','objet','monstre','quidditch','autre']

var formats=['jpg','png','gif','jp2']

var profondeurs=['1','8','8g','16a','24','32','32a','48']

var types=['crayon','plume','image de synthèse','dessin vectoriel','feutre','peinture','craie/fusain','autre']

function parTitre(a,b)
{
	if(a.titre>b.titre)
		return 1
	if(a.titre<b.titre)
		return -1
	return 0
}

function parDate(a,b)
{
	if(a.date.getTime()>b.date.getTime())
		return -1
	if(a.date.getTime()<b.date.getTime())
		return 1
	return parTitre(a,b)
}

function parAuteur(a,b)
{
	if(a.auteur>b.auteur)
		return 1
	if(a.auteur<b.auteur)
		return -1
	return parTitre(a,b)
}

function parGenre(a,b)
{
	if(a.genre>b.genre)
		return 1
	if(a.genre<b.genre)
		return -1
	return parTitre(a,b)
}

function parType(a,b)
{
	if(a.type>b.type)
		return 1
	if(a.type<b.type)
		return -1
	return parTitre(a,b)
}
