function 
(x, y) {
	this.x = x;
	this.y = y;
	this.width = 25;
	this.height = 100;
	this.up(false);
	this.down(false);
	this.ai = false;
	this.color = "green";
}

Paddle.ACCEL = 3;
Paddle.MAXSPD = 10;
Paddle.FROTT = .8;

Paddle.prototype = new Polygon();

Paddle.prototype.up   = function(b) { this.b_up = b; };
Paddle.prototype.down = function(b) { this.b_down = b; };

Paddle.prototype.doAI = function(pong) {
	this.b_down = false;
	this.b_up = false;
	var bally = pong.h / 2;
	var balld = Infinity;
	var ballx = -Infinity;
	var ballvx = -Infinity
	for(var i in pong.entities)
		if (pong.entities[i] instanceof Ball) {
			var ball = pong.entities[i];
			var bvx = (this.x - pong.h / 2) * ball.vx;
			var vd = Math.abs(ball.x - this.x) / ball.vx;
			vd = (vd < 0 ? vd * -2 : vd);
			if ( (ballvx < 0 && bvx > 0) || (bvx * ballvx > 0 && vd < balld) || balld == Infinity ) {
				balld = vd;
				bally = ball.y;
				ballx = ball.x;
				ballvx = bvx;
			}
	}
	if (balld == Infinity)
		return ;
	if (pong.debug) {
		pong.ctx.beginPath();
		pong.ctx.moveTo(this.x + this.width/2 , this.y + this.height/2);
		pong.ctx.lineTo(ballx, bally);
		pong.ctx.stroke();
		pong.ctx.closePath();
	}
	if (this.y + this.height*3/4 < bally)
		this.b_down = true;
	if (this.y + this.height/4 > bally)
		this.b_up = true;
}

Paddle.prototype.update = function(pong) {
	if (this.ai)
		this.doAI(pong);
	if (this.b_up   && this.vy > -Paddle.MAXSPD) this.vy -= Paddle.ACCEL;
	if (this.b_down && this.vy <  Paddle.MAXSPD) this.vy += Paddle.ACCEL;
	this.vy *= Paddle.FROTT;

	Polygon.prototype.update.call(this);

	if (this.y < 0) {
		this.vy *= -1;
		this.y = 0;
	} else if (this.y > pong.h - this.height) {
		this.vy *= -1;
		this.y = pong.h - this.height;
	}
};

Paddle