var imageTrail = Class.create({
	
	initialize:function( infos ){
		this.offsetfrommouse = infos.offsetfrommouse;
		this.currentimageheight = isSet( infos.currentimageheight ) ? infos.currentimageheight : 0;
		this.moveLeft = isSet( infos.moveLeft ) ? infos.moveLeft : 0;
		this.nameDiv = infos.nameDiv;
		this.contentDiv = infos.contentDiv;
		this.lanceur = infos.lanceur;
		$(this.lanceur).observe( 'mousemove' , this.followmouse.bindAsEventListener( this ) );
		$(this.lanceur).observe( 'mouseout' , this.destroy.bind( this ) );
	},

	createContainer:function(){
		var elemntsFrame = {
				'htmlelmt' : 'div',
				'txtContent' : this.contentDiv, 
				'attributes' : { 'id' : this.nameDiv , 'style' : 'display:none;' }
			   };
		$('page-content').createFrame( elemntsFrame );
	},
	
	followmouse:function( e ) {
		if( !isSet( $(this.nameDiv) ) ) this.createContainer();
		
		var xcoord = this.offsetfrommouse[0];
		var ycoord = this.offsetfrommouse[1];
		
		var docheight = document.body.cumulativeScrollOffset()[1];
		var docwidth =  955;
		
		if( this.moveLeft > 0 && ( docwidth - e.pageX ) < this.moveLeft ){
			xcoord += e.pageX - this.moveLeft;
		}else{
			xcoord += e.pageX;
		}

		if( docheight < ( e.pageY - this.currentimageheight ) ){
			ycoord += e.pageY - this.currentimageheight;
		} else {
			ycoord += e.pageY;
		}

		if(ycoord < 0) {
			ycoord = ycoord*-1;
		}
		
		$(this.nameDiv).style.left = xcoord+"px";
		$(this.nameDiv).style.top = ycoord+"px";
		$(this.nameDiv).show();

	},
	
	destroy:function(){
		if( isSet( $(this.nameDiv) ) ) $(this.nameDiv).remove();
	}

});