/*
----------------------------------------------------------------
	CreativeDevece JavaScript Library
	core scripts
----------------------------------------------------------------
	version			0.90
	last update		2010/04/09
	author			Yoshihisa Kato/YAH!-cyberstudio
----------------------------------------------------------------
*/

var CD={
	Version:"0.89",
	
	Libs:new Array(
		"alert",
		"embed",
		"menu",
		"anchorctrl",
		"extenddiv",
		"cssswitch",
		"calendar",
		"createfield",
		"editor",
		"timecontrol",
		"base",
		"settings"
	),

	Load:function(){
		/*define global vars*/
		this.UA=new CD_userAgent.Get();

		var dir=null;
		var scripts=document.getElementsByTagName("script");
		for(var i=0;i<scripts.length;i++){
			if(scripts[i].src.indexOf("/cd.js")!=-1){
				dir=scripts[i].src.replace(/cd\.js/,"");
				break;
			}
		}

		/*attach image*/
		this.imageDir=dir+'/image/';

		/*attach part of script*/
		for(var i=0;i<this.Libs.length;i++){
			path=dir+'cd_'+this.Libs[i]+'.js';
			document.write('<script language="JavaScript" type="text/javascript" src="'+path+'"></script>');
		}

		CD_core.setEvent(function(){
			CD_core.addEvent(document,'mousemove',function(e){
				CD._mouseX=CD_core._mouseX(e);
				CD._mouseY=CD_core._mouseY(e);
			});
		});
	},

	/*global vars*/

	UA:'',	//userAgent
	imageDir:'',	//directory for images
	_mouseX:0,		//mouse position X at document mousemove;
	_mouseY:0,		//mouse position Y at document mousemove;
	_minDepth:1000,	//use with CD_core.swapDepths
	debugMode:false	//using debug Mode Flag (true or false)
}



