/* Copyright(c) http://www.noma-soft.com/ */

function assignTo(dst,src){for(var key in src){dst[key]=src[key];}}

var dlg_result;
var dlg_arguments;
ModalDialog=function(url){this.width="300px";this.height="300px";this.url=url;this.result="";}
ModalDialog.prototype.doModal=function(arguments){
	var isvalid=true;
	this.result="";
	if(window.showModalDialog){
		this.result=showModalDialog(this.url,arguments,"dialogWidth:"+this.width+";dialogHeight:"+this.height+";");
	}else{
		dlg_arguments=arguments;
		var dialog=window.open(this.url,"dialog","width:"+this.width+",height:"+this.height+",dependent,modal");
		this.result=dlg_result;
		window.onfocus=function(){if(dialog&&!dialog.closed){hwnd.focus();}else if(dialog.closed&&isvalid){isvalid=false;}}
	}
	return isvalid;
}

PaperPluginMgr=function(){}
PaperPluginMgr={
	plugins:{},ctrls:{},items:{},writers:{selctrl:{}},pluginPath:"plugins",editMode:1,showMode:2,mode:2,
	getId:function(pluginName,ctrlId,itemName){return (pluginName+"_"+ctrlId+"_"+itemName);},
	init:function(){/*for(var key in PaperPluginMgr.items){PaperPluginMgr.items[key].init();}*/},
	registerPlugin:function(pluginName,plugin){
		if(!PaperPluginMgr.plugins[pluginName]){
			if(plugin.writeCtrl){PaperPluginMgr.plugins[pluginName]=plugin;plugin.name_=pluginName;}
			else{window.alert(pluginName+" is not the plugin.");}
		}else{window.alert("Plugin:"+pluginName+" is already registered.");}
	}
}
PaperPluginMgr.serializer=new PaperSerializer;

