var stroke = false;
var fill = true;
var blur = true;
var blurFill = "rgba(0,0,0, 0.1)";
var circleGradient = {
    type : "radial",
    endRadius : 15,
    colorStops : [
      [ 0, "rgba(255,0,0,1)" ],
      [ 0.2, "rgba(80,20,20,0.2)" ],
      [ 1, "rgba(10,0,40,0)" ]
    ]
  }

function initialize (id)
{
    canvas = new Canvas(id, 420, 60);
	
	canvas.fill = blurFill;
	var scene = new CanvasNode();
    for (var i = 0; i < 15; i++) {
      scene.append(makeCircle(i / 20 * 4 * Math.PI));
    }
    scene.rotation = [0, canvas.width / 2, canvas.height / 2];
    scene.compositeOperation = "lighter";
    scene.fill = new Gradient(circleGradient);
	canvas.append(scene);

}

function makeCircle (offset)
{
    var circle = new Circle(10);
	circle.circles = this;
    circle.offset = offset;
    circle.addFrameListener(circleMotion);
    return circle;
}

function circleMotion (t)
{
    this.fill = this.circles.fill;
    this.stroke = this.circles.stroke;
    var trw = this.root.width + 160;
    this.x = ((t / 10 + this.offset * trw) % trw) * 1.4;
    this.y = 30;
    this.scale = 0.9 + Math.cos(this.offset * Math.PI * 4 + t / 1200);
}

function setBlur (blur)
{
    blur = blur;
    canvas.fill = blur;
}


$(document).ready(function() {
	
	if (($.browser.msie) && ($.browser.version < 9))
	{
		
	}
	else
	{
		var id = document.getElementById('laser');
		window.onload = initialize(id);
	}
	
});