var CD_core={

	createObject:function(Tag,ids,classs,Targets,disableAppend){
		var obj=document.createElement(Tag);
		if(ids)obj.setAttribute("id",ids);
		if(disableAppend==0 || !disableAppend){
			if(!Targets){
				document.body.appendChild(obj);
			}else{
				Targets.appendChild(obj);
			}
		}
		if(classs)obj.className=classs;
		return obj;
	},


/* Get object position */
	getPosition:function(obj,adjustX,adjustY,adjustW,adjustH,setPosition){
		var holdObj=obj;
		this._name=(obj.getAttribute('id'))?obj.getAttribute('id'):'';

		if(obj.style.left){
			this._x=parseInt(obj.style.left.replace(/px/i,''));
		}else{
			this._x=CD_core.getEmbedStyle(obj,'left');
			if(this._x==undefined){
				if(CD.UA.asn=="ie" || CD.UA.asn=="op"){
					this._x=0;
					do{
						this._x+=obj.offsetLeft;
						obj=obj.offsetParent;
					}while(obj);
					obj=holdObj;
				}else{
					this._x=obj.offsetLeft;
				}
			}else{
				this._x=parseInt(this._x.replace(/px/,''));
			}
		}

		if(obj.style.top){
			this._y=parseInt(obj.style.top.replace(/px/i,''));
		}else{
			this._y=CD_core.getEmbedStyle(obj,'top');
			if(this._y==undefined){
				if(CD.UA.asn=="ie" || CD.UA.asn=="op"){
					this._y=0;
					do{
						this._y+=obj.offsetTop;
						obj=obj.offsetParent;
					}while(obj);
					obj=holdObj;
				}else{
					this._y=obj.offsetTop;
				}
			}else{
				this._y=parseInt(this._y.replace(/px/,''));
			}
		}

		if(obj.style.width){
			this._width=parseInt(obj.style.width.replace(/px/i,''));
		}else{
			this._width=CD_core.getEmbedStyle(obj,'width');
			if(this._width==undefined){
				this._width=obj.offsetWidth+adjustW;
			}else{
				this._width=parseInt(this._width.replace(/px/,''));
			}
		}

		if(obj.style.height){
			this._height=parseInt(obj.style.height.replace(/px/i,''));
		}else{
			this._height=CD_core.getEmbedStyle(obj,'height');
			if(this._height==undefined){
				this._height=obj.offsetHeight+adjustH;
			}else{
				this._height=parseInt(this._height.replace(/px/,''));
			}
		}

		if(setPosition){
			obj.style.left=(this._x+adjustX)+"px";
			obj.style.top=(this._y+adjustY)+"px";
			obj.style.width=(this._width+adjustW)+"px";
			obj.style.height=(this._height+adjustH)+"px";
		}

		if(obj.style.position=="absolute" || obj.style.position=="fixed"){
			this._bottom=parseInt(CD_core.getStyle(obj,"Bottom","bottom","bottom"));
			this._right=parseInt(CD_core.getStyle(obj,"Right","right","right"));
		}
	},

	getParentPos:function(objID,adjustX,adjustY,adjustW,adjustH,setPosition){
		var obj=$(objID).parentNode;
		this._name=obj.getAttribute("id");

		var param=new CD_core.getPosition(obj,adjustX,adjustY,adjustW,adjustH,setPosition);
		this._x=param._x;
		this._y=param._y;
		this._width=param._width;
		this._height=param._height;
	},

	/* Get Style Attribute */
	getStyle:function(obj,IEStyleProp,CSSStyleProp,Prop){
		var Val=this.getInlineStyle(obj,IEStyleProp,CSSStyleProp,Prop);
		if(!Val || Val==null || Val==undefined || Val=="initial"){
			Val=this.getEmbedStyle(obj,Prop);
		}
		if(!Val || Val==null || Val==undefined || Val=="initial"){
			return undefined;
		}else{
			return Val;
		}
	},

	getInlineStyle:function(obj,IEStyleProp,CSSStyleProp,Prop) {
		if(obj.style[Prop]){
			return obj.style[Prop];
		}else{
			if (obj.currentStyle) {
				return obj.currentStyle[IEStyleProp];
			} else if (document.defaultView.getComputedStyle) {
				var compStyle = document.defaultView.getComputedStyle(obj,"")||window.getComputedStyle(obj,"");
				return compStyle.getPropertyValue(CSSStyleProp);
			}
		}

	},

	getEmbedStyle:function(obj,Prop){
		var settedClass=obj.className;
		var objID=obj.getAttribute("id");
		var classValue=undefined;
		var cssFile=document.styleSheets;
		if(cssFile){
			for(var i=0;i<cssFile.length;i++){
				var rules=(cssFile[i].cssRules)?cssFile[i].cssRules:cssFile[i].rules;
				for(var n=0;n<rules.length;n++){
					if(rules[n].selectorText==("."+settedClass)||rules[n].selectorText==("#"+objID)){
						if(rules[n].style[Prop]){
							classValue=rules[n].style[Prop];
						}
					}
				}
			}
		}
		return classValue;
	},

	getOffset:function(obj){
		if(CD.UA.asn=="ie" || CD.UA.asn=="op"){
			do{
				this._x+=obj.offsetLeft;
				obj=obj.offsetParent;
			}while(obj);
			obj=$(objID);
		}else{
			this._x=obj.offsetLeft;
		}

		if(CD.UA.asn=="ie" || CD.UA.asn=="op"){
			do{
				this._y+=obj.offsetTop;
				obj=obj.offsetParent;
			}while(obj);
			obj=$(objID);
		}else{
			this._y=obj.offsetTop;
		}

		this._width=obj.offsetWidth;
		this._height=obj.offsetHeight;
	},

	/* Set Object Position */
	setPosition:function(obj,Attr,Val){
		if(typeof(obj)=="string")obj=$(obj);
		if(Val=="NaN")Val=0;
		switch(Attr){
			case "x":
				obj.style.left=Val+"px";
			break;
			case "y":
				obj.style.top=Val+"px";
			break;
			case  "width":
				obj.style.width=Val+"px";
			break;
			case  "height":
				obj.style.height=Val+"px";
			break;
			case  "bottom":
				obj.style.bottom=Val+"px";
			break;
			case "right":
				obj.style.right=Val+"px";
			break;
		}
	},

	setPositionPixel:function(obj,Attr,Val){
		if(typeof(obj)=="string")obj=$(obj);
		if(Attr == "x"){
			obj.style.pixelLeft=Val+"px";
		}else if(Attr == "y"){
			obj.style.PixelTop=Val+"px";
		}else if(Attr == "width"){
			obj.style.pixelWidth=Val+"px";
		}else if(Attr == "height"){
			obj.style.pixelHeight=Val+"px";
		}
	},

	setCenter:function(obj){
		this.setPosition($(obj),"x",(this._windowWidth()-parseInt(this.getStyle($(obj),"Width","width","width")))/2);
		this.setPosition($(obj),"y",(this._windowHeight()-parseInt(this.getStyle($(obj),"Height","height","height")))/2);
	},

	setFixedPosition:function(obj,x,y){
		if(typeof(obj)=="string")obj=$(obj);
		switch(x){
			case "center":
				x=(this._windowWidth()-parseInt(this.getStyle(obj,"Width","width","width")))/2;
			break;
			case "right":
				x=this._windowWidth()-parseInt(this.getStyle(obj,"Width","width","width"));
			break;
			case "left":
				x=0;
			break;
		}
		if(x)this.setPosition(obj,"x",x);
		if(y)this.setPosition(obj,"y",y);
	},

	removeStyleProp:function(obj,prop){
		if(typeof(obj)=="string")obj=$(obj);
		var Style=(CD.UA.asn=="ie")?obj.style.cssText:obj.getAttribute('style');
		var props=prop.split(":");
		for(var i=0;i<props.length;i++){
			switch(props[i].toUpperCase()){
				case "X":
					Style=Style.replace(/ *left: *.+?;*/gi,'');
				break;
				case "Y":
					Style=Style.replace(/ *top: *.+?;*/gi,'');
				break;
				case "W":
					Style=Style.replace(/ *width: *.+?;*/gi,'');
				break;
				case "H":
					Style=Style.replace(/ *height: *.+?;*/gi,'');
				break;
			}
		}
		if(CD.UA.asn=="ie"){
			obj.style.cssText=Style;
		}else{
			obj.setAttribute("style",Style);
		}
	},

	/* Depth(z-index) */
	swapDepths:function(obj,val){
		if(typeof(obj)=="string")obj=$(obj);
		if(!obj.style.zIndex)obj.style.zIndex=0;
		var depth=(val=="nextHighestDepth")?CD._minDepth:val;
		obj.style.zIndex=depth;
		if(val=="nextHighestDepth")CD._minDepth++;
	},

	/* Alpha(Opacity) */
	getAlpha:function(obj){
		var val='';
		switch(CD.UA.asn){
			case "ie":
			val=this.getStyle($(obj),"Filter","filter","filter");
			if(val)val=val.replace(/alpha\(opacity=|\)/ig,"")/100
			break;
			case "ff":
			val=this.getStyle($(obj),"MozOpacity","-moz-opacity","mozOpacity");
			if(val==undefined)val=this.getStyle($(obj),"Opacity","opacity","opacity");
			break;
			case "nn":
			val=this.getStyle($(obj),"MozOpacity","-moz-opacity","mozOpacity");
			break;
			default:
			val=this.getStyle($(obj),"Opacity","opacity","opacity");
		}

		if(!val && val!=0)val=1;

		return Math.round(val*100);
	},

	setAlpha:function(obj,Alpha){
		$(obj).style.filter = "alpha(opacity="+Alpha+")";
		$(obj).style.mozOpacity = Alpha / 100;
		$(obj).style.opacity = Alpha / 100;
	},

	/*Color*/
	getColor:function(obj,Style){
		var color=new Object();
		var clr=(Style=="BG")?CD_core.getStyle($(obj),"BackGroundColor","backgroundColor","backgroundColor"):CD_core.getStyle($(obj),"Color","color","Color");
		if(clr==undefined || !clr)clr="rgb(255,255,255)";
		if(clr.indexOf("#")!=-1){
			clr=clr.replace(/#/,'');
			color.R=parseInt(clr.substring(0,2),16);
			color.G=parseInt(clr.substring(2,4),16);
			color.B=parseInt(clr.substring(4,6),16);
		}else if(clr.toLowerCase().indexOf("rgb")!=-1){
			clr=clr.replace(/\(|\)|rgb| /gi,'');
			color.R=parseInt(clr.split(",")[0]);
			color.G=parseInt(clr.split(",")[1]);
			color.B=parseInt(clr.split(",")[2]);
		}
		return color;
	},

	setColor:function(obj,R,G,B,Style){
		if(Style=="BG"){
			$(obj).style.backgroundColor="rgb("+R+","+G+","+B+")";
		}else{
			$(obj).style.Color="rgb("+R+","+G+","+B+")";
		}
	},

/* Window position Attribute */
	_mouseX:function(e){
		if(navigator.appName == "Opera"){
			return e.clientX;
		}else if(navigator.appName == "Microsoft Internet Explorer"){
			return e.clientX+(document.documentElement.scrollLeft || document.body.scrollLeft);
		}else{
			return e.pageX;
		}
	},

	_mouseY:function(e){
		if(navigator.appName == "Opera"){
			return e.clientY;
		}else if(navigator.appName == "Microsoft Internet Explorer"){
			return e.clientY+(document.documentElement.scrollTop || document.body.scrollTop);
		}else{
			return e.pageY;
		}
	},

	_scrollX:function(){
		//return document.body.scrollLeft||document.documentElement.scrollLeft;
		if(CD.UA.asn!="ie"){
			return document.body.scrollLeft;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.scrollLeft;
			}else{
				return document.documentElement.scrollLeft;
			}
		}
	},
	
	_scrollY:function(){
		//return document.body.scrollTop||document.documentElement.scrollTop;
		if(CD.UA.asn!="ie"){
			return document.body.scrollTop;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.scrollTop;
			}else{
				return document.documentElement.scrollTop;
			}
		}
	},

	_scrollWidth:function(){
		//return document.body.scrollWidth||document.documentElement.scrollWidth;
		if(CD.UA.asn!="ie"){
			return document.body.scrollWidth;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.scrollWidth;
			}else{
				return document.documentElement.scrollWidth;
			}
		}
	},
	
	_scrollHeight:function(){
		//return document.body.scrollHeight||document.documentElement.scrollHeight;
		if(CD.UA.asn!="ie"){
			return document.body.scrollHeight;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.scrollHeight;
			}else{
				return document.documentElement.scrollHeight;
			}
		}
	},

	_windowWidth:function(){
		if(CD.UA.asn!="ie"){
			return window.innerWidth;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.clientWidth;
			}else{
				return document.documentElement.clientWidth;
			}
		}
	},
	
	_windowHeight:function(){
		if(CD.UA.asn!="ie"){
			return window.innerHeight;
		}else{
			if(document.compatMode == "BackCompat"){
				return document.body.clientHeight;
			}else{
				return document.documentElement.clientHeight;
			}
		}
	},
	
	_documentWidth:function(){
		//return document.body.clientWidth||document.documentElement.clientWidth;
	     var pageWidth=0;
		if(window.innerWidth && window.scrollMaxX){	
			pageWidth=window.innerWidth+window.scrollMaxX;
		}else{
			if(document.compatMode == "BackCompat"){
				if(document.body.scrollHeight>document.body.offsetHeight){
					pageWidth=document.body.scrollWidth;
				}else{
					pageWidth=document.body.offsetWidth;
				}
			}else{
				if(document.documentElement.scrollHeight>document.documentElement.offsetHeight){
					pageWidth=document.documentElement.scrollWidth;
				}else{
					pageWidth=document.documentElement.offsetWidth;
				}
			}
		}
		pageWidth=(pageWidth<this._windowWidth())?pageWidth:this._windowWidth();

		return pageWidth;
	},
	
	_documentHeight:function(){
		//return document.body.clientHeight||document.documentElement.clientHeight;
		var pageHeight=0;
		if(window.innerHeight && window.scrollMaxY){	
			pageHeight=window.innerHeight+window.scrollMaxY;
		}else{
			if(document.compatMode == "BackCompat"){
				if(document.body.scrollHeight>document.body.offsetHeight){
					pageHeight=document.body.scrollHeight;
				}else{
					pageHeight=document.body.offsetHeight;
				}
			}else{
				if(document.documentElement.scrollHeight>document.documentElement.offsetHeight){
					pageHeight=document.documentElement.scrollHeight;
				}else{
					pageHeight=document.documentElement.offsetHeight;
				}
			}
		}
		pageHeight=(pageHeight<this._windowHeight())?this._windowHeight():pageHeight;

		return pageHeight;
	},