PaperPluginCtrl=function(id,pluginName,initValue){
	var plugin=null;
	if(pluginName!=""){plugin=PaperPluginMgr.plugins[pluginName];}
	this.name=id;this.id=id;this.plugin=plugin;
	if(this.plugin!=null){this.pluginName=plugin.name_;}else{this.pluginName="";}
	this.value=initValue;this.oldValue="";
	this.objects=new Object;this.object=null;
	this.items={};
	this.sharedContext=new Object;
	this.contexts=new Object;
	if(plugin&&plugin.createCtrl){this.object=this.plugin.createCtrl(this);this.objects[plugin.name_]=this.object;}
	this.isInit=false;
	this.isCaptured=false;
	this.deprivedObjects=new Array;
}
PaperPluginCtrl.selectPluginHandler_=function(selctrl,ctrlName){
	var ctrl=PaperPluginMgr.ctrls[ctrlName];
	ctrl.select();
}
PaperPluginCtrl.play_=function(tag,ctrlName){
	var ctrl=PaperPluginMgr.ctrls[ctrlName];
	ctrl.play(tag);
}
PaperPluginCtrl.prototype={
	init:function(){
		for(var key in this.items){this.items[key].init();}
		this.dataTag=document.getElementById('ppc'+(this.view.columnIndex+1)+'_obj_data');
		this.ctrlTag=document.getElementById('ppc'+this.view.columnIndex+'__');
		this.selctrlTag=this.ctrlTag.firstChild;this.propTag=this.selctrlTag.nextSibling.nextSibling.nextSibling;
		if(this.object!=null){this.object.init();}this.isInit=true;},
	write:function(){
		var pluginName;
		var str;
		if(PaperPluginMgr.mode==PaperPluginMgr.editMode){str='<div id="ppc'+this.view.columnIndex+'__">';}
		else{str='<div style="display:none;" id="ppc'+this.view.columnIndex+'__">';}
		str+='<select name="ppc'+(this.view.columnIndex+1)+'_obj_type" onchange="PaperPluginCtrl.selectPluginHandler_(this,'+"'"+this.name+"'"+')">';
		str+='<option value="">none</option>';
		for(pluginName in PaperPluginMgr.plugins){
			if(pluginName!=this.pluginName){str+='<option value="'+pluginName+'">';}
			else{str+='<option value="'+pluginName+'" selected>';}
			if(PaperPluginMgr.plugins[pluginName].pluginLabel){str+=PaperPluginMgr.plugins[pluginName].pluginLabel;}
			else{str+=pluginName;}
			str+='</option>';}
		str+='</select>';
		str+='<input type="button" value="再生" onclick="PaperPluginCtrl.play_(this,\''+this.name+'\')"/>';
		str+='<input type="button" value="停止"/>';
		for(pluginName in PaperPluginMgr.plugins){
			if(pluginName!=this.pluginName){str+='<div class="property-group" style="display:none;border: solid 1px black;margin-left:2px;">';}
			else{str+='<div class="property-group">';}
			str+=PaperPluginMgr.plugins[pluginName].writeCtrl(this);
			str+='</div>';}
			str+='<input type="hidden" id="ppc'+(this.view.columnIndex+1)+'_obj_data"';
			str+=' name="ppc'+(this.view.columnIndex+1)+'_obj_data"/>';
		str+='</div>';
		return str;},
	getViewId:function(){return this.view.getViewId();},
	getViewTag:function(){return this.view.getViewTag();},
	getCanvasId:function(){return this.view.getCanvasId();},
	getCanvasTag:function(){return this.view.getCanvasTag();},
	getSharedContext:function(){return this.sharedContext;},
	getContext:function(){return this.contexts[this.pluginName];},
	getContextByName:function(pluginName){
		if(!this.contexts[pluginName]){this.contexts[pluginName]=new Object;}
		return this.contexts[pluginName];},
	show:function(isShow){this.view.show(isShow);},
	clearView:function(){this.view.clear();},
	showCanvas:function(isShow){this.view.showCanvas(isShow);},
	/* @note about value/ null:plugin is not modified, "":plugin is initialiezed */
	selectPlugin:function(pluginName,value){
		if(pluginName!=""){
			for(var idx=0;idx<this.selctrlTag.length;idx++){
				if(this.selctrlTag.options[idx].value==pluginName){this.selctrlTag.selectedIndex=idx;break;}}
			this.showPluginEditor(pluginName,true);
			this.selectPluginObject(pluginName,value);
		}},
	selectPluginObject:function(pluginName,value){
		this.pluginName=pluginName;
		if(!this.contexts[this.pluginName]){this.contexts[this.pluginName]=new Object;}
		if(this.pluginName!=""){this.plugin=PaperPluginMgr.plugins[this.pluginName];}
		else{this.plugin=null;}
		this.oldValue=this.value;
		this.value=value;
		if(this.plugin){
			if(!this.objects[this.pluginName]){
				if(this.plugin.createCtrl){
					this.object=this.plugin.createCtrl(this);
					this.object.init();
					this.objects[this.pluginName]=this.object;
				}else{this.object=null;}
			}else{this.object=this.objects[this.pluginName];
				if(value==""){this.sendReset(this.pluginName);}
				else if(value!=null){this.clearParam();this.deserialize(this.value);}}
		}else{this.object=null;}},
	showPluginEditor:function(pluginName,isShow){
		var index=1;
		for(var key in PaperPluginMgr.plugins){
			if(key==pluginName){return this.showPluginEditor_(index,isShow);}index++;}
		return false;},
	showPluginEditor_:function(pluginIndex,isShow){
		var index=0; var iter=this.propTag;
		while(iter){
			if(iter.className=="property-group"){
				if((index+1)==pluginIndex){
					if(isShow==true){iter.style.display="block";}
					else{iter.style.display="none";}
					return true;} index++;}
			iter=iter.nextSibling;}
		return false;},
	showAllPluginEditor:function(isShow){
		var iter=this.propTag;
		while(iter){
			if(iter.className=="property-group"){
				if(isShow){iter.style.display="block";}else{iter.style.display="none";}}
			iter=iter.nextSibling;}},
	hideAllPluginEditor:function(){
		var iter=this.propTag;
		while(iter){
			if(iter.className=="property-group"){iter.style.display="none";}
			iter=iter.nextSibling;}},
	select:function(){
		this.sendReleased();
		var pluginIndex=this.selctrlTag.selectedIndex;
		this.selectPluginObject(this.selctrlTag.options[pluginIndex].value,null);
		this.hideAllPluginEditor();
		this.showPluginEditor_(pluginIndex,true);
		this.sendCaptured();},
	sendReset:function(pluginName){
		if(this.object&&this.object.pluginHandler){
			var ev=new Object;ev.type="reset";ev.pluginName=pluginName;
			this.object.pluginHandler(ev);delete ev;}},
	play:function(tag){var mode=PaperPluginMgr.mode;
		this.sendReleased();
		PaperPluginMgr.mode=PaperPluginMgr.showMode;
		this.sendCaptured();
		PaperPluginMgr.mode=mode;},
	sendCaptured:function(){
		if(this.object){
			var ev=new Object;
			if(this.isCaptured==true){
				ev.type="deprived";
				this.deprivedObjects.push(this.object);
				this.object.pluginHandler(ev);}
			else{this.isCaptured=true;}
			ev.type="captured";
			this.object.pluginHandler(ev);
			delete ev;
			this.dataTag.value=this.serialize();}},
	sendReleased:function(){
		var ev={type:"released"};
		for(var index=0;index<this.deprivedObjects.length;index++){this.deprivedObjects[index].pluginHandler(ev);}
		this.deprivedObjects.splice(0,this.deprivedObjects.length);
		if(this.object){this.isCaptured=false;this.object.pluginHandler(ev);}},
	sendModify:function(pluginName,itemName){
		if(this.object&&this.object.pluginHandler){
			var ev=new Object;ev.type="modify";ev.pluginName=pluginName;ev.target=itemName;
			this.object.pluginHandler(ev);delete ev;}
		this.dataTag.value=this.serialize();},
	sendAnimationEnd:function(){
		if(this.object&&this.object.viewerHandler){
			var ev=new Object;ev.type="animationEnd";this.object.viewerHandler(ev);delete ev;}},
	exportParam:function(params){
		for(var key in params){delete params[key];}
		if(this.plugin){
			if(this.object&&this.object.exportParam){
				this.object.exportParam(params);
			}else{
				var target;
				var pluginName=this.pluginName;
				var targets=this.plugin.targets;
				for(var index=0;index<targets.length;index++){
					target=targets[index];
					var elm=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,target));
					if(elm){if((elm.value!="")||(elm.value!=params[target])){params[target]=elm.value;}}
				}
				var dlgCtrl=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,"_"));
				if(dlgCtrl){PaperPluginMgr.serializer.deserialize(params,dlgCtrl.value);}}}},
	clearParam:function(){
		if(this.plugin){
			if(this.object&&this.object.clearParam){this.object.clearParam(params);}
			else{
				var target;
				var pluginName=this.pluginName;
				var targets=this.plugin.targets;
				for(var index=0;index<targets.length;index++){
					target=targets[index];
					var elm=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,target));
					if(elm){if(elm.value!=""){elm.value="";}}}
				var dlgCtrl=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,"_"));
				if(dlgCtrl){dlgCtrl.value="";}}}},
	importParam:function(params){
		if(this.plugin){
			if(this.object&&this.object.importParam){this.object.importParam(params);}
			else{
				var target;var pluginName=this.pluginName;var targets=this.plugin.targets;var index;
				for(index=0;index<targets.length;index++){
					target=targets[index];
					var elm=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,target));
					if(elm){if(params[target]){elm.value=params[target];}else{elm.value="";}}}
				var dlgCtrl=document.getElementById(PaperPluginMgr.getId(pluginName,this.id,"_"));
				if(dlgCtrl){
					var extraCount=0;var str="";
					for(var key in params){
						var isExtra=true;
						for(index=0;index<targets.length;index++){if (targets[index]==key){isExtra=false;break;}}
						if(isExtra){
							extraCount++;
							if(extraCount!=1){str+=PaperPluginMgr.serializer.fieldPad;}
							str+=key; str+=PaperPluginMgr.serializer.namePad; str+=params[key];}}
					dlgCtrl.value=str;}}}},
	serialize:function(){var str;
		if(this.object&&this.object.serialize){str=this.object.serialize();}
		else{var params=new Object;
			this.exportParam(params);str=PaperPluginMgr.serializer.serialize(params);delete params;}
		return str;},
	deserialize:function(str){
		if(this.object&&this.object.deserialize){this.object.deserialize(str);}
		else{var params=new Object;
			PaperPluginMgr.serializer.deserialize(params,str);this.importParam(params);delete params;}},
	bindItem:function(pluginName,itm){
		itm.pluginName=pluginName;
		itm.ctrlName=this.id;
		itm.ctrl=this;
		itm.id=pluginName+'_'+this.id+'_'+itm.name;
		PaperPluginMgr.items[itm.id]=itm;
		this.items[pluginName+'_'+itm.name]=itm;
		if(this.isInit==true){itm.init();}},
	listenEditor:function(ctrl){this.id=ctrl.id;}
}

