var Ripple = function(radius) {
	this.radius = radius;
	this.alpha = 1;
	this.top = 150;
	this.left = 150;
	
	this.init();
};

Ripple.prototype = {
	init: function(){
		var canvas = document.getElementById('canvassample');
		if (!canvas || !canvas.getContext)
			return false;
		this.ctx = canvas.getContext('2d');
	},

	draw: function(){
		// 消すとちょっと変になっちゃうからやめた
		// this.canvasClear();

		this.ctx.beginPath();
		this.ctx.globalAlpha = this.alpha;
		this.ctx.strokeStyle = 'rgb(128, 100, 162)';
		this.ctx.arc(this.top, this.left, this.radius, 0, Math.PI*2, false);
		this.ctx.stroke();
		this.alpha -= 0.1;
		this.radius += 2;

		if(this.alpha <= 0)
			return;

		var _this = this;
		setTimeout(function(){
			_this.draw();
		}, 50);
	},

	canvasClear: function(attribute){
		this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
	},
	
	pos: function(event){
		if (!event) var event = window.event;
		if (!event.pageX) event.pageX = event.clientX + document.body.scrollLeft;
		if (!event.pageY) event.pageY = event.clientY + document.body.scrollTop;
		
		return {
			top: event.pageX,
			left: event.pageY
		};
	}
}