/*EVENT*/	
	addEvent:function(obj,ev,func){
		if(obj){
			if(obj.addEventListener){
				obj.addEventListener(ev,func,false);
			}else{
				/*__ex:www.r-definition.com/program/js/dom/eventListener.htm__*/
				if(obj==document){
	            	if( ! func._bridge ) {
    	            	func._bridge = new Array(0);
        	    	}
            		var i = func._bridge.length;
            		func._bridge[i] = new Array(3);
            		func._bridge[i][0] = obj;
            		func._bridge[i][1] = ev;
            		func._bridge[i][2] = function() {
            	    	func.apply(obj, arguments);
            		};
            		obj.attachEvent("on"+ev, func._bridge[i][2]);
				}else{
            		obj.attachEvent("on"+ev,func);
				}
				/*__end_ex__*/
			}
		}
	},

	delEvent:function(obj,ev,func){
		if(obj.addEventListener){
			obj.removeEventListener(ev,func,false);
		}else{
			try{
			/*__ex:www.r-definition.com/program/js/dom/eventListener.htm__*/
	            var i = 0; var f = null;
    	        while( i < func._bridge.length ) {
        	        if( func._bridge[i][0] == obj && func._bridge[i][1] == ev ) {
            	        f = func._bridge[i][2];
						//alert(f);
                	    break;
                	}
                	i++;
            	}
            	obj.detachEvent("on"+ev, f);
            	func._bridge.splice(i,1);
			/*__end_ex__*/
			}catch(e){}
		}
/*
		if(event.preventDefault){
			event.preventDefault();
			event.stopPropagation();
		}else{
			event.returnValue = false;
			event.cancelBubble = true;
		}
*/
	},

	DOMLoadEvent:Array(),
	setEvent:function(func){
		if(CD.UA.asn!="ie" && CD.UA.asn!="op"){
			CD_core.addEvent(document,"DOMContentLoaded",func);
/*
		}else if(CD.UA.asn=="op"){
			document.addEventListener("DOMContentLoaded",function(){
				for(var i=0;i<document.styleSheets.length;i++){
					if(document.styleSheets[i].disabled){
						setTimeout(arguments.callee,0);
						return;
					}
				}
				eval(func);
			},false);
*/
		}else{
			CD_core.addEvent(window,"load",func);
		}
	},

	loadEvent:function(){
		for(var i=0;i<CD_core.DOMLoadEvent.length;i++){
			if(CD.UA.asn!="ie" && CD.UA.asn!="op"){
				CD_core.addEvent(document,"DOMContentLoaded",CD_core.DOMLoadEvent[i]);
			}else{
				CD_core.addEvent(window,"load",CD_core.DOMLoadEvent[i]);
			}
		}
	},

	cancelEvent:function(e){
		if (!e) return false;
		if (CD.UA.asn=="ie") {
			e.returnValue = false;
			e.cancelBubble = true;
		} else {
			e.preventDefault();
			e.stopPropagation && e.stopPropagation();
		}
		return false;	
	},

/*utility*/
	chomp:function(str){
		str=str.replace(/[\r|\n]/ig,'');
		return str;
	},


/*Tween*/
	startPos:new Array(),
	endofPos:new Array(),
	moveVect:new Array(),
	timer:new Array(),
	fps:33,
	dpf:5,

	options:new Array(),

	addTween:function(obj,attr,pos,ease,option){
		if(this.timer[obj+"_"+attr]){
			this.endTween(obj,attr);
		}

		this.options[obj]=new Array();
		if(option){
			var optVals=option.split(";");
			for(i=0;i<optVals.length;i++){
				this.options[obj][optVals[i].split(":")[0]]=optVals[i].split(":")[1];
			}
		}

		if(attr=="x"){
			styleAttr="left";
		}else if(attr=="y"){
			styleAttr="top";
		}else{
			styleAttr=attr;
		}

		if($(obj).style[styleAttr]!=pos+"px"){
			if($(obj).style.position=="static" || $(obj).style.position==''){
				$(obj).style.position="relative";
			}
			this.endofPos[obj+"_"+attr]=pos;
			this.timer[obj+"_"+attr]=setInterval("CD_core.actTween(\'"+obj+"\',\'"+attr+"\',\'"+ease+"\')",this.fps);
			if(this.options[obj]['start'])eval(this.options[obj]['start']);
		}
	},	

	actTween:function(obj,attr,ease){
		var pos=new CD_core.getPosition($(obj),0,0,0,0,0);
		var vect=(pos["_"+attr]>this.endofPos[obj+"_"+attr])?-1:1;
		this.dpf=Math.abs(Math.floor((this.endofPos[obj+"_"+attr]-pos["_"+attr])/(this.fps*(ease/100))));
		this.dpf=(this.dpf<1)?1:this.dpf;
		var move=pos["_"+attr]+(this.dpf*vect);

		if(this.endofPos[obj+"_"+attr]-move<=1 && vect==1){
			CD_core.setPosition($(obj),attr,this.endofPos[obj+"_"+attr]);
			if(this.options[obj]['complete']){eval(this.options[obj]['complete']);}
			clearInterval(this.timer[obj+"_"+attr]);
		}else if(this.endofPos[obj+"_"+attr]-move>=1 && vect==-1){
			CD_core.setPosition($(obj),attr,this.endofPos[obj+"_"+attr]);
			if(this.options[obj]['complete']){eval(this.options[obj]['complete']);}
			clearInterval(this.timer[obj+"_"+attr]);
		}else{
			CD_core.setPosition($(obj),attr,move);
		}

		if(this.options[obj]['enterframe'])eval(this.options[obj]['enterframe']);

		if(this.options[obj]['fixedCenter']=="true"){
			CD_core.setPosition($(obj),'x',(this._windowWidth()-move)/2);
		}
	},

	endTween:function(obj,attr){
		clearInterval(this.timer[obj+"_"+attr]);
	},

