define("animate/circle", [], function (require, exports, module) {
	var circle = _.Class({
        initial: function (options) {
            var defaultOp = {
				cid:"circle",
				cx:310,
				cy:181,
				cr:15,
				color:"#ed1e4a"
            };
            this.options = $.extend(true, {}, defaultOp, options);
            this.createcircle();
        },
		createcircle: function () {
			var datac=this.options;
			var R = Raphael(datac.cid), x = datac.cx, y = datac.cy, r = datac.cr, s_color=datac.color;
			R.customAttributes.fg = function(e){
				   var sop = parseFloat(this.data("sop")),//透明度
					   sr = parseFloat(this.data("sr")),//半径
					   isrun = this.data("isrun");//next是否已经启动
					if(e<0.5){
					   this.attr({
						   "stroke-opacity" : sop,
						   r :  2*e*sr		//半径变到最大，即放大动画过程
						});
					}else{
						this.attr({
						   "stroke-opacity" : 2*(1-e)*sop,  //随e变化，透明度参数由1变为0，即为后半段消失动画
						   r:sr
						});
						if(isrun=="no"){
						
						   this.data("c2").attr({fg2:0}).animate(this.data("ab"));
						   this.data("isrun","yes");
						}
						if(e==1){
						   this.data("isrun","no");
						}
					}
			};
			R.customAttributes.fg2 = function(e){
				   var sop = parseFloat(this.data("sop")),
					   sr = parseFloat(this.data("sr"));
					   isrun = this.data("isrun");//next是否已经启动
						if(e<0.5){
						   this.attr({
							   "stroke-opacity" : sop,
							   r :  2*e*sr		//半径变到最大，即放大动画过程
							});
						}else{
							this.attr({
							   "stroke-opacity" : 2*(1-e)*sop,  //随e变化，透明度参数由1变为0，即为后半段消失动画
							   r:sr
							});
							if(isrun=="no"){
							   this.data("c").attr({fg:0}).animate(this.data("ab"));
							   this.data("isrun","yes");
							}
							if(e==1){
							   this.data("isrun","no");
							}
						}
			};
			
			var pool = [];
			var ani = function(r_f,r_i,i){
				var c=R.circle(x, y, 0).attr({fg:0,fill:"none","stroke-width":r_f,stroke:s_color,"stroke-opacity":1-(2*i+1)/10});
				c.data({"sop":1-(2*i+1)/10,"sr":r-r_i});
				var c2=R.circle(x, y, 0).attr({fg2:0,fill:"none","stroke-width":r_f,stroke:s_color,"stroke-opacity":1-(2*i+1)/10});
				c2.data({"sop":1-(2*i+1)/10,"sr":r-r_i});
				c.data("isrun","no");
				c2.data("isrun","no");
				var a = Raphael.animation({fg:1},3000,function(){
				});
				var b = Raphael.animation({fg2:1},3000,function(){
				});
				c.data("c2",c2);
				c.data("ab",b);
				c2.data("c",c);
				c2.data("ab",a);
				c.animate(a);
			}
			for(var i=0;i<5;i++)
			{
				var r_f,r_i;//最外层线宽
				if(i==0)
					r_f=1,r_i=0;
				else
					r_f=2,r_i=2*i-1;
				ani(r_f,r_i,i);//ani(2,7,4)
				
			}
			var cp=R.circle(x,y,1).attr({fill:"none","stroke-width":1,stroke:s_color});
        },
	});
    module.exports = circle;
});
/*$("[data-circle]").each(function(){
	var cid=$(this).attr("id"),
		cx=$(this).data("x"),
		cy=$(this).data("y"),
		cr=$(this).data("r");
	
	var testd = new circle({
	});
});*/

