function Circle(canvas,o){
	return new CircleClass(canvas,o);
}

function CircleClass(canvas,o){
	this.canvas = canvas;	
	this.style="fill";
	if (o) {
		this.x = o.x;
		this.y = o.y;
		this.radius = o.radius;
		this.rgb = o.rgb;		
		if(o.hasOwnProperty('style')){
			this.style=o.style;
		}
	}else{
		this.x = 50;
		this.y = 50;
		this.radius = 10;
		this.rgb = "rgb(255,255,255)";		
	}
}

/*
 * Returns the bounding box of the circle.
 * in cords field left right top bottom
 */
CircleClass.prototype.aabb=function(){
	return {
		left: this.x - this.radius,
		top: this.y - this.radius,
		right:this.x+this.radius,
		bottom:this.y+this.radius
	};
}
/*
 * Returns the bounding rect of the circle.
 * in cords field x y width height
 */
CircleClass.prototype.rect=function(){
	return {
		x: this.x - this.radius,
		y: this.y - this.radius,
		width:1+this.radius*2,
		height:1+this.radius*2
	};
}


CircleClass.prototype.draw=function(){
	if(this.style=='stroke'){
		this.canvas.oStrokeCircle(this);		
	}else{
		this.canvas.oFillCircle(this);	
	}
}


if (typeof(JCanvasDSLClass)=="function") {
	//FILL_OR_STROKE=stroke
	//              |fill
	//<circle x="INT" y="INT" radius="INT" rgb="COLOR" style="FILL_OR_STROKE"/>	
	JCanvasDSLClass.prototype.rootNode.circle = function(self, node){
		var ele = Circle(self.canvas);
		self.mapAttributes(node, ele, [['style','style'],['x', 'x', parseInt], ['y', 'y', parseInt], ['color', 'rgb', self.colorSolver], ['radius', 'radius', parseInt]]);
		ele.draw();
		self.elements.push(ele);
	}
}