/*Cookie*/
	setCookie:function(cookieName,cookieValue,expireTime,cPath){
		var expdate=new Date();
		expdate.setTime(expdate.getTime()+expireTime*(60*60*1000))
		document.cookie=cookieName+"="+escape(cookieValue)+
		((expdate==null)?"":("; expires="+expdate.toGMTString()))+
		((cPath==null)?"; path=/":("; path="+cPath));
	},

	getCookie:function(cookieName){
		var cname=cookieName+"=";
		var i=0;
		while(i<document.cookie.length){
			var j=i+cname.length;
			if(document.cookie.substring(i,j)==cname){
			var leng=document.cookie.indexOf(";",j);
			if(leng==-1)
				leng=document.cookie.length;
				return unescape(document.cookie.substring(j,leng));
			}
			i=document.cookie.indexOf(" ",i)+1;
			if(i==0)break;
		}
		return "";
	},

	cookieDisableMsg:function(layerID){
		var cookieStatus=CD_canCookie();
		var disableMsg='<strong class="notice">Cookieをご利用いただかない場合、サイトの機能の一部がご利用いただけなくなります。<br />CookieをONにして、ご覧いただきますよう、お願いします。</strong>';
		if(!cookieStatus){
			$(layerID).style.display="block";
			$(layerID).innerHTML=disableMsg;
		}
	},

	canCookie:function(){
		var checkValue=navigator.cookieEnabled;
		if(!checkValue){
			CD_setCookie("test","true",1);checkValue=CD_getCookie("test");
		}
		return checkValue;
	},

	createRandomValue:function(maxFigure){
		var code='';
		var num=0;
		var codeStr=new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9");
		for(var i=0;i<maxFigure;i++){
			num=Math.floor(Math.random()*codeStr.length);
			code+=codeStr[num];
		}
		return code;
	},

	createInputField:function(typeVal,Value,nameVal,idVal,classVal,sizeVal){
		var inputObj=document.createElement("input");
		inputObj.setAttribute("type",typeVal);
		inputObj.setAttribute("value",Value);
		if(nameVal)inputObj.setAttribute("name",nameVal);
		if(idVal)inputObj.setAttribute("id",idVal);
		if(sizeVal)inputObj.setAttribute("size",sizeVal);
		if(classVal)inputObj.className=classVal;
		return inputObj;
	},

	createAreaField:function(Value,nameVal,idVal,classVal,colVal,rowVal){
		var inputObj=document.createElement("textarea");
		if(nameVal)inputObj.setAttribute("name",nameVal);
		if(idVal)inputObj.setAttribute("id",idVal);
		if(classVal)inputObj.className=classVal;
		if(!colVal)colVal=20;
		if(!rowVal)rowVal=3;
		inputObj.setAttribute("cols",colVal);
		inputObj.setAttribute("rows",rowVal);
		if(Value){
			var val=document.createTextNode(Value);
			inputObj.appendChild(val);
		}
		return inputObj;
	},

	createButtonField:function(typeVal,Value,idVal,classVal,styleVal){
		var buttonObj=document.createElement("button");
		if(typeVal)buttonObj.setAttribute("type",typeVal);
		if(idVal)buttonObj.setAttribute("id",idVal);
		if(styleVal)buttonObj.setAttribute("style",styleVal);
		if(classVal)buttonObj.className=classVal;
		if(Value){
			if(Value.match(/\.jpg$|\.gif$|\.gif$/gi)){
				buttonObj.label=document.createElement("img");
				buttonObj.label.setAttribute("src",Value);
			}else{
				buttonObj.label=document.createTextNode(Value);
			}
			buttonObj.appendChild(buttonObj.label);
		}
		return buttonObj;
	},

	createAnchorLink:function(Value,idVal,classVal,styleVal){
		var buttonObj=document.createElement("a");
		buttonObj.label=document.createTextNode(Value);
		if(idVal)buttonObj.setAttribute("id",idVal);
		if(styleVal)buttonObj.setAttribute("style",styleVal);
		if(classVal)buttonObj.className=classVal;
		if(Value.match(/\.jpg$|\.gif$|\.gif$/gi)){
			buttonObj.label=document.createElement("img");
			buttonObj.label.setAttribute("src",Value);
		}else{
			buttonObj.label=document.createTextNode(Value);
		}
		buttonObj.appendChild(buttonObj.label);
		return buttonObj;
	},

	createInlineSpace:function(classVal,styleVal){
		var spaceObj=document.createElement("span");
		spaceObj.setAttribute("style","font-size:0;line-height:0;display:inline-block;"+styleVal);
		if(classVal)spaceObj.className=classVal;
		spaceObj.Label=document.createTextNode(" ");
		spaceObj.appendChild(spaceObj.Label);
		return spaceObj;
	},

	imageRadioFieldAct:function(fieldID,List,Value,obj){
		var radios=(List)?List.split(","):new Array();
		if($(fieldID)){
			//init radio
			if(radios.length>0){
				for(var i=0;i<radios.length;i++){
					if($(fieldID+radios[i])){
						if($(fieldID+radios[i]).firstChild.style.left==obj.offsetWidth*-1+"px"){
							$(fieldID+radios[i]).firstChild.style.left="0px";
						}
					}
				}
			}
			var radioImage=obj.firstChild;
			if($(fieldID).value != Value){
				$(fieldID).value = Value;
				if(!radioImage.style.position || radioImage.style.position != 'absolute')radioImage.style.position="absolute";
				radioImage.style.left=obj.offsetWidth*-1+"px";
			}else{
				$(fieldID).value = '';
				radioImage.style.left="0px";
			}
		}
	},

	/*DOM CONTROL*/
	findParentNode:function(tagName,obj) {
		while(obj.tagName!="HTML") {
	  		if (obj.tagName==tagName){
	  			return obj;
	  		} 
	  		obj=obj.parentNode;
	 	}
	 	return null;
	},

	findParentElement:function(obj,ntype,val){
		if(typeof(obj)=="string")obj=$(obj);
		var target='';
		while (obj.tagName != "HTML" && obj.parentNode) {
			if(obj.parentNode.nodeType==ntype){
				if(ntype==1 && obj.parentNode.tagName==val){
					target=obj.parentNode;
					return target;
				}else if(ntype==3 && obj.parentNode.nodeValue==val){
					target=obj.parentNode;
					return target;
				}
			}else{
				if(obj.type=="radio" || obj.type=="checkbox"){
					obj=obj.parentNode.parentNode;
				}else{
					obj=obj.parentNode;
				}
			}
		}
		return target;
	},

