/**
    @fileOverview \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB룞\xEC옉\xEC쓣 \xEB떞\xEB떦\xED븯\xEB뒗 而댄룷\xEB꼳\xED듃
    @author sculove
    @version 1.17.0
    @since 2013. 4. 15.
*/
/**
    \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB룞\xEC옉\xEC쓣 \xEC젣\xEC뼱\xED븯\xEB뒗 而댄룷\xEB꼳\xED듃

    @class jindo.m.Animation
   	@extends jindo.m.UIComponent
    @keyword component
    @group Component
    @invisible
   	@uses jindo.m.Morph

		@history 1.9.0 Update jindo.m.Morph 湲곕컲\xEC쑝濡\x9C 蹂寃\xBD   
		@history 1.8.0 Release 理쒖큹 由대━利\x88   	    
**/
jindo.m.Animation = jindo.$Class({
	/* @lends jindo.m.Animation.prototype */
	/**
      珥덇린\xED솕 \xED븿\xEC닔

      @constructor
      @param {String|HTMLElement} el \xED뵆由ы궧 湲곗\xA4 Element (\xED븘\xEC닔)
      @param {Object} [htOption] 珥덇린\xED솕 \xEC샃\xEC뀡 媛앹껜
				@param {Boolean} [htOption.bHasOffsetBug=false] android \xED븯\xEC쐞 踰꾩쟾\xEC뿉 議댁옱\xED븯\xEB뒗 offset蹂\xED솚\xEC떆 \xED븯\xEC씠\xEB씪\xEC씠\xED듃,濡깊꺆, \xED겢由\xAD\xEC씠 offset蹂寃\xBD \xEC쟾 \xEC뿕由щ㉫\xED듃\xEC뿉\xEC꽌 諛쒖깮\xED븯\xEB뒗 踰꾧렇 \xEC뿬遺
				@param {Function} [htOption.fEffect=jindo.m.Effect.cubicEaseOut] \xEC븷\xEB땲硫붿씠\xEC뀡\xEC뿉 \xEC궗\xEC슜\xEB릺\xEB뒗 jindo.m.Effect \xEC쓽 \xED븿\xEC닔\xEB뱾
	      @param {Boolean} [htOption.bUseCss3d=jindo.m.useCss3d()] css3d(translate3d) \xEC궗\xEC슜\xEC뿬遺<br />
	          紐⑤컮\xEC씪 \xEB떒留먭린蹂꾨줈 \xEB떎瑜닿쾶 \xEC꽕\xEC젙\xEB맂\xEB떎. \xEC긽\xEC꽭\xEB궡\xEC뿭\xEC\x9D <auidoc:see content="jindo.m">[jindo.m]</auidoc:see>\xEC쓣 李몄“\xED븯湲\xB0 諛붾\x9E\xEB떎.
	      @param {Boolean} [htOption.bUseTimingFunction=jindo.m.useTimingFunction()] \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB룞\xEC옉諛⑹떇\xEC쓣 css\xEC쓽 TimingFunction\xEC쓣 \xEC궗\xEC슜\xED븷吏 \xEC뿬遺<br />false\xEC씪 寃쎌슦 setTimeout\xEC쓣 \xEC씠\xEC슜\xED븯\xEC뿬 \xEC븷\xEB땲硫붿씠\xEC뀡 \xEC떎\xED뻾.<br />
	      紐⑤컮\xEC씪 \xEB떒留먭린蹂꾨줈 \xEB떎瑜닿쾶 \xEC꽕\xEC젙\xEB맂\xEB떎. \xEC긽\xEC꽭\xEB궡\xEC뿭\xEC\x9D <auidoc:see content="jindo.m">[jindo.m]</auidoc:see>\xEC쓣 李몄“\xED븯湲\xB0 諛붾\x9E\xEB떎.
	    @history 1.10.0 Update fEffect \xEC샃\xEC뀡 湲곕낯媛\x92 蹂寃\xBD easeOut => cubicEaseOut
  **/	
	$init : function(htUserOption) {
		this.option({
			bUseH : true,
			bHasOffsetBug : false,
			fEffect : jindo.m.Effect.cubicEaseOut,
			bUseCss3d : jindo.m.useCss3d(),
			bUseTimingFunction : jindo.m.useTimingFunction()
		});
		this.option(htUserOption || {});
		this._initVar();
	},

	/**
	 * 蹂\xEC닔瑜\xBC 珥덇린\xED솕 \xED븳\xEB떎.
	 */
	_initVar: function(el) {
		this.sCssPrefix = jindo.m.getCssPrefix();
		this._htTans = this.option("bUseCss3d") ? {
    	open : "3d(",
    	end : ",0)"
		} : {
    	open : "(",
    	end : ")"
		};
		this._oMorph = new jindo.m.Morph({
			'fEffect' : this.option("fEffect"),
			'bUseTransition' : this.option("bUseTimingFunction")
		}).attach({
			// "progress" : jindo.$Fn(function(we) {
			// 	console.error("progress");
			// 	this.fireEvent("progress",we);
			// },this).bind(),
			"end" : jindo.$Fn(function(we) {
			  this._oMorph.clear();
			  // console.error("end");
				this.fireEvent("end",we);
			},this).bind()
		});
		// set \xEC씠\xED썑 \xEC꽕\xEC젙\xEB릺\xEB뒗 媛\x92.
		this._welTarget = null;	// \xED븯\xEC쐞\xEC뿉\xEC꽌 \xED븘\xEC닔 \xEC꽕\xEC젙.
	},

	/**
	 * [\xED븘\xEC닔 援ы쁽]
	 * \xEB\x8C\xEC긽 而댄룷\xEB꼳\xED듃瑜\xBC 珥덇린\xED솕
	 */
	setStyle : function() {}, // \xED븯\xEC쐞\xEC뿉\xEC꽌 \xED븘\xEC닔 援ы쁽.

	/**
	 * [\xED븘\xEC닔 援ы쁽]
	 * \xEC뿕由щ㉫\xED듃 \xEC씠\xEB룞\xEC떆 諛쒖깮\xED븿
	 * @param  {Number} nPos  \xEC씠\xEB룞\xED븷 醫뚰몴
	 * @param  {Boolen} bNext \xEB떎\xEC쓬\xEC쑝濡\x9C \xEC씠\xEB룞\xED븯\xEB뒗 寃쎌슦 true, \xEC씠\xEC쟾\xEC쑝濡\x9C \xEC씠\xEB룞\xED븯\xEB뒗 寃쎌슦 false
	 */
	move : function(nX, nY, nDuration, option) {},  // \xED븯\xEC쐞\xEC뿉\xEC꽌 \xED븘\xEC닔 援ы쁽.

	/**
	 * \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB\x8C\xEC긽 \xED\x83寃\x9F
	 * @param  {Boolean} isWrapper $Element 諛섑솚 \xEC뿬遺
	 * @return {$Element|HTMLElement} \xED\x83寃\x9F
	 *
	 * @method getTarget
	 */
	getTarget : function(isWrapper) {
		if(isWrapper) {
			return this._welTarget;
		} else {
			return this._welTarget.$value();
		}
	},

	/**
	 * prefix瑜\xBC 遺숈씤 \xEC뒪\xED듃留곸쓣 諛섑솚\xED븳\xEB떎.
	 * @param  {String} str prefix瑜\xBC 遺숈씪 臾몄옄\xEC뿴
	 * @return {String}     prefix瑜\xBC 遺숈씤 臾몄옄\xEC뿴
	 */
	p : function(str) {
		return jindo.m._toPrefixStr(str);
	},

	getTranslate : function(sX,sY) {
		return "translate" + this._htTans.open + sX + "," + sY + this._htTans.end;
	},

	toCss : function(ht) {
		var p, pResult, prefix, htResult = {};
		for(p in ht) {
			pResult = p;
			if(/^@/.test(p)) {
				p.match(/^(@\w)/);
				prefix = RegExp.$1;
				if(/transition|transform/.test(pResult)) {
					if(this.sCssPrefix == "") {
						pResult = p.replace(prefix, prefix.toLowerCase());
					} else {
						pResult = p.replace(prefix, prefix.toUpperCase());
					}
					pResult = pResult.replace("@",this.sCssPrefix);
				} else {
					pResult = pResult.replace("@","");
				}
			}
			htResult[pResult] = ht[p];
		}
		return htResult;
	},

	/**
	 * \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB룞\xEC옉 \xEC뿬遺瑜\xBC 諛섑솚
	 * @return {Boolean} \xEC븷\xEB땲硫붿씠\xEC뀡 \xEB룞\xEC옉 \xEC뿬遺
	 */
	isPlaying : function() {
		return this._oMorph.isPlaying();
	},

  /**
      \xEC븷\xEB땲硫붿씠\xEC뀡\xEC쓣 硫덉텣\xEB떎.
  **/
	stop : function(nMode) {
		if(typeof nMode === "undefined") {
			nMode = 0;
		}
		// console.warn("morph stop---");
		this._oMorph.pause(nMode).clear();
	},

  /**
      \xEC궗\xEC슜\xED븯\xEB뒗 紐⑤뱺 媛앹껜瑜\xBC release \xEC떆\xED궓\xEB떎.
      @method destroy
  **/
	destroy: function() {
		this._oMorph.detachAll("end");
	}
}).extend(jindo.m.UIComponent);