/* Classe hline (x, y, w)*/
function hline(instancename, c, x0, x1, y, w, h, brds, pv, sv) {
	this.o = document.createElement('div');
	var ctn = document.getElementById('ctn'); 
	ctn.appendChild(this.o);
	this.im = instancename;
	this.fct2call = false;
	var ox = (x0 < x1)?x0:(parseInt(ctn.style.width) - (x0 + w)); 
	var ex = (x0 < x1)?x1:parseInt(ctn.style.width) - (x1 + w); 
	this.d = (x0 < x1)?1:-1;
	this.x0 = this.tmpx = new Number(ox); //Absice de la ligne  debut de l'animation et absice courante de la ligne
	this.x1 = new Number(ex); //Absice finale de la ligne
	this.y = new Number(y); //Ordonnée de la ligne
	this.tmpw = new Number(0); //Largeur courante de la ligne
	this.w = new Number(w); //Longueur de la ligne
	this.pv = new Number(pv); //Cadence du positionnement de la line
	this.sv = new Number(sv); //Cadence du dimentionnement de la ligne
	this.ps = this.ss = new Number(20);
	(x0 < x1)?(this.o.style.left = this.tmpx+'px'):(this.o.style.right = this.tmpx+'px');
	this.color = c;
	this.brds = brds;
	this.o.style.position = 'absolute';
	this.o.style.top = y+'px';
	this.o.style.width = this.tmpw+'px';
	this.o.style.height = h+'px';
	this.o.style.borderTop = 'solid '+c+' '+brds[0]+'px';
	//this.o.style.borderRight = 'solid '+c+' '+brds[1]+'px';
	this.o.style.borderBottom = 'solid '+c+' '+brds[2]+'px'; 
	//this.o.style.borderLeft = 'solid '+c+' '+brds[3]+'px';
	this.o.style.background = 'none';
}

hline.prototype.play = function() {
	this.o.style.display = 'block';
	setTimeout(this.im+'.setScale()',0);
	setTimeout(this.im+'.setPos()',0);
}

hline.prototype.setScale = function() { 
	this.tmpw = Math.min(this.tmpw + this.sv, this.w);
	this.o.style.width = this.tmpw+'px';
	if(this.tmpw != this.w) setTimeout(this.im+'.setScale()',this.ss);
	else this.checkEnd();
}

hline.prototype.setPos = function() {
	this.tmpx = Math.min(this.tmpx + this.pv , this.x1);
	if(this.d>0) this.o.style.left = this.tmpx+'px';
	else this.o.style.right = this.tmpx+'px';
	//debug(this.o.parentNode.id+(this.d>0?'left':'right')+'>'+this.o.style.left+' : '+this.o.style.right);
	if(this.tmpx != this.x1) setTimeout(this.im+'.setPos()',this.ps);
	else this.checkEnd();
}

hline.prototype.checkEnd = function() {
	if(this.tmpw == this.w && this.tmpx == this.x1)  {
		this.o.style.borderLeft = 'solid '+this.color+' '+this.brds[3]+'px';
		this.o.style.borderRight = 'solid '+this.color+' '+this.brds[1]+'px';
		if(this.fct2call) {	eval(this.fct2call+'()');}
	}
}

hline.prototype.setFct2call = function(fct) {
	this.fct2call = fct;
}
/****************** Classe vline (x, y, h) **************************/
function vline(instancename, c, x, y0, y1, w, h, brds, pv, sv) {
	this.o = document.createElement('div');
	var ctn = document.getElementById('ctn'); 
	ctn.appendChild(this.o);
	this.im = instancename;
	this.fct2call = false;
	var oy = (y0 < y1)?y0:(parseInt(ctn.style.height) - (y0 + h)); 
	var ey = (y0 < y1)?y1:parseInt(ctn.style.height) - (y1 + h); 
	this.d = (y0 < y1)?1:-1;
	this.y0 = this.tmpy = new Number(oy); //Ordonnée de la ligne en debut de l'animation et absice courante de la ligne
	this.y1 = new Number(ey); //Ordonnée finale de la ligne
	this.x = new Number(x); //Absice de la ligne
	this.tmph = new Number(0); //Hauteur courante de la ligne
	this.h = new Number(h); //Hauteur de la ligne
	this.pv = new Number(pv); //Pas pour le positionnement de la line
	this.sv = new Number(sv); //Pas pour le dimentionnement de la ligne
	this.ps = this.ss = new Number(5); //Cadence du positionnement et du dimentionnement de la line
	(y0 < y1)?(this.o.style.top = this.tmpy+'px'):(this.o.style.bottom = this.tmpy+'px');
	this.color = c;
	this.brds = brds;
	this.o.style.position = 'absolute';
	this.o.style.left = x+'px';
	this.o.style.height = this.tmph+'px';
	this.o.style.width = w+'px';
	//this.o.style.borderTop = 'solid '+c+' '+brds[0]+'px';
	this.o.style.borderRight = 'solid '+c+' '+brds[1]+'px';
	//this.o.style.borderBottom = 'solid '+c+' '+brds[2]+'px';
	this.o.style.borderLeft = 'solid '+c+' '+brds[3]+'px';
	this.o.style.background = 'none';
}

vline.prototype.play = function() {
	this.o.style.display = 'block';
	setTimeout(this.im+'.setScale()',0);
	setTimeout(this.im+'.setPos()',0);
}

vline.prototype.setScale = function() { 
	this.tmph = Math.min(this.tmph + this.sv, this.h);
	this.o.style.height = this.tmph+'px';
	if(this.tmph != this.h) setTimeout(this.im+'.setScale()',this.ss);
	else this.checkEnd();
}

vline.prototype.setPos = function() {
	this.tmpy = Math.min(this.tmpy + this.pv , this.y1);
	this.d>0?(this.o.style.top = this.tmpy+'px'):(this.o.style.bottom = this.tmpy+'px');
	if(this.tmpy != this.y1) setTimeout(this.im+'.setPos()',this.ps);
	else this.checkEnd();
}

vline.prototype.checkEnd = function() {
	if(this.tmph == this.h && this.tmpy == this.y1)  {
		this.o.style.borderTop = 'solid '+this.color+' '+this.brds[0]+'px';
		this.o.style.borderBottom = 'solid '+this.color+' '+this.brds[2]+'px';
		if(this.fct2call) {	eval(this.fct2call+'()');}
	}
}

vline.prototype.setFct2call = function(fct) {
	this.fct2call = fct;
}
/* Classe animg (instancename, src,img, x, y)*/
function aimg(instancename, src, x, y, delay)  {
	this.loadedimg = new Image(); this.loadedimg.src = src;
	this.src=src;
	this.im = instancename;
	this.img = document.createElement('img');
	this.delay = delay?delay:1;
	document.getElementById('ctn').appendChild(this.img);
	this.img.style.display = 'block';
	this.img.style.position = 'absolute';
	this.img.style.left = x+'px'; //Absice de l'image
	this.img.style.top = y+'px'; //Ordonnée de l'image
	this.img.id = this.im;
	this.img.style.display = 'none';
}

aimg.prototype.dispMe = function() {
	document.getElementById(this.im).style.display = 'block'; 
	document.getElementById(this.im).src = eval(this.im+'.src');
	
}

aimg.prototype.play = function() { 
	setTimeout(this.im+'.dispMe()',this.delay);
}