/*
	findChildElement:function(obj,ntype,val,innerval){
		if(typeof(obj)=="string")obj=$(obj);
		var target='';
		for(var i=0;i<obj.childNodes.length;i++){
			var child=obj.childNodes[i];
			if(child.nodeType==ntype){
				if(ntype==1 && child.tagName==val){
					if(innerval){
						for(var c=0;c<child.childNodes.length;c++){
							if(child.childNodes[c].nodeValue==innerval)target=child;
						}
					}else{
						target=child;
					}
				}
				else if(ntype==3 && child.nodeValue==val){
					target=child;
				}
			}
		}
		return target;
	},
*/
	findSiblingElement:function(obj,ntype,val,innerval){
		if(typeof(obj)=="string")obj=$(obj);
		var target='';
		for(var i=0;i<obj.parentNode.childNodes.length;i++){
			var sibling=obj.parentNode.childNodes[i];
			if(sibling.nodeType==ntype){
				if(ntype==1 && sibling.tagName==val){
					if(innerval){
						for(var c=0;c<sibling.childNodes.length;c++){
							if(sibling.childNodes[c].nodeValue==innerval)target=sibling;
						}
					}else{
						target=sibling;
					}
				}
				else if(ntype==3 && sibling.nodeValue==val){
					target=sibling;
				}
			}
		}
		return target;
	},

	findPrevSibling:function(obj,ntype,val){
		if(typeof(obj)=="string")obj=$(obj);
		var target='';
		var objIndex=0;
		for(var i=0;i<obj.parentNode.childNodes.length;i++){
			if(obj==obj.parentNode.childNodes[i]){
				objIndex=i;break;
			}
		}
		for(var i=objIndex;i>=0;i--){
			var sibling=obj.parentNode.childNodes[i];
			if(sibling.nodeType==ntype){
				if(ntype==1 && sibling.tagName==val){
					target=sibling;
				}else if(ntype==3 && sibling.nodeValue==val){
					target=sibling;
				}
				if(target)break;
			}
		}
		return target;
	},

	findNextSibling:function(obj,ntype,val){
		if(typeof(obj)=="string")obj=$(obj);
		var target='';
		var objIndex=0;
		for(var i=0;i<obj.parentNode.childNodes.length;i++){
			if(obj==obj.parentNode.childNodes[i]){
				objIndex=i;break;
			}
		}
		for(var i=objIndex+1;i<obj.parentNode.childNodes.length;i++){
			var sibling=obj.parentNode.childNodes[i];
			if(sibling.nodeType==ntype){
				if(ntype==1 && sibling.tagName==val){
					target=sibling;
				}else if(ntype==3 && sibling.nodeValue==val){
					target=sibling;
				}
				if(target)break;
			}
		}
		return target;
	},

	replaceChildValue:function(obj,val,mod){
		for(var i=0;i<obj.childNodes.length;i++){
			if(obj.childNodes[i].nodeValue==val){
				obj.childNodes.nodeValue=mod;
			}
		}
	},

	//hash controll
	getHashIndexNumber:function(arrays,val){
		var count=0;
		for(var i in arrays){
			if(arrays[i]==val)return count;
			count++;
		}
		return;
	},

	getHashFromIndexNum:function(arrays,indexNum){
		var count=0;
		for(var i in arrays){	
			if(count==indexNum)return arrays[i];
			count++;
		}
		return;
	},

	//for ie6 
	getAnchorObject:function(obj){
		if(obj.nodeName.toUpperCase()!="A"){
			obj=this.findParentElement(obj,1,'A');
		}
		return obj;
	}
}

/*USER AGENT*/
var CD_userAgent={
	Get:function(){
		var NavBrowser=navigator.appName;
		var Agent=navigator.userAgent;
		var AgentVer=navigator.appVersion;
		var NN="Netscape";

		this.navigator="["+Agent+" :: "+AgentVer+" :: "+NavBrowser+"]";

		if(Agent.indexOf("Mac", 0) >=0){
			this.os="Mac";
			for(i=0;i<navigator.plugins.length;i++){
				if(navigator.plugins[i].filename.indexOf(".plugin") >=0){
					this.osVer="X";
				}
			}
		}
		else if(Agent.indexOf("Win", 0) >=0){
			this.os="Windows";
			if(Agent.indexOf("NT 7.0",0) >=0){
				this.osVer="Seven";
			}else if(Agent.indexOf("NT 6.0",0) >=0){
				this.osVer="Vista";
			}else if(Agent.indexOf("NT 5.2",0) >=0){
				this.osVer="2003";
			}else if(Agent.indexOf("NT 5.1",0) >=0){
				this.osVer="XP";
			}else if(Agent.indexOf("NT 5.0",0) >=0){
				this.osVer="2000";
			}
		}
		else{
			this.os=this.osVer=undefined;
		}

		// OPERA
		if(Agent.indexOf("Opera",0) >=0){
			this.app="Opera";
			this.asn="op";
			blength=this.app.length;
			ver_start=Agent.indexOf("Opera",0) + blength + 1;
			ver_end=Agent.length - ver_start;
			this.appVer=Agent.substr(ver_start,ver_end);
			this.appVer=this.appVer.substr(0,5);
		}
	
		// Firefox
		else if(Agent.indexOf("Firefox",0) >=0){
			this.app="Firefox";
			this.asn="ff";
			blength=this.app.length;
			ver_start=Agent.indexOf("Firefox",0) + blength +1;
			ver_end=Agent.length - ver_start;
			this.appVer=Agent.substr(ver_start,ver_end);
		}
	
		// InternetExplorer 
		else if(Agent.indexOf("MSIE 8", 0) >=0){
			this.app="InternetExplorer";	this.appVer="8";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 7", 0) >=0){
			this.app="InternetExplorer";	this.appVer="7";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 6", 0) >=0){
			this.app="InternetExplorer";	this.appVer="6";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 5.5", 0) >=0){
			this.app="InternetExplorer";	this.appVer="5.5";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 5.2", 0) >=0){
			this.app="InternetExplorer";	this.appVer="5.2";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 5.1", 0) >=0){
			this.app="InternetExplorer";	this.appVer="5.1";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 5", 0) >=0){
			this.app="InternetExplorer";	this.appVer="5";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 4.01", 0) >=0){
			this.app="InternetExplorer";	this.appVer="4.01";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 4.5", 0) >=0){
			this.app="InternetExplorer";	this.appVer="4.5";
			this.asn="ie";
		}
		else if(Agent.indexOf("MSIE 4", 0) >=0){
			this.app="InternetExplorer";
			this.asn="ie";
			this.appVer="4";
		}

		// Chrome
		else if(Agent.indexOf("Chrome", 0) >=0){
			this.app="Google Chrome";
			this.asn="gc";
			this.appVer=Agent.split("/")[3].split(" ")[0];
		}

		// Safari
		else if(Agent.indexOf("Safari", 0) >=0){
			this.app="Safari";
			this.asn="sf";
			var s=Agent.split("/")[4]
			var n=Agent.split("/")[3];
			var n2=n.split(" ")[0];

			if(n.indexOf("Safari")!=-1){
				this.appVer=n2+"("+s+")";
			}
			else if(n >=419.3){
				this.appVer="2.0.4("+n+")";
			}
			else if(n >=410){
				this.appVer="2.0("+n+")";
			}
			else if(n >=312.6){
				this.appVer="1.3.2("+n+")";
			}
			else if(n >=130){
				this.appVer="1.3("+n+")";
			}
			else if(n >=125.12){
				this.appVer="1.2.4("+n+")";
			}
			else if(n>120){
				this.appVer="1.2("+n+")";
			}
			else if(n>100){
				this.appVer="1.1("+n+")";
			}
			else if(n>86){
				this.appVer="1.0("+n+")";
			}
			else{
				this.appVer="unknown";
			}
		}

		// Netscape 6,7
		else if(NN=="Netscape" && Agent.indexOf("Netscape",0) >=0){
			this.app="Netscape";
			this.asn="nn";
			blength=this.app.length;
			ver_start=Agent.indexOf("Netscape",0) + blength +1;
			ver_end=Agent.length - ver_start;
			this.appVer=Agent.substr(ver_start,ver_end);
		}

		// Netscape 4.x
		else if(NN=="Netscape" && Agent.indexOf("4.",0) >=0){
			this.app="Netscape";
			this.asn="nn";
			this.appVer="4";
		}

		// Mozilla
		else if(this.NavBrowser=="Netscape" && Agent.indexOf("Mozilla",0) >=0 && Agent.indexOf("Gecko",0) >=0){
			this.app="Mozilla";
			this.asn="mz";
			ver_start=Agent.indexOf("rv:",0) + 3;
			this.appVer=Agent.substr(ver_start,5);
		}

		else{
			this.app=this.appVer=undefined;
			this.asn="undef";
		}

		//appVer=appVer.replace("/","");
	},

	Show:function(obj,useN){
		var ua=new this.Get();
		var viewSrc='<dl>';

		viewSrc+='<dt>OS</dt><dd>'+ua.os+'</dd>';
		viewSrc+='<dt>OS version</dt><dd>'+ua.osVer+'</dd>';
		viewSrc+='<dt>Browser</dt><dd>'+ua.app+'</dd>';
		viewSrc+='<dt>Browser Version</dt><dd>'+ua.appVer+'</dd>';

		if(useN){
			viewSrc+='<dt>Navigator Property</dt><dd>'+ua.navigator+'</dd>';
		}
		viewSrc+='</dl>';

		$(obj).innerHTML=viewSrc;
	}
}