PaperPluginMgr.createPluginCtrl=function(ctrlName,defaultPluginName,initValue){
	var ctrl;
	ctrl=new PaperPluginCtrl(ctrlName,defaultPluginName,initValue);
	PaperPluginMgr.ctrls[ctrlName]=ctrl;
	return ctrl;
}

PluginTextCtrl=function(name,className,initValue){
	this.ctor_("",className,initValue);
	this.name=name;this.ctrlName="";this.ctrl=null;this.isVisible=true;}
PluginTextCtrl.prototype={
	ctor_:NmTextCtrl.prototype.ctor,
	init:NmTextCtrl.prototype.init,
	get:NmTextCtrl.prototype.get,
	set:NmTextCtrl.prototype.set,
	write:NmTextCtrl.prototype.write,
	modify:function(target){if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}}
}
PluginSelCtrl=function(name,className,initValue){
	this.ctor_("",className,initValue);
	this.name=name;this.ctrlName="";this.ctrl=null;this.isVisible=true;}
PluginSelCtrl.prototype={
	ctor_:NmSelCtrl.prototype.ctor,
	init:NmSelCtrl.prototype.init,
	get:NmSelCtrl.prototype.get,
	set:NmSelCtrl.prototype.set,
	write:NmSelCtrl.prototype.write,
	modify:function(target){if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}}
}

