//! objet lecteur de BD en une ligne. Plus d'infos en bas.
function stripReader(id, url, width, height, panels, top, left, panelwidth) {
	this.id = id;
	this.panels = panels;
	this.bar_height = 19; // en pixels, changeable
	top = (top==null)? 0 : top;
	this.realtop = this.bar_height-top;
	this.left = (left==null)? 0 : left;
	this.lecture = 0;
	this.pos = this.left;
	this.panels = panels;
	this.panelwidth = (panelwidth==null)? width : panelwidth;

	this.mklink = function(texte, signal) {
		var lien = document.createElement('a');
		lien.appendChild( document.createTextNode(texte) );
		lien.href='#';
		lien.setAttribute('class', (signal<0)?'prev':'next' );
		lien.setAttribute('onclick', 'return '+this.id+'.stripMove('+signal+', "'+this.id+'");');
		//lien.onclick = function() { return alert(this.parentNode); } // pour IE
		if (signal<0) lien.style.display = 'none';
		return lien;
	}
	this.stripMoving = function(i, id) {
		but = this.lecture * this.panelwidth + this.left;
		this.pos += i*5;
		this.tag.style.backgroundPosition = (0-this.pos)+'px '+this.realtop+'px';
		if (i<0 && this.pos<=but) return;
		if (i>0 && this.pos>=but) return;
		setTimeout(id+'.stripMoving('+i+', "'+id+'")', 20);
	}

	this.stripMove = function(i, id) {
		if (i<0 && this.lecture<=0) return false;
		if (i>0 && this.lecture>=this.panels-1) return false;
		this.lecture+=i;
		this.majLinks();
		setTimeout(id+'.stripMoving('+i+', "'+id+'")', 20);
		return false;
	}

	this.majLinks = function() {
		var liens = this.tag.getElementsByTagName('a');
		if (this.lecture<=0)
			liens[0].style.display='none';
		else
			liens[0].style.display='';
		if (this.lecture>=this.panels-1)
			liens[1].style.display='none';
		else
			liens[1].style.display='';
	}

	this.mkFloat = function(sense) {
		if (sense!='right') sense='left'; // error killer / default
		this.tag.style.cssFloat = sense;
		if (sense=='left')
			this.tag.style.marginRight = '0.5em';
		else
			this.tag.style.marginLeft = '0.5em';
	}

	// constructeur

	divliens = document.createElement('div');
	divliens.appendChild( this.mklink('«', -1) );
	divliens.appendChild( this.mklink('»',  1) );
	divliens.appendChild( document.createTextNode('Strip Reader') );
	divliens.style.height = this.bar_height+'px';

	this.tag = document.createElement('div');
	this.tag.className = 'stripReader';
	this.tag.style.width = width+'px';
	this.tag.style.height= height+'px';
	this.tag.style.backgroundImage = 'url('+url+')';
	this.tag.style.backgroundPosition = (0-left)+'px '+this.realtop+'px';
	this.tag.appendChild( divliens );

	document.getElementById(id).parentNode.appendChild( this.tag );
}
/** Infos :

	Exemple de CSS utilisable :
	div.stripReader { background: 0 19px no-repeat; border: 2px solid #067; }
	div.stripReader div { font: bold 1em sans-serif; text-align:center; background: #0ab; }
	div.stripReader div a { color:black; text-decoration:none; float:left; margin: 0 0.2em }
	div.stripReader div a+a { float:right }

	Exemple d'appel :
	<script type="text/javascript" id="PVP1">
		PVP1 = new stripReader('PVP1', 'http://www.pvponline.com/images/3008.gif', 170,285, 5);
		PVP1.mkFloat('right');
	</script>

	Comme l'on voit, le nom de l'objet est énormément répété.
*/