/*FUNCTIONS*/
function $(id){
	return document.getElementById(id);
}

/*----------------------------------*/
function $$(Name){
	return document.getElementsByName(Name);
}

/*----------------------------------*/
function WO$(id){
	return window.opener.document.getElementById(id);
}

/*----------------------------------*/
function insertAfter(newElem,targetObj){
	var parent=targetObj.parentNode;
	if(parent.lastChild==targetObj){
		parent.appendChild(newElem);
	}else{
		parent.insertBefore(newElem,targetObj.nextSibling);
	}
}

/*----------------------------------*/
function changeClass(targetObj,changeClass){
	targetObj.className=changeClass;
}

/*----------------------------------*/
function CD_resizeWindow(expWidth,expHeight,imgWidth,imgHeight){
	window.self.resizeTo(expWidth,expHeight);
}

/*----------------------------------*/
function CD_opWindow(U,T,W,H,S,R){
	if(U!=""){
		var O="width="+W+",height="+H+",scrollbars="+S+",menubar=no,toolbar=no,status=yes,resizable="+R+",location=no,directories=no";
		var popUp=window.open(U,T,O);
	}
}

/*----------------------------------*/
function CD_clWindow(){
	window.self.close();
}

/*----------------------------------*/
function CD_backPage(){
	history.back();
}

/*----------------------------------*/
/*DEBUG*/
function trace(str){
	if(CD.debugMode){
		if(!$("CD_trace")){
			CD_core.createObject("div","CD_trace","CD_trace",'',0);
			$("CD_trace").innerHTML=str;
			$("CD_trace").style.position="absolute";
			$("CD_trace").style.top="0px";
			$("CD_trace").style.left="0px";
		}else{
			$("CD_trace").innerHTML=str+"<br />"+$("CD_trace").innerHTML;
		}
		$("CD_trace").style.visibility="visible";
		CD_core.swapDepths("CD_trace",'nextHighestDepth');
	}
}


/**
 * Emulates insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement()
 * three functions so they work with Netscape 6/Mozilla
 * by Thor Larholm me@jscript.dk
 */
if(typeof HTMLElement!='undefined'){
	if(typeof HTMLElement.insertAdjacentHTML=='undefined'){
		HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
	  	switch (where){
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode,this);
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling) { 
					this.parentNode.insertBefore(parsedNode,this.nextSibling); 
				}else{ 
					this.parentNode.appendChild(parsedNode); 
				}
			break;
		  }
		};
	}
	if (CD.UA.asn!="ie"){
		if(typeof HTMLElement.insertAdjacentHTML=='undefined'){
			HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr) {
				var r = this.ownerDocument.createRange();
				r.setStartBefore(this);
				var parsedHTML = r.createContextualFragment(htmlStr);
				this.insertAdjacentElement(where,parsedHTML);
			};
		}
	   if(typeof HTMLElement.insertAdjacentText=='undefined'){
			HTMLElement.prototype.insertAdjacentText = function (where,txtStr) {
				var parsedText = document.createTextNode(txtStr);
				this.insertAdjacentElement(where,parsedText);
			};
		}
	}
}

/*_____POPUP_window______*/
var CD_popup={

	/*___option param___*/
	/*
	"
	width=XX,
	height=xx,
	scrollbars=yes|no|auto,
	menubar=yes|no,
	toolbar=yes|no,
	status=yes|no,
	resizable=yes|no,
	location=yes|no,
	directories=yes|no
	"
	*/

	Open:function(Url,Target,Options){
		window.open(Url,Target,Options);
		return false;
		window[Target].focus();
	},

	Close:function(Target){
		window[Target].close();
	}

}

/*
move(x:y)
size(x:y)
scale(x:y:abs)
alpha(0-100)
color(r:g:b)
*/