PluginListCtrl=function(name,className,initValue,isArray){
	this.ctor_("",className,initValue,isArray);
	this.name=name;this.ctrlName="";this.ctrl=null;}
PluginListCtrl.prototype={
	ctor_:NmListCtrl.prototype.ctor,
	init:NmListCtrl.prototype.init,
	bindSubCtrl:NmListCtrl.prototype.bindSubCtrl,
	setSub:NmListCtrl.prototype.setSub,
	getSubIndex:NmListCtrl.prototype.getSubIndex,
	setSubIndex:NmListCtrl.prototype.setSubIndex,
	getSubCount:NmListCtrl.prototype.getSubCount,
	setSubCount:NmListCtrl.prototype.setSubCount,
	getSubKey:NmListCtrl.prototype.getSubKey,
	getSubValue:NmListCtrl.prototype.getSubValue,
	loadSub:NmListCtrl.prototype.loadSub,
	saveSub:NmListCtrl.prototype.saveSub,
	write:NmListCtrl.prototype.write,
	save_:NmListCtrl.prototype.save_,
	load_:NmListCtrl.prototype.load_,
	autoIndex_:NmListCtrl.prototype.autoIndex_,
	select:NmListCtrl.prototype.select,
	modify__:NmListCtrl.prototype.modify,
	modify:function(){this.modify__();if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}},
	add:NmListCtrl.prototype.add,
	remove__:NmListCtrl.prototype.remove,
	remove:function(){this.remove__();if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}},
	up__:NmListCtrl.prototype.up,
	up:function(){this.up__();if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}},
	down__:NmListCtrl.prototype.down,
	down:function(){this.down__();if(this.ctrl){this.ctrl.sendModify(this.pluginName,this.name);}},
	set:NmListCtrl.prototype.set,
	get:NmListCtrl.prototype.get,
	update:NmListCtrl.prototype.update
}

