//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// rainbow font
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
AE.namespace('AE.app');

AE.app.rainbowFont = function(){
 this.config = {
 		target : "rainbow-font",	// 彩虹目标
		colors : ["EE1B24","EE155C","F06520","F7941C","8CC540","37B549","00A99C","438DCA","A665A7"]	// 彩虹循环颜色数组
 };
 
 this.temp = {
	// 最终HTML序列暂定数组
	htmlArray : []	
 };

 // 返回对象
 return this;
};

// prototype 内容
AE.app.rainbowFont.prototype = {
   // 渲染颜色
   romance : function(){
      var _self = this,config = this.config,temp = this.temp;
      var target = get(config.target);if(!target)return;
      
			var rainbowDomHTML = target.innerHTML;
			temp.colorsLength = config.colors.length;
			
			var colorIndex = 0;
			for(var i=0;i<rainbowDomHTML.length;i++){
				colorIndex++;
				temp.htmlArray.push('<span style="color:#'+config.colors[colorIndex]+'">'+rainbowDomHTML.charAt(i)+'</span>');
				if(i%temp.colorsLength == 0){colorIndex = -1;}
			};
			target.innerHTML = temp.htmlArray.join("");
   },
   
	 init : function(customConfig){
	 	 this.config = YL.merge(this.config,customConfig||{});
	 	 var _self = this,config = this.config,temp = this.temp;

		 _self.romance();

	   if(AE.bom.isIE){ CollectGarbage(); }
	   return _self;
	 }
};