var CD_tween={

	mdm:1,

	Config:new Array(),
	Tweens:new Array(),
	fps:33,
	dpf:5,

	Set:function(obj,options){
		this.endPos=new Array();
		this.vector=new Array();
		this.option=new Array();
		if(options){
			var optVals=options.split(";");
			for(i=0;i<optVals.length;i++){
				this.option[optVals[i].split(":")[0]]=optVals[i].split(":")[1];
			}
		}
		this.endCount=0;
	},

	Add:function(obj,Move,Scale,Alpha,Color,Speed,Options){
		this.Config[obj]=new this.Set(obj,Options);

		var pos=new CD_core.getPosition($(obj),0,0,0,0,0);

		//Move
		if(Move != "null"){
//			if($(obj).style.position != "absolute")$(obj).style.position= "absolute";

			if($(obj).parentNode.nodeName.toUpperCase() != "BODY" && !$(obj).parentNode.style.position){
				$(obj).parentNode.style.position="relative";
			}
			if(!$(obj).style.position || $(obj).style.position=="static"){
				$(obj).style.position="relative";
				pos._x=0;pos._y=0;
			}

			this.Config[obj].endPos['moveX']=Move.split(":")[0];
			if(this.Config[obj].endPos['moveX'] != '' && this.Config[obj].endPos['moveX'] != undefined){
				this.Config[obj].vector['moveX']=((this.Config[obj].endPos['moveX']-pos._x)>0)?"p":"m";
				$(obj).style.left=pos._x+"px";
				this.Config[obj].endCount++;
			}else{
				this.Config[obj].endPos['moveX']='null';
			}
			this.Config[obj].endPos['moveY']=Move.split(":")[1];
			if(this.Config[obj].endPos['moveY'] != '' && this.Config[obj].endPos['moveY'] != undefined){
				this.Config[obj].vector['moveY']=((this.Config[obj].endPos['moveY']-pos._y)>0)?"p":"m";
				$(obj).style.top=pos._y+"px";
				this.Config[obj].endCount++;
			}else{
				this.Config[obj].endPos['moveY']='null';
			}
		}else{
			this.Config[obj].endPos['moveX']='null';
			this.Config[obj].endPos['moveY']='null';
		}

		//Scale
		if(Scale != "null"){
			this.Config[obj].endPos['scaleX']=Scale.split(":")[0];
			this.Config[obj].endPos['scaleY']=Scale.split(":")[1];
			this.Config[obj].endPos['scaleType']=Scale.split(":")[2];
			this.Config[obj].endPos['scaleBase']=Scale.split(":")[3];
			if(this.Config[obj].endPos['scaleType']==undefined || this.Config[obj].endPos['scaleType']==0){
				if(this.Config[obj].endPos['scaleX'] != '' && this.Config[obj].endPos['scaleX'] != undefined){
					this.Config[obj].vector['scaleX']=(this.Config[obj].endPos['scaleX']>1)?"p":"m";
					this.Config[obj].endPos['scaleX']=Math.floor(this.Config[obj].endPos['scaleX']*pos._width);
					$(obj).style.width=pos._width+"px";
					this.Config[obj].endCount++;
				}else{
					this.Config[obj].endPos['scaleX']='null';
				}
				if(this.Config[obj].endPos['scaleY'] != '' && this.Config[obj].endPos['scaleY'] != undefined){
					this.Config[obj].vector['scaleY']=(this.Config[obj].endPos['scaleY']>1)?"p":"m";
					this.Config[obj].endPos['scaleY']=Math.floor(this.Config[obj].endPos['scaleY']*pos._height);
					$(obj).style.height=pos._height+"px";
					this.Config[obj].endCount++;
				}else{
					this.Config[obj].endPos['scaleY']='null';
				}
			}else{
				if(this.Config[obj].endPos['scaleX'] != '' && this.Config[obj].endPos['scaleX'] != undefined){
					if((this.Config[obj].endPos['scaleX']-pos._width)==0){
						this.Config[obj].endPos['scaleX']='null';
					}else{
						this.Config[obj].vector['scaleX']=((this.Config[obj].endPos['scaleX']-pos._width)>0)?"p":"m";
						$(obj).style.width=pos._width+"px";
						this.Config[obj].endCount++;
					}
				}else{
					this.Config[obj].endPos['scaleX']='null';
				}
				if(this.Config[obj].endPos['scaleY'] != '' && this.Config[obj].endPos['scaleY'] != undefined){
					if((this.Config[obj].endPos['scaleY']-pos._height)==0){
						this.Config[obj].endPos['scaleY']='null';
					}else{
						this.Config[obj].vector['scaleY']=((this.Config[obj].endPos['scaleY']-pos._height)>0)?"p":"m";
						$(obj).style.height=pos._height+"px";
						this.Config[obj].endCount++;
					}
				}else{
					this.Config[obj].endPos['scaleY']='null';
				}
			}
			if(this.Config[obj].endPos['scaleBase'] && this.Config[obj].endPos['scaleX']!='null' && this.Config[obj].endPos['scaleY']!='null'){
//				if($(obj).style.position != "absolute")$(obj).style.position= "absolute";
				if($(obj).parentNode.nodeName.toUpperCase() != "BODY" && !$(obj).parentNode.style.position){
					$(obj).parentNode.style.position="relative";
				}
				if(!$(obj).style.position || $(obj).style.position=="static"){
					$(obj).style.position="relative";
					pos._x=0;pos._y=0;
				}

				$(obj).style.left=pos._x+"px";
				$(obj).style.top=pos._y+"px";
				this.Config[obj].endPos['scaleMathX']=0;
				this.Config[obj].endPos['scaleMathY']=0;
			}
		}else{
			this.Config[obj].endPos['scaleX']='null';
			this.Config[obj].endPos['scaleY']='null';
		}

		//alpha
		if(Alpha != "null" && Alpha<=1){
			pos._alpha=CD_core.getAlpha(obj);
			this.Config[obj].endPos['alpha']=Alpha;
			if(this.Config[obj].endPos['alpha'] != null && this.Config[obj].endPos['alpha'] != undefined){
				if(this.Config[obj].endPos['alpha']*100==pos._alpha){
					this.Config[obj].endPos['alpha']='null';
				}else{
					this.Config[obj].vector['alpha']=(this.Config[obj].endPos['alpha']*100>pos._alpha)?"p":"m";
					this.Config[obj].endPos['alpha']=Math.floor(this.Config[obj].endPos['alpha']*100);
					this.Config[obj].endCount++;
				}
			}else{
				this.Config[obj].endPos['alpha']='null';
			}
		}else{
			this.Config[obj].endPos['alpha']='null';
		}

		//color
		if(Color != "null"){
			var clr=CD_core.getColor(obj,"BG");
			pos._colorR=clr.R;
			pos._colorG=clr.G;
			pos._colorB=clr.B;
			if($(obj).style.backgroundColor == undefined)$(obj).style.backgroundColor="#ffffff";

			if(Color.indexOf("#")!=-1){			
				Color=Color.replace(/^#/,'');
				switch(Color.length){
					case 3:
						this.Config[obj].endPos['colorR']=parseInt(Color.substring(0,1),16);
						this.Config[obj].endPos['colorG']=parseInt(Color.substring(1,2),16);
						this.Config[obj].endPos['colorB']=parseInt(Color.substring(2,3),16);
					break;
					default:
						this.Config[obj].endPos['colorR']=parseInt(Color.substring(0,2),16);
						this.Config[obj].endPos['colorG']=parseInt(Color.substring(2,4),16);
						this.Config[obj].endPos['colorB']=parseInt(Color.substring(4,6),16);
				}
			}else{
				this.Config[obj].endPos['colorR']=Color.split(":")[0];
				this.Config[obj].endPos['colorG']=Color.split(":")[1];
				this.Config[obj].endPos['colorB']=Color.split(":")[2];
			}

			if(this.Config[obj].endPos['colorR'] != null && this.Config[obj].endPos['colorR'] != "undefined"){
				this.Config[obj].vector['colorR']=((this.Config[obj].endPos['colorR']-pos._colorR)>0)?"p":"m";
			}
			if(this.Config[obj].endPos['colorG'] != null && this.Config[obj].endPos['colorG'] != "undefined"){
				this.Config[obj].vector['colorG']=((this.Config[obj].endPos['colorG']-pos._colorG)>0)?"p":"m";
			}
			if(this.Config[obj].endPos['colorG'] != null && this.Config[obj].endPos['colorB'] != "undefined"){
				this.Config[obj].vector['colorB']=((this.Config[obj].endPos['colorB']-pos._colorB)>0)?"p":"m";
			}
			this.Config[obj].endCount++;
		}else{
			this.Config[obj].endPos['color']='null';
		}

		if(this.Config[obj].option['start'])eval(this.Config[obj].option['start']);
		this.Tweens[obj]=setInterval("CD_tween.Act('"+obj+"',"+Speed+")",this.fps);
	},

	Act:function(obj,Speed){
		var actCount=0;
		//move
		if(this.Config[obj].endPos['moveX']!="null"){
			var moveX=this.Value(obj,$(obj).style.left.replace(/px/gi,''),this.Config[obj].endPos['moveX'],this.Config[obj].vector['moveX'],Speed);
			if(moveX != "*"){
				$(obj).style.left=moveX+"px";
			}else{
				actCount++;
			}
		}
		if(this.Config[obj].endPos['moveY']!="null"){
			var moveY=this.Value(obj,$(obj).style.top.replace(/px/gi,''),this.Config[obj].endPos['moveY'],this.Config[obj].vector['moveY'],Speed);
			if(moveY != "*"){
				$(obj).style.top=moveY+"px";
			}else{
				actCount++;
			}
		}

		//scale
		if(this.Config[obj].endPos['scaleX']!="null"){
			var nw=$(obj).style.width.replace(/px/gi,'');
			var scaleX=this.Value(obj,nw,this.Config[obj].endPos['scaleX'],this.Config[obj].vector['scaleX'],Speed);
			if(scaleX != "*"){
				switch(this.Config[obj].endPos['scaleBase']){
					case "RB":
						$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+parseInt(nw-scaleX))+"px";
					break;
					case "RT":
						$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+parseInt(nw-scaleX))+"px";
					break;
					case "RM":
						$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+parseInt(nw-scaleX))+"px";
					break;
					case "CB":
						if(this.Config[obj].endPos['scaleMathX']==0){
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.floor(parseInt(nw-scaleX)/2))+"px";
							if(parseInt(nw-scaleX)%2==1)this.Config[obj].endPos['scaleMathX']=1;
						}else{
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.ceil(parseInt(nw-scaleX)/2))+"px";
							this.Config[obj].endPos['scaleMathX']=0;
						}
					break;
					case "CT":
						if(this.Config[obj].endPos['scaleMathX']==0){
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.floor(parseInt(nw-scaleX)/2))+"px";
							if(parseInt(nw-scaleX)%2==1)this.Config[obj].endPos['scaleMathX']=1;
						}else{
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.ceil(parseInt(nw-scaleX)/2))+"px";
							this.Config[obj].endPos['scaleMathX']=0;
						}
					break;
					case "CM":
						if(this.Config[obj].endPos['scaleMathX']==0){
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.floor(parseInt(nw-scaleX)/2))+"px";
							if(parseInt(nw-scaleX)%2==1)this.Config[obj].endPos['scaleMathX']=1;
						}else{
							$(obj).style.left=(parseInt($(obj).style.left.replace(/px/g,''))+Math.ceil(parseInt(nw-scaleX)/2))+"px";
							this.Config[obj].endPos['scaleMathX']=0;
						}
					break;
				}
				$(obj).style.width=scaleX+"px";
			}else{
				actCount++;
			}
		}
		if(this.Config[obj].endPos['scaleY']!="null"){
			var nh=$(obj).style.height.replace(/px/gi,'');
			var scaleY=this.Value(obj,nh,this.Config[obj].endPos['scaleY'],this.Config[obj].vector['scaleY'],Speed);
			if(scaleY != "*"){
				switch(this.Config[obj].endPos['scaleBase']){
					case "RB":
						$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+parseInt(nh-scaleY))+"px";
					break;
					case "LB":
						$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+parseInt(nh-scaleY))+"px";
					break;
					case "CB":
						$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+parseInt(nh-scaleY))+"px";
					break;
					case "CM":
						if(this.Config[obj].endPos['scaleMathY']==0){
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.floor(parseInt(nh-scaleY)/2))+"px";
							if(parseInt(nh-scaleY)%2==1)this.Config[obj].endPos['scaleMathY']=1;
						}else{
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.ceil(parseInt(nh-scaleY)/2))+"px";
							this.Config[obj].endPos['scaleMathY']=0;
						}
					break;
					case "LM":
						if(this.Config[obj].endPos['scaleMathY']==0){
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.floor(parseInt(nh-scaleY)/2))+"px";
							if(parseInt(nh-scaleY)%2==1)this.Config[obj].endPos['scaleMathY']=1;
						}else{
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.ceil(parseInt(nh-scaleY)/2))+"px";
							this.Config[obj].endPos['scaleMathY']=0;
						}
					break;
					case "RM":
						if(this.Config[obj].endPos['scaleMathY']==0){
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.floor(parseInt(nh-scaleY)/2))+"px";
							if(parseInt(nh-scaleY)%2==1)this.Config[obj].endPos['scaleMathY']=1;
						}else{
							$(obj).style.top=(parseInt($(obj).style.top.replace(/px/g,''))+Math.ceil(parseInt(nh-scaleY)/2))+"px";
							this.Config[obj].endPos['scaleMathY']=0;
						}
					break;
				}
				$(obj).style.height=scaleY+"px";
			}else{
				actCount++;
			}
		}
		//alpha
		if(this.Config[obj].endPos['alpha']!="null"){
			var alpha=this.Value(obj,CD_core.getAlpha(obj),this.Config[obj].endPos['alpha'],this.Config[obj].vector['alpha'],Speed);
			if(alpha != "*"){
				CD_core.setAlpha(obj,alpha);
			}else{
				actCount++;
			}
		}
		//color
		if(this.Config[obj].endPos['color']!="null"){
			var color=CD_core.getColor(obj,"BG");
			var R=this.Value(obj,color.R,this.Config[obj].endPos['colorR'],this.Config[obj].vector['colorR'],Speed);
			var G=this.Value(obj,color.G,this.Config[obj].endPos['colorG'],this.Config[obj].vector['colorG'],Speed);
			var B=this.Value(obj,color.B,this.Config[obj].endPos['colorB'],this.Config[obj].vector['colorB'],Speed);
			if(R=="*" && G=="*" && B=="*")actCount++;

			if(R=="*")R=color.R;
			if(G=="*")G=color.G;
			if(B=="*")B=color.B;
			CD_core.setColor(obj,R,G,B,"BG");
		}

		if(actCount==this.Config[obj].endCount){
			if(this.Config[obj].option['enterframe'])eval(this.Config[obj].option['enterframe']);
			if(this.Config[obj].option['complete'])eval(this.Config[obj].option['complete']);
			this.Del(obj);
		}else{
			if(this.Config[obj].option['enterframe'])eval(this.Config[obj].option['enterframe']);
		}
	},

	Del:function(obj){
		clearInterval(this.Tweens[obj]);
		this.Config[obj]='';
	},

	Value:function(obj,nowVal,endVal,vect,Speed){
		nowVal=parseInt(nowVal);
		endVal=parseInt(endVal);
		var md=0;

		switch(vect){
			case "p":
				if(nowVal != endVal){
					md=Math.floor((endVal-nowVal)/Speed);
					md=(md<this.mdm)?this.mdm:md;
					if(nowVal>endVal-this.mdm){
						return endVal;
					}else{
						return (nowVal+md);
					}
				}else{
					return "*";
				}
			break;
			case "m":
				if(nowVal != endVal){
					md=Math.floor((nowVal-endVal)/Speed);
					md=(md<this.mdm)?this.mdm:md;
					if(nowVal<endVal+this.mdm){
						return endVal;
					}else{
						return (nowVal-md);
					}
				}else{
					return "*";
				}
			break;
		}
	}
}


/*______________EXECUTE______________*/
CD.Load();