PluginDlgCtrl=function(className,initValue){this.ctor(className,initValue);}
PluginDlgCtrl.prototype={
	ctor:function(className,initValue){this.ctor_("",className,initValue);
		this.name="_";this.ctrlName="";this.ctrl=null;},
	ctor_:NmExternalCtrl.prototype.ctor,
	init:NmExternalCtrl.prototype.init,
	write:NmExternalCtrl.prototype.write,
	click:function(target){
		var tag=this.textTag;
		var plugin=PaperPluginMgr.plugins[this.pluginName];
		if(!plugin){return;}
		if(plugin.hasDialog!=true){return;}
		if(!plugin.dialog){
			plugin.dialog=new ModalDialog(PaperPluginMgr.pluginPath+"/dlg/"+this.pluginName+"_dlg.html");}
		var dlg=plugin.dialog;
		if(plugin.dialogWidth){dlg.width=plugin.dialogWidth;}
		if(plugin.dialogHeight){dlg.height=plugin.dialogHeight;}
		var args=new Array(0);args[0]=tag.value;
		if(dlg.doModal(args)){
			if(dlg.result!=undefined){tag.value=dlg.result;this.ctrl.sendModify(this.pluginName,this.name);}}}
}

PaperPluginView=function(id,defaultPluginName,initValue,width,height){
	this.id=id;this.width=width;this.height=height;this.objects=new Array;
	this.ctrl=PaperPluginMgr.createPluginCtrl(this.id,defaultPluginName,initValue);
	this.ctrl.view=this;this.span=0;
}
PaperPluginView.viewerHandler_=function(dom,type,ctrlName){
	var ctrl=PaperPluginMgr.ctrls[ctrlName];
	if(ctrl.object&&ctrl.object.viewerHandler){
		var ev=new Object;ev.type=type;ev.dom=dom;
		ctrl.object.viewerHandler(ev);}}
