var topazShip = Class.create();

topazShip.prototype = {
  initialize: function() {
		this.options = {};
		this.options.fps = 25.0;
		this.options.bounce = 13.0;
		this.options.decel = 11.0;
		this.options.friction = 0.0;
		this.options.easing = 4.0;
		this.options.duration = 0.2;
		this.handle = false;
		this.listen($('follow').cumulativeOffset().left,0, 104, 830);
	},
  
  listen: function(xPos, yPos, xRaster, maxLength) {
	  Event.observe('navi','mouseover',function(evt) {
		if ((Event.pointerX(evt) >= xPos) && (Event.pointerX(evt)<=xPos+maxLength)) {
            this.launch(((Math.floor((Event.pointerX(evt)-xPos)/xRaster)*xRaster)),yPos);
        $('ship').style.backgroundColor="grey";
      } 
	 }.bindAsEventListener(this));
		
	Event.observe('navi','mouseout',function(evt) {
			$('ship').style.backgroundColor="white";
    }.bindAsEventListener(this));
		
	},
	launch: function(toX,toY) {
		if( this.handle ) {
			this.handle.cancel();
		}
		this.handle = new Effect.Move('ship',{
  			mode: 'absolute',
  			x: toX,
  			y: toY,
  			duration: this.options.duration,
  			fps: this.options.fps,
  			transition: Effect.Transitions.sinoidal,
  			afterFinish: function(){this.handle=false}.bind(this)
  		});
	}
};