PaperPluginView.play_=function(id){var ctrl=PaperPluginMgr.ctrls[id];ctrl.view.play();}
PaperPluginView.prototype={
	init:function(){
		this.canvasTag=document.getElementById(this.id+'_canvas');
		this.viewTag=document.getElementById(this.id+'_view');
		this.ctrl.init();this.ctrl.sendCaptured();},
	setAnimation:function(rate){
		this.time=0;this.rate=rate;this.deltaT=parseInt(1000.0/rate);this.span=0;},
	setBackground:function(bg){/*TODO*/},
	appendText:function(text){
		var divTag=document.createElement("div");
		divTag.style.position="absolute";
		divTag.style.left=text.x+"px";
		divTag.style.top=text.y+"px";
		if(text.width){divTag.style.width=text.width+"px";}
		if(text.fontSize){divTag.style.fontSize=text.fontSize+"px";}
		if(text.fontFamily){divTag.style.fontFamily=text.fontFamily;}
		if(text.fontColor){divTag.style.color=text.fontColor;}
		divTag.innerHTML=text.text;
		if(text.isVisible==false){divTag.style.display="none";}
		this.viewTag.appendChild(divTag);
		if(text.endTime){this.bindAnimationObject_(text);text.textTag=divTag;}
		return divTag;},
	appendImage:function(img){
		var imgTag=document.createElement("img");
		imgTag.src=img.src;
		imgTag.style.position="absolute";
		imgTag.style.left=text.x+"px";
		imgTag.style.top=text.y+"px";
		if(text.isVisible==false){imgTag.style.display="none";}
		this.viewTag.appendChild(imgTag);
		if(img.endTime){this.bindAnimationObject_(img);text.imgTag=imgTag;}
		return imgTag;},
	bindAnimationObject_:function(object){
		if(this.span<object.endTime){this.span=object.endTime;} object.view=this; this.objects.push(object);},
	clear:function(){
		var ctx=this.canvasTag.getContext("2d");
		var elm=this.canvasTag;
		if(elm){
			ctx.clearRect(0,0,elm.width,elm.height);
			elm=elm.parentNode;
			var next_iter;
			var iter=elm.firstChild;
			while(iter!=null){
				next_iter=iter.nextSibling;
				if((iter.tagName!="canvas")&&(iter.tagName!="CANVAS")){elm.removeChild(iter);}
				iter=next_iter;}}
		this.objects.splice(0,this.objects.length);
		this.span=0;},
	show:function(isShow){
		if(isShow==true){this.viewTag.style.display="block";}
		else{this.viewTag.style.display="none";}},
	showCanvas:function(isShow){
		if(isShow==true){this.canvasTag.style.display="block";this.viewTag.style.display="block";}
		else{this.canvasTag.style.display="none";this.viewTag.style.display="none";}},
	getViewId:function(){return this.id+'_view';},
	getViewTag:function(){return this.viewTag;},
	getCanvasId:function(){return this.id+'_canvas';},
	getCanvasTag:function(){return this.canvasTag;},
	write:function(){
		var str="";
		str+='<DIV id="'+this.id+'_view" ';
		str+=' onmouseout="PaperPluginView.viewerHandler_(this,'+"'mouseout',"+"'"+this.id+"'"+')"';
		str+=' onmouseover="PaperPluginView.viewerHandler_(this,'+"'mouseover',"+"'"+this.id+"'"+')"';
		str+=' onmousedown="PaperPluginView.viewerHandler_(this,'+"'mousedown',"+"'"+this.id+"'"+')"';
		str+=' onmouseup="PaperPluginView.viewerHandler_(this,'+"'mouseup',"+"'"+this.id+"'"+')"';
		//str+=' onmousemove="PaperPluginView.viewerHandler_(this,'+"'mousemove',"+"'"+this.id+"'"+')"';
		str+=' onclick="PaperPluginView.viewerHandler_(this,'+"'click',"+"'"+this.id+"'"+')"';
		str+=' style="width:'+this.width+"px; height:"+this.height+'px;display:none;position:relative;float:left;">';
		str+='<CANVAS id="'+this.id+'_canvas" '+'" width="'+this.width+'" height="'+this.height+'" style="display:none;position:absolute;top:0px;left:0px;"></CANVAS>';
		str+='</DIV>';
		return str;},
	play:function(){
		for(var index=0;index<this.objects.length;index++){
			if(this.objects[index].play){this.objects[index].play();}}
		if(this.deltaT){
			this.time+=this.deltaT;
			if(this.time<=this.span){setTimeout("PaperPluginView.play_('"+this.id+"')",this.deltaT);}
			else{this.ctrl.sendAnimationEnd();}}
		else{this.ctrl.sendAnimationEnd();}},
	sendAnimationEnd:function(){this.ctrl.sendAnimationEnd();},
	writeCtrl:function(){return this.ctrl.write();},
	serialize:function(){return this.ctrl.serialize(this.id);},
	deserialize:function(str){this.ctrl.deserialize(this.id,str);},
	modify:function(){
		if(this.canvasTag.width!=this.width){this.canvasTag.width=this.width;this.canvasTag.height=this.height;}
		if(this.viewTag.width!=this.width){this.viewTag.style.width=this.width+"px";this.viewTag.style.height=this.height+"px";}}
}

StaticTest=function(text,fontSize,x,y){this.text=text;this.fontSize=fontSize;this.x=x;this.y=y;this.isVisible=true;}
SlideinText=function(text,fontSize,x,y){this.text=text;this.fontSize=fontSize;this.x=x;this.y=y;this.isVisible=false;this.is1st=true;}
SlideinText.prototype={
	setMove:function(addX,addY,sTm,eTm){
		this.addX=addX;this.addY=addY;this.startTime=sTm;this.endTime=eTm;
		this.endX=this.x+addX; this.endY=this.y+addY;},
	play:function(){
		if(this.is1st==true){
			this.dx=this.addX*(this.view.deltaT/(this.endTime-this.startTime));
			this.dy=this.addY*(this.view.deltaT/(this.endTime-this.startTime));
			this.is1st=false;}
		if((this.view.time>this.startTime)&&(this.view.time<=this.endTime)){
			if(this.isVisible==false){this.textTag.style.display="block";this.isVisible=true;}
			if(this.dx){
				if(this.endX){
					if((this.x-this.endX)*this.dx<0){
						this.x+=this.dx;this.textTag.style.left=this.x+"px";}}
					else{this.x+=this.dx;this.textTag.style.left=this.x+"px";}}
			if(this.dy){
				if(this.endY){if((this.y-this.endY)*this.dy<0){
					this.y+=this.dy;this.textTag.style.top=this.y+"px";}}
				else{this.y+=this.dy;this.textTag.style.top=this.y+"px";}}}}
}
FadeinText=function(text,fontSize,x,y){this.text=text;this.fontSize=fontSize;this.x=x;this.y=y;this.isVisible=false;this.is1st=true;}
FadeinText.prototype={
	setFadein:function(bCl,eCl,sTm,eTm){
		this.startTime=sTm;this.endTime=eTm;
		this.nBR=parseInt(bCl.substr(1,2),16);
		this.nBG=parseInt(bCl.substr(3,2),16);
		this.nBB=parseInt(bCl.substr(5,2),16);
		this.nER=parseInt(eCl.substr(1,2),16);
		this.nEG=parseInt(eCl.substr(3,2),16);
		this.nEB=parseInt(eCl.substr(5,2),16);
		this.nColorR=this.nBR;this.nColorG=this.nBG;this.nColorB=this.nBB;},
	play:function(){
		if(this.is1st==true){
			var w=this.view.deltaT/(this.endTime-this.startTime);
			this.dcR=(this.nER-this.nBR)*w;this.dcG=(this.nEG-this.nBG)*w;this.dcB=(this.nEB-this.nBB)*w;
			this.is1st=false;}
		if((this.view.time>this.startTime)&&(this.view.time<=this.endTime)){
			if(this.isVisible==false){this.textTag.style.display="block";this.isVisible=true;}
			this.nColorR+=this.dcR;this.nColorG+=this.dcG;this.nColorB+=this.dcB;
			var tmp; var color="#";
			tmp=parseInt(this.nColorR);if(tmp<16){color+="0";} color+=tmp.toString(16);
			tmp=parseInt(this.nColorG);if(tmp<16){color+="0";} color+=tmp.toString(16);
			tmp=parseInt(this.nColorB);if(tmp<16){color+="0";} color+=tmp.toString(16);
			this.textTag.style.color=color;}}
}
AdditionalText=function(text,fontSize,x,y){this.text="";this.text_=text;this.fontSize=fontSize;this.x=x;this.y=y;this.isVisible=false;this.is1st=true;}
AdditionalText.prototype={
	setShow:function(sTm,eTm){
		this.startTime=sTm;this.endTime=eTm;this.pos=0;},
	play:function(){
		if((this.view.time>this.startTime)&&(this.view.time<=this.endTime)){
			if(this.isVisible==false){this.textTag.style.display="block";this.isVisible=true;}
			if(this.pos<this.text_.length){
				this.text+=this.text_.charAt(this.pos);
				if(navigator.userAgent.indexOf("Firefox")>-1){this.textTag.textContent+=this.text_.charAt(this.pos);}
				else{this.textTag.innerText+=this.text_.charAt(this.pos);}
				this.pos++;}}}
}

