/*
----------------------------------------------------------------
	CreativeDevece JavaScript Library
	core scripts
----------------------------------------------------------------
	version			1.00
	last update		2010/04/09
	author			Yoshihisa Kato/YAH!-cyberstudio
----------------------------------------------------------------
	This script is prohibited to use outside mu-MU WEB SITE
	http://www.mu-mu.info/
--------------------------------------------------------------------------
*/

var CD={
	Version:"1.00",
	
	Libs:new Array(
		"settings",
		"utilities",
		"functions",
		"editor"
	),

	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={

	/*Create object*/
	createObject:function(Tag,ids,classs,Targets,disableAppend){
		var obj=document.createElement(Tag);
		if(ids)this.setAttribute(obj,"id",ids);
		if(disableAppend==0 || !disableAppend){
			if(!Targets){
				document.body.appendChild(obj);
			}else{
				Targets.appendChild(obj);
			}
		}
		if(classs)CD_core.setAttribute(obj,"class",classs);
		return obj;
	},

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

	/*Create dummy object for using layout spacing*/
	createInlineSpace:function(classVal,styleVal){
		var spaceObj=document.createElement("span");
		this.setAttribute(spaceObj,"style","font-size:0;line-height:0;display:inline-block;"+styleVal);
		if(classVal)CD_core.setAttribute(spaceObj,'class',classVal);
		spaceObj.Label=document.createTextNode(" ");
		spaceObj.appendChild(spaceObj.Label);
		return spaceObj;
	},

	/* Get object position */
	getPosition:function(obj,adjustX,adjustY,adjustW,adjustH,setPosition){
		var holdObj=obj;
		this._name=(CD_core.getAttribute(obj,'id'))?CD_core.getAttribute(obj,'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=CD_core.getAttribute(obj,"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) {
				var current_Style=(obj.currentStyle[IEStyleProp])?obj.currentStyle[IEStyleProp]:obj.currentStyle[Prop];
				current_Style=current_Style.replace(/px/,'');
				return current_Style;
			} 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=CD_core.getAttribute(obj,"id");
		var classValue=undefined;
		var cssFile=document.styleSheets;
		if(cssFile){
			var rules=null;
			for(var i=0;i<cssFile.length;i++){
				if(cssFile[i].href && cssFile[i].href.indexOf(location.hostname)!=-1){
					rules=(CD.UA.asn!="ie")?cssFile[i].cssRules:cssFile[i].rules;
				}else{
					rules=null;
				}
				if(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.setFixedPosition($(obj),'center',this._scrollY()+(this._windowHeight()-parseInt(this.getStyle($(obj),"Height","height","height")))/2);
/*
		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._documentWidth()-parseInt(this.getStyle(obj,"Width","width","width")))/2;
			break;
			case "right":
				x=this._documentWidth()-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_core.getAttribute(obj,'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;
			}
		}
		this.setAttribute(obj,"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){
		if(typeof(obj)=="string")obj=$(obj);
		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(typeof(obj)=="string")obj=$(obj);
		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){
			//switch event on iOS
			if(CD.UA.os=="iOS"){
				switch(ev.toLowerCase()){
					case "mousedown":
						ev="touchstart";
					break;
					case "mouseup":
						ev="touchend";
					break;

					case "mousemove":
						ev="touchmove";
					break;
/*
					case "click":
						ev="touch";
					break;
*/
				}
			}
			//add event function
			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;	
	},

/*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;
	},



/*form control*/
	//create field object
	createInputField:function(typeVal,Value,nameVal,idVal,classVal,sizeVal){
		var inputObj=document.createElement("input");
		this.setAttribute(inputObj,"type",typeVal);
		this.setAttribute(inputObj,"value",Value);
		if(nameVal)this.setAttribute(inputObj,"name",nameVal);
		if(idVal)this.setAttribute(inputObj,"id",idVal);
		if(sizeVal)this.setAttribute(inputObj,"size",sizeVal);
		if(classVal)this.setAttribute(inputObj,'class',classVal);
		return inputObj;
	},

	createAreaField:function(Value,nameVal,idVal,classVal,colVal,rowVal){
		var inputObj=document.createElement("textarea");
		if(nameVal)this.setAttribute(inputObj,"name",nameVal);
		if(idVal)this.setAttribute(inputObj,"id",idVal);
		if(classVal)CD_core.setAttribute(inputObj,'class',classVal);
		if(!colVal)colVal=20;
		if(!rowVal)rowVal=3;
		this.setAttribute(inputObj,"cols",colVal);
		this.setAttribute(inputObj,"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)this.setAttribute(buttonObj,"type",typeVal);
		if(idVal)this.setAttribute(buttonObj,"id",idVal);
		if(styleVal)this.setAttribute(buttonObj,"style",styleVal);
		if(classVal)this.setAttribute(buttonObj,'class',classVal);
		if(Value){
			if(Value.match(/\.jpg$|\.gif$|\.gif$/gi)){
				buttonObj.label=document.createElement("img");
				this.setAttribute(buttonObj.label,"src",Value);
			}else{
				buttonObj.label=document.createTextNode(Value);
			}
			buttonObj.appendChild(buttonObj.label);
		}
		return buttonObj;
	},

	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";
			}
		}
	},

	/*clear input field if field value equal default value*/
	inputFieldClear:function(obj){
		if(typeof(obj)=="string")obj=$(obj);
		var val=obj.value;
		obj.value=(val==obj.defaultValue)?"":val;
	},

	/*translate form action to linkPath*/
	formSerialize:function(formID){
		var F=document.forms[formID];
		var sendValue=CD_core.getAttribute(F,'action');
		for(var i=0;i<F.elements.length;i++){
			sendValue+=(i==0)?'?':'&amp;';
			sendValue+=F.elements[i].name+"="+encodeURIComponent(F.elements[i].value);
		}
		return sendValue;
	},

	/*get select field selected value*/
	getSelectedIndexValue:function(obj,formID){
		var F=(!formID)?this.findParentElement(obj,1,"FORM"):document.forms[formID];
		return F.elements[obj].options[F.elements[obj].selectedIndex].value;
	},

	/*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.parentNode) {
			if(obj.parentNode.nodeType==ntype){
				if(ntype==1 && obj.parentNode.nodeName.toUpperCase()==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;
					}
				}
			}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;
			}
		}
	},

	//attributes
	setAttribute:function(obj,attr,val){
		if(typeof(obj)=="string")obj=$(obj);
		switch(attr.toLowerCase()){
			case "style":
				if(CD.UA.asn=="ie"){
					obj.style.cssText=val;
				}else{
					obj.setAttribute("style",val);
				}
			break;
			case "class":
				if(CD.UA.asn=="ie"){
					obj.className=val;
				}else{
					obj.setAttribute("class",val);
				}
			break;
			default:
				obj.setAttribute(attr.toLowerCase(),val);
		}
	},

	getAttribute:function(obj,attr){
		var val=null;
		if(typeof(obj)=="string")obj=$(obj);
		switch(attr.toLowerCase()){
			case "style":
				if(CD.UA.asn=="ie"){
					val=obj.style.cssText;
				}else{
					val=obj.getAttribute("style");
				}
			break;
			case "class":
				if(CD.UA.asn=="ie"){
					val=obj.className;
				}else{
					val=obj.getAttribute("class");
				}
			break;
			case "href":
				val=obj.getAttribute("href",2);
			break;
			default:
				val=obj.getAttribute(attr.toLowerCase());
		}
		return val;
	},


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

	//clip strings
	clipString:function(txt,top,end){
		return txt.substring(top,end);
	},

	//create random value
	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;
	},

	//create & remove window shade
	createShadeScreen:function(shadeID,shadeClass,tweenSetting){
		/*ie 6 reject select object*/
		for(i=0;i<document.getElementsByTagName("select").length;i++){
			document.getElementsByTagName("select")[i].style.visibility="none";
		}
		var shade=CD_core.createObject("div",shadeID,shadeClass,'',0);
		if(tweenSetting){
			var tP=tweenSetting.split(/,/);
			//Move,Scale,Alpha,Color,Speed,Motion,Options
			for(var i=0;i<tP.length-1;i++){
				if(!tP[i])tP[i]="null";
			}
			if(tP[1] != "null"){
				CD_core.setPosition(shade,"width",0);
				CD_core.setPosition(shade,"height",0);
				tP[1]=CD_core._documentWidth()+":"+CD_core._documentHeight()+":1:"+tP[1];
			}else{
				CD_core.setPosition(shade,"width",CD_core._documentWidth());
				CD_core.setPosition(shade,"height",CD_core._documentHeight());
			}
			if(tP[2] != "null")CD_core.setAlpha(shade,0);
			CD_core.swapDepths(shade,"nextHighestDepth");
			CD_tween.Add(shadeID,tP[0],tP[1],tP[2],tP[3],tP[4],tP[5],tP[6]);
		}else{
			CD_core.setPosition(shade,"width",CD_core._documentWidth());
			CD_core.setPosition(shade,"height",CD_core._documentHeight());
			CD_core.swapDepths(shade,"nextHighestDepth");
		}
	},

	removeShadeScreen:function(shadeID,tweenSetting){
		/*ie 6 reject select object*/
		for(i=0;i<document.getElementsByTagName("select").length;i++){
			document.getElementsByTagName("select")[i].style.visibility="inline";
		}
		document.body.removeChild($(shadeID));
	},

	//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 9", 0) >=0){
			this.app="InternetExplorer";	this.appVer="9";
			this.asn="ie";
		}
		// 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";
			}

			if(Agent.indexOf("(iPad")!=-1){
				this.os="iOS";
				this.appVer="iPad";				
			}
			if(Agent.indexOf("(iPhone")!=-1 || Agent.indexOf("(iPod")!=-1){
				this.os="iOS";
				this.appVer="iPhone";				
			}
		}

		// 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;
	}
}

/*_____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){
		if(!Target)Target="_self";
		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(),
	Timers:new Array(),
	fps:33,
	dpf:5,

	Set:function(obj,options){
		this.topPos=new Array();
		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;
	},

	Auto:function(obj,Move,Scale,Alpha,Color,Speed,Motion,Time,Options){
		this.Timers[obj]=setInterval('CD_tween.Add("'+obj+'","'+Move+'","'+Scale+'","'+Alpha+'","'+Color+'","'+Speed+'","'+Motion+'","'+Options+'")',(Time*1000));
	},

	Add:function(obj,Move,Scale,Alpha,Color,Speed,Motion,Options){
		if(this.Tweens[obj]){
			clearInterval(this.Tweens[obj]);
			this.Config[obj]='';
		}
		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).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;
			}

			//X
			this.Config[obj].endPos['moveX']=Move.split(":")[0];
			if(this.Config[obj].endPos['moveX']){
				if(this.Config[obj].endPos['moveX'].indexOf("--")!=-1){
					this.Config[obj].endPos['moveX']=this.Config[obj].endPos['moveX'].replace(/\-\-/,'');
					this.Config[obj].endPos['moveX']=pos._x-parseInt(this.Config[obj].endPos['moveX']);
					if(Math.abs(this.Config[obj].endPos['moveX'])>pos._width){
						this.Config[obj].endPos['moveX']=0;
					}
				}
				else if(this.Config[obj].endPos['moveX'].indexOf("++")!=-1){
					this.Config[obj].endPos['moveX']=this.Config[obj].endPos['moveX'].replace(/\+\+/,'');
					this.Config[obj].endPos['moveX']=pos._x+parseInt(this.Config[obj].endPos['moveX']);
				}
			}
//			if((this.Config[obj].endPos['moveX'] != '' && this.Config[obj].endPos['moveX'] != undefined) || this.Config[obj].endPos['moveX']==0){
			if(this.Config[obj].endPos['moveX'] != null && this.Config[obj].endPos['moveX'] != undefined && this.Config[obj].endPos['moveX'] != "null"){
				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';
			}

			//Y
			this.Config[obj].endPos['moveY']=Move.split(":")[1];
			if(this.Config[obj].endPos['moveY']){
				if(this.Config[obj].endPos['moveY'].indexOf("--")!=-1){
					this.Config[obj].endPos['moveY']=this.Config[obj].endPos['moveY'].replace(/\-\-/,'');
					this.Config[obj].endPos['moveY']=pos._y-parseInt(this.Config[obj].endPos['moveY']);
					if(Math.abs(this.Config[obj].endPos['moveY'])>pos._height){
						this.Config[obj].endPos['moveY']=0;
					}
				}
				else if(this.Config[obj].endPos['moveY'].indexOf("++")!=-1){
					this.Config[obj].endPos['moveY']=this.Config[obj].endPos['moveY'].replace(/\+\+/,'');
					this.Config[obj].endPos['moveY']=pos._y+parseInt(this.Config[obj].endPos['moveY']);
				}
			}
//			if((this.Config[obj].endPos['moveY'] != '' && this.Config[obj].endPos['moveY'] != undefined) || this.Config[obj].endPos['moveY']==0){
			if(this.Config[obj].endPos['moveY'] != null && this.Config[obj].endPos['moveY'] != undefined && this.Config[obj].endPos['moveY'] != "null"){
				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).parentNode.nodeName.toUpperCase() != "BODY" && !$(obj).parentNode.style.position){
				if(!CD_core.getStyle($(obj).parentNode,'Position','position','position')){
					$(obj).parentNode.style.position="relative";
				}
				//alert(CD_core.getStyle($(obj),'Position','position','position'));
				if(!CD_core.getStyle($(obj),'Position','position','position') || CD_core.getStyle($(obj),'Position','position','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+",'"+Motion+"')",this.fps);
	},

	Act:function(obj,Speed,Motion){
		var actCount=0;
		//move
		if(this.Config[obj].endPos['moveX']!="null"){
			var moveX=(Motion=="eq")?this.Equal(obj,$(obj).style.left.replace(/px/gi,''),this.Config[obj].endPos['moveX'],this.Config[obj].vector['moveX'],Speed):this.Decel(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=(Motion=="eq")?this.Equal(obj,$(obj).style.top.replace(/px/gi,''),this.Config[obj].endPos['moveY'],this.Config[obj].vector['moveY'],Speed):this.Decel(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=(Motion=="eq")?this.Equal(obj,nw,this.Config[obj].endPos['scaleX'],this.Config[obj].vector['scaleX'],Speed):this.Decel(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=(Motion=="eq")?this.Equal(obj,nh,this.Config[obj].endPos['scaleY'],this.Config[obj].vector['scaleY'],Speed):this.Decel(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=(Motion=="eq")?this.Equal(obj,CD_core.getAlpha(obj),this.Config[obj].endPos['alpha'],this.Config[obj].vector['alpha'],Speed):this.Decel(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=(Motion=="eq")?this.Equal(obj,color.R,this.Config[obj].endPos['colorR'],this.Config[obj].vector['colorR'],Speed):this.Decel(obj,color.R,this.Config[obj].endPos['colorR'],this.Config[obj].vector['colorR'],Speed);
			var G=(Motion=="eq")?this.Equal(obj,color.G,this.Config[obj].endPos['colorG'],this.Config[obj].vector['colorG'],Speed):this.Decel(obj,color.G,this.Config[obj].endPos['colorG'],this.Config[obj].vector['colorG'],Speed);
			var B=(Motion=="eq")?this.Equal(obj,color.B,this.Config[obj].endPos['colorB'],this.Config[obj].vector['colorB'],Speed):this.Decel(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){
			var efFunc;
			var cpFunc;
			if(this.Config[obj].option['enterframe'])efFunc=this.Config[obj].option['enterframe'];
			if(this.Config[obj].option['complete'])cpFunc=this.Config[obj].option['complete'];
			this.Del(obj);
			if(efFunc)eval(efFunc);
			if(cpFunc)eval(cpFunc);
		}else{
			if(this.Config[obj].option['enterframe'])eval(this.Config[obj].option['enterframe']);
		}
	},

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

	Decel: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;
		}
	},

	Equal:function(obj,nowVal,endVal,vect,Speed){
		nowVal=parseInt(nowVal);
		endVal=parseInt(endVal);

		switch(vect){
			case "p":
				if(nowVal != endVal){
					if(Speed>endVal-nowVal){
						return endVal;
					}else{
						return (nowVal+Speed);
					}
				}else{
					return "*";
				}
			break;
			case "m":
				if(nowVal != endVal){
					if(Speed>nowVal-endVal){
						return endVal;
					}else{
						return (nowVal-Speed);
					}
				}else{
					return "*";
				}
			break;
		}
	},

	/*===============================================*/

	strAdd:function(obj,str,top,end,leng,vect,Speed,Options){
		if(this.Tweens[obj]){
			clearInterval(this.Tweens[obj]);
			this.Config[obj]='';
		}

		this.Config[obj]=new this.Set(obj,Options);

		this.Config[obj].endPos['str']=end;
		this.Config[obj].vector['str']=vect;

		switch(vect){
			case "p":
				this.Config[obj].topPos['str']=0;
			break;
			case "m":
				this.Config[obj].topPos['str']=str.length;
			break;
		}		

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

	strAct:function(obj,str){
		switch(this.Config[obj].vector['str']){
			case "p":
				$(obj).firstChild.nodeValue=this.strAccel(obj,str);
			break;
			case "m":
				$(obj).firstChild.nodeValue=this.strDecel(obj,str);
			break;
		}		

		if(this.Config[obj].topPos['str']==this.Config[obj].endPos['str']){
			var efFunc;
			var cpFunc;
			if(this.Config[obj].option['enterframe'])efFunc=this.Config[obj].option['enterframe'];
			if(this.Config[obj].option['complete'])cpFunc=this.Config[obj].option['complete'];
			this.Del(obj);
			if(efFunc)eval(efFunc);
			if(cpFunc)eval(cpFunc);
		}else{
			if(this.Config[obj].option['enterframe'])eval(this.Config[obj].option['enterframe']);
		}
	},

	strAccel:function(obj,str){
		this.Config[obj].topPos['str']++;
		return CD_core.clipString(str,0,this.Config[obj].topPos['str']);
	},

	strDecel:function(obj,str){
		this.Config[obj].topPos['str']--;
		return CD_core.clipString(str,0,this.Config[obj].topPos['str']);
	},

	strLeng:function(obj){
		this.nowStrPos[obj]--;
	}

}

/*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;
}

/*----------------------------------*/
/*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);
			};
		}
	}
}


/*
----------------------------------------------------------------
	cd_alert
	Part of CreativeDevice JavaScript Liabrary
	Using custom alert dialog
----------------------------------------------------------------
	version			1.00
	last update		2010/07/15
	author			Yoshihisa Kato/YAH!-cyberstudio
----------------------------------------------------------------
*/

var CD_alert={

	Setting:function(){
		//決定ボタン
		this.defineButtonLabel="OK";	//ラベル
		this.defineButtonClass="CDdialogDefine";	//クラス

		//キャンセルボタン
		this.cancelButtonLabel="キャンセル";	//ラベル
		this.cancelButtonClass="CDdialogCancel";	//クラス
		this.afterCancelMessage="";

		/*
			set dialog class
		*/

		//hide Shade
		this.shadeClass='CD_alertShade';

		//dialog box
		this.boxClass='CD_alertDialog';

		//message Area
		this.messageClass='CD_alertMessage';

		//button Area
		this.buttonClass='CD_alertButtonArea';

//		this.barClass='';

		/*
			set alert content
			this.dialogs : alert content & params. string split by "::"
			[0]	message
			[1]	box width
			[2]	box height
			[3]	using after cancel function
			[4]	use Cancel
			[5]	view animation width only
			[6]	view animation height only;
			[7]	disable buttons;
			id	: using dialog id & attribute id of creating div elements
		*/
		this.dialogs="alert!!!!!!!!::240::180::0";

		//button function
		this.defineFunc=function(){};
		this.cancelFunc=function(){};
	},

	Config:new Array(),

	Show:function(alertID,setting){
		if(!setting){
			this.Config[alertID]=new this.Setting();
		}else{
			this.Config[alertID]=setting;
		}

		if(!$(alertID) && !CD_core.getCookie('afterCancel-'+alertID)){
			//get alert propaties
			var propaties=this.Config[alertID].dialogs.split("::");
			propaties[0]=propaties[0].replace(/†/g,'');//文字化け対応

			//create shade
			CD_core.createShadeScreen("CD_alertShade",this.Config[alertID].shadeClass,'null,null,0.6,#000000,3,de,');
			//CD_core.createShadeScreen("CD_alertShade",this.Config[alertID].shadeClass,'');

			//create alert
			var alertBox=CD_core.createObject("div",alertID,this.Config[alertID].boxClass,'',0);
			CD_core.setAttribute(alertBox,'style','position:absolute;width:100px;');

			//create dialog message
			var dialogs=CD_core.createObject("div",alertID+'Msg',this.Config[alertID].messageClass,'',1);
			var message='';
			if(propaties[0].indexOf("<")==-1){
				message=document.createTextNode(propaties[0]);
			}else{
				var r=document.createRange();
				r.selectNodeContents(alertBox);
				message=r.createContextualFragment(propaties[0]);
			}
			dialogs.appendChild(message);

			//create alert button
			var alertFunc=CD_core.createObject("form",'afterCancel-'+alertID,'',alertBox,0);
			if(!propaties[7]){
				//after Cancel
				if(propaties[3]!=0){
					afterCancel=this.afterCancelForm(alertID);
					dialogs.appendChild(afterCancel);
				}

				var buttonArea=CD_core.createObject("div",'',this.Config[alertID].buttonClass,'',1);

				if(propaties[4]!=0){
					var cancelButton=CD_core.createButtonField('button',this.Config[alertID].cancelButtonLabel,'',this.Config[alertID].cancelButtonClass,'');
					buttonArea.appendChild(cancelButton);
				}

				var defineButton=CD_core.createButtonField('button',this.Config[alertID].defineButtonLabel,'',this.Config[alertID].defineButtonClass,'');
				buttonArea.appendChild(defineButton);

				//dialogs.appendChild(buttonArea);
				alertFunc.appendChild(buttonArea);

				if(propaties[3]!=0){
					if(propaties[4]!=0){
						cancelButton.onclick=function(){
							CD_alert.afterCancelCheck(alertID,'CANCEL');
						}
					}
					defineButton.onclick=function(){
						CD_alert.afterCancelCheck(alertID,'DEFINE');
					}
				}else{
					if(propaties[4]!=0){
						cancelButton.onclick=function(){
							CD_alert.Cancel(alertID);
						}
					}
					defineButton.onclick=function(){
						CD_alert.Define(alertID);
					}
				}
			}

			CD_core.setAlpha(alertBox,0);
			if(propaties[5]==1)alertBox.style.height=propaties[2]+"px";
			if(propaties[6]==1)alertBox.style.height=propaties[1]+"px";
			CD_core.setFixedPosition(alertBox,'center',CD_core._scrollY()+CD_core._windowHeight()/2-$(alertID).offsetHeight/2);
			CD_core.swapDepths(alertBox,"nextHighestDepth");
			alertFunc.insertBefore(dialogs,alertFunc.firstChild);
			CD_core.setAlpha(alertFunc,0);

			CD_core.addEvent(window,"resize",function resizeMove(e){
				CD_alert.Move(alertID);
			});

			CD_core.addEvent(window,"scroll",function scrollMove(e){
				CD_alert.Move(alertID);
			});

			var comps=function(){
				if(this.Config[alertID].completeFunc)eval(this.Config[alertID].completeFunc);
			}

//			CD_tween.Add(alertID,"",propaties[1]+":"+propaties[2]+":1:CM",1,'null',4,'eq','complete:CD_core.setFixedPosition("'+alertID+'","center",'+(CD_core._scrollY()+CD_core._windowHeight()/2-$(alertID).offsetHeight/2)+')');
			CD_tween.Add(alertID,"null",propaties[1]+":"+propaties[2]+":1:CM",1,'null',20,'eq','complete:CD_tween.Add("afterCancel-'+alertID+'","null","",1,"null",4,"de","")');

			return false;

		}else{

			this.Define(alertID);
			return;
		}
	},

	afterCancelForm:function(alertID){
		var formCode=CD_core.createObject("div",'',"CD_alertAfterCancel",'',1);
		var checkBox=CD_core.createInputField("checkbox",1,'cancelCheck','','','');
		var cancelMsg=document.createTextNode(this.Config[alertID].afterCancelMessage);
		formCode.appendChild(checkBox);
		insertAfter(cancelMsg,checkBox);
		return formCode;
	},

	afterCancelCheck:function(alertID,buttonType){
		if($('afterCancel-'+alertID).elements['cancelCheck'].checked)CD_core.setCookie('afterCancel-'+alertID,1,1,"/");
		if(buttonType=="DEFINE")this.Define(alertID);
		if(buttonType=="CANCEL")this.Cancel(alertID);
	},

	Define:function(alertID){
		if(this.Config[alertID].defineFunc)eval(this.Config[alertID].defineFunc);
		this.Close(alertID);
	},

	Cancel:function(alertID){
		if(this.Config[alertID].cancelFunc)eval(this.Config[alertID].cancelFunc);
		this.Close(alertID);
	},

	Close:function(alertID){
		if($(alertID)){
			document.body.removeChild($(alertID));
			CD_core.removeShadeScreen("CD_alertShade",'');
		}
	},

	Move:function(alertID){
		if($(alertID)){
			CD_core.setFixedPosition(alertID,'center',CD_core._scrollY()+CD_core._windowHeight()/2-$(alertID).offsetHeight/2);
			CD_core.setPosition($("CD_alertShade"),"width",CD_core._documentWidth());
			CD_core.setPosition($("CD_alertShade"),"height",CD_core._documentHeight());
		}
	},

	dragStartX:0,
	dragStartY:0,
	alertPosition:'',
	alertObject:'',

	dragStart:function(obj){
		this.dragStartX=CD._mouseX;
		this.dragStartY=CD._mouseY;
		this.alertObject=$(obj);
		this.alertPosition=new CD_core.getPosition($(obj),0,0,0,0,0);
		CD_core.addEvent(document,"mousemove",CD_alert.dragMove);
		CD_core.addEvent(document,"mouseup",CD_alert.dragStop);
	},

	dragStop:function(){
		CD_alert.dragStartX=0;
		CD_alert.dragStartY=0;
		CD_alert.alertObject=undefined;
		CD_alert.alertPosition=undefined;
		CD_core.delEvent(document,"mousemove",CD_alert.dragMove);
		CD_core.delEvent(document,"mouseup",CD_alert.dragStop);
	},

	dragMove:function(){
		var moveX=CD._mouseX-CD_alert.dragStartX;
		var moveY=CD._mouseY-CD_alert.dragStartY;
		CD_core.setPosition($(CD_alert.alertPosition._name),"x",(CD_alert.alertPosition._x+moveX));
		CD_core.setPosition($(CD_alert.alertPosition._name),"y",(CD_alert.alertPosition._y+moveY));
	}

}

/*
----------------------------------------------------------------
	cd_timecontrol
	Part of CreativeDevice JavaScript Liabrary
	control date & time extension
----------------------------------------------------------------
	version			1.00
	last update		2010/1/12
	author			Yoshihisa Kato/YAH!-cyberstudio
----------------------------------------------------------------
*/

var CD_timeControl={
	/*
	================================================================================
		day view configure
	================================================================================
	*/
	weekDays:{
		"J":["日","月","火","水","木","金","土"],
		"E0":["sun","mon","tue","wed","thu","fri","sat"],
		"E1":["SUN","MON","TUE","WED","THU","FRI","SAT"],
		"E2":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
	},

	/*
	================================================================================
		get month last date
	================================================================================
	*/
	getMonthLastDate:function(Y,M){
		var LD=new Array();
		LD[0]=[0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
		LD[1]=[0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
		return LD[this.isLeapYear(Y)][M];
	},

	/*
	================================================================================
		confirm leap year
	================================================================================
	*/
	isLeapYear:function(Y){
		var res=0;
		if(Y%100){
			res=(Y%4)?0:1;
		}else{
			if(Y%400){
				res=0;
			}else{
				res=(Y%4000)?1:0;
			}
		}
		return res;
	},

	/*
	================================================================================
		change year view to Japanese era
	================================================================================
	*/
	changeEraToJ:function(Y){
		if(Y<=644){
			Y=Y;
		}else if(Y==645){
			Y="大化元";
		}else if(Y==654){
			Y="白雉5";
		}else if(Y==655){
			Y="[斉明]元";
		}else if(Y==672){
			Y="[弘文]2";
		}else if(Y==673){
			Y="[天武]元";
		}else if(Y==685){
			Y="[天武]14";
		}else if(Y==686){
			Y="[天武]15 / 朱鳥 / [持統]元";
		}else if(Y==687){
			Y="[持統]2";
		}else if(Y==748){
			Y="天平20";
		}else if(Y==749){
			Y="天平21 / 天平感宝 / 天平勝宝元";
		}else if(Y==750){
			Y="天平勝宝2";
		}else if(Y==1330){
			Y="元徳2";
		}else if(Y>=1331 && Y<=1392){
			for(var i=0;i<this.wareki1.length;i++){
				if(Y==this.wareki1[i][0]){
					Y="南朝："+this.wareki1[i][2]+"・"+"北朝："+this.wareki1[i][1];
					break;
				}
			}
		}else{
			for(var i=0;i<this.wareki0.length;i++){
				if(Y==this.wareki0[i][0]){
					if(i==12 || i==155){//750年 or 1395年
						Y=this.wareki0[i][2]+"2";
					}else{
						Y=this.wareki0[i-1][2]+(parseInt(Y)-parseInt(this.wareki0[i-1][0])+1)+" / "+this.wareki0[i][2]+"元";
					}
					break;
				}else if(Y>this.wareki0[i][0] && Y<this.wareki0[i][1]){
					Y=this.wareki0[i][2]+(parseInt(Y)-parseInt(this.wareki0[i][0])+1);
					break;
				}
			}
		}
		return Y;
	},

	/*
	================================================================================
		change year view to Christian era
	================================================================================
	*/
	changeEraToE:function(Y){
		if(Y=="大化元"){
			Y=645;
		}else if(Y=="白雉5"){
			Y=654;
		}else if(Y=="[斉明]元"){
			Y=655;
		}else if(Y=="[弘文]2"){
			Y=672;
		}else if(Y=="[天武]元"){
			Y=673;
		}else if(Y=="[天武]14"){
			Y=685;
		}else if(Y=="[天武]15 / 朱鳥 / [持統]元"){
			Y=686;
		}else if(Y=="[持統]2"){
			Y=687;
		}else if(Y=="天平20"){
			Y=748;
		}else if(Y=="天平21 / 天平感宝 / 天平勝宝元"){
			Y=749;
		}else if(Y=="天平勝宝2"){
			Y=750;
		}else if(Y=="元徳2"){
			Y=1330;
		}else if(Y.indexOf("・")!=-1){
			var checkWareki=(Y.split("・"))[0].replace(/南朝：/,'');
			for(var i=0;i<this.wareki1.length;i++){
				if(checkWareki==this.wareki1[i][2]){
					Y=this.wareki1[i][0];
					break;
				}
			}
		}else{
			var checkWareki=(Y.indexOf(" / ")!=-1)?(Y.split(" "))[2].replace(/元$/g,1):Y;
			for(var i=0;i<this.wareki0.length;i++){
				if(checkWareki.indexOf(this.wareki0[i][2])!=-1){
					Y=parseInt(checkWareki.replace(/\D/g,''))+this.wareki0[i][0]-1;
					break;
				}
			}
		}
		return Y;
	},

	/*
	================================================================================
		Japanese era Array
	================================================================================
	*/
	wareki0:new Array(
		[645,650,'大化'],
		[650,654,'白雉'],
		[655,661,'[斉明]'],
		[661,671,'[天智]'],
		[671,672,'[弘文]'],
		[673,685,'[天武]'],
		//686	天武]15 / 朱鳥 / 天持統]元
		[686,697,'[持統]'],
		[697,701,'[文武]'],
		[701,704,'大宝'],
		[704,708,'慶雲'],
		[708,714,'和銅'],
		[714,717,'霊亀'],
		[717,724,'養老'],
		[724,729,'神亀'],
		[729,748,'天平'],
		//749	天平21 / 天平感宝 / 天平勝宝元
		[749,757,'天平勝宝'],
		[757,765,'天平宝字'],
		[765,767,'天平神護'],
		[767,770,'神護景雲'],
		[770,781,'宝亀'],
		[781,782,'天応'],
		[782,806,'延暦'],
		[806,810,'大同'],
		[810,824,'弘仁'],
		[824,834,'天長'],
		[834,848,'承和'],
		[848,851,'嘉祥'],
		[851,854,'仁寿'],
		[854,857,'斉衡'],
		[857,859,'天安'],
		[859,877,'貞観'],
		[877,885,'元慶'],
		[885,889,'仁和'],
		[889,898,'寛平'],
		[898,901,'昌泰'],
		[901,923,'延喜'],
		[923,931,'延長'],
		[931,938,'承平'],
		[938,947,'天慶'],
		[947,957,'天暦'],
		[957,961,'天徳'],
		[961,964,'応和'],
		[964,968,'康保'],
		[968,970,'安和'],
		[970,973,'天禄'],
		[973,976,'天延'],
		[976,978,'貞元'],
		[978,983,'天元'],
		[983,985,'永観'],
		[985,987,'寛和'],
		[987,989,'永延'],
		[989,990,'永祚'],
		[990,995,'正暦'],
		[995,999,'長徳'],
		[999,1004,'長保'],
		[1004,1012,'寛弘'],
		[1012,1017,'長和'],
		[1017,1021,'寛仁'],
		[1021,1024,'治安'],
		[1024,1028,'万寿'],
		[1028,1037,'長元'],
		[1037,1040,'長暦'],
		[1040,1044,'長久'],
		[1044,1046,'寛徳'],
		[1046,1053,'永承'],
		[1053,1058,'天喜'],
		[1058,1065,'康平'],
		[1065,1069,'治暦'],
		[1069,1074,'延久'],
		[1074,1077,'承保'],
		[1077,1081,'承暦'],
		[1081,1084,'永保'],
		[1084,1087,'応徳'],
		[1087,1094,'寛治'],
		[1094,1096,'嘉保'],
		[1096,1097,'永長'],
		[1097,1099,'承徳'],
		[1099,1104,'康和'],
		[1104,1106,'長治'],
		[1106,1108,'嘉承'],
		[1108,1110,'天仁'],
		[1110,1113,'天永'],
		[1113,1118,'永久'],
		[1118,1120,'元永'],
		[1120,1124,'保安'],
		[1124,1126,'天治'],
		[1126,1131,'大治'],
		[1131,1132,'天承'],
		[1132,1135,'長承'],
		[1135,1141,'保延'],
		[1141,1142,'永治'],
		[1142,1144,'康治'],
		[1144,1145,'天養'],
		[1145,1151,'久安'],
		[1151,1154,'仁平'],
		[1154,1156,'久寿'],
		[1156,1159,'保元'],
		[1159,1160,'平治'],
		[1160,1161,'永暦'],
		[1161,1163,'応保'],
		[1163,1165,'長寛'],
		[1165,1166,'永万'],
		[1166,1169,'仁安'],
		[1169,1171,'嘉応'],
		[1171,1175,'承安'],
		[1175,1177,'安元'],
		[1177,1181,'治承'],
		[1181,1182,'養和'],
		[1182,1184,'寿永'],
		[1184,1185,'元暦'],
		[1185,1190,'文治'],
		[1190,1199,'建久'],
		[1199,1201,'正治'],
		[1201,1204,'建仁'],
		[1204,1206,'元久'],
		[1206,1207,'建永'],
		[1207,1211,'承元'],
		[1211,1213,'建暦'],
		[1213,1219,'建保'],
		[1219,1222,'承久'],
		[1222,1224,'貞応'],
		[1224,1225,'元仁'],
		[1225,1227,'嘉禄'],
		[1227,1229,'安貞'],
		[1229,1232,'寛喜'],
		[1232,1233,'貞永'],
		[1233,1234,'天福'],
		[1234,1235,'文暦'],
		[1235,1238,'嘉禎'],
		[1238,1239,'暦仁'],
		[1239,1240,'延応'],
		[1240,1243,'仁治'],
		[1243,1247,'寛元'],
		[1247,1249,'宝治'],
		[1249,1256,'建長'],
		[1256,1257,'康元'],
		[1257,1259,'正嘉'],
		[1259,1260,'正元'],
		[1260,1261,'文応'],
		[1261,1264,'弘長'],
		[1264,1275,'文永'],
		[1275,1278,'建治'],
		[1278,1288,'弘安'],
		[1288,1293,'正応'],
		[1293,1299,'永仁'],
		[1299,1302,'正安'],
		[1302,1303,'乾元'],
		[1303,1306,'嘉元'],
		[1306,1308,'徳治'],
		[1308,1311,'延慶'],
		[1311,1312,'応長'],
		[1312,1317,'正和'],
		[1317,1319,'文保'],
		[1319,1321,'元応'],
		[1321,1324,'元亨'],
		[1324,1326,'正中'],
		[1326,1329,'嘉暦'],
		[1329,1330,'元徳'],
		//1331-1394	= wareki1
		[1390,1394,'明徳'],
		[1394,1428,'応永'],
		[1428,1429,'正長'],
		[1429,1441,'永享'],
		[1441,1444,'嘉吉'],
		[1444,1449,'文安'],
		[1449,1452,'宝徳'],
		[1452,1455,'享徳'],
		[1455,1457,'康正'],
		[1457,1460,'長禄'],
		[1460,1466,'寛正'],
		[1466,1467,'文正'],
		[1467,1469,'応仁'],
		[1469,1487,'文明'],
		[1487,1489,'長享'],
		[1489,1492,'延徳'],
		[1492,1501,'明応'],
		[1501,1504,'文亀'],
		[1504,1521,'永正'],
		[1521,1528,'大永'],
		[1528,1532,'享禄'],
		[1532,1555,'天文'],
		[1555,1558,'弘治'],
		[1558,1570,'永禄'],
		[1570,1592,'元亀'],
		[1592,1596,'文禄'],
		[1596,1615,'慶長'],
		[1615,1624,'元和'],
		[1624,1644,'寛永'],
		[1644,1648,'正保'],
		[1648,1652,'慶安'],
		[1652,1655,'承応'],
		[1655,1658,'明暦'],
		[1658,1661,'万治'],
		[1661,1673,'寛文'],
		[1673,1681,'延宝'],
		[1681,1684,'天和'],
		[1684,1688,'貞享'],
		[1688,1704,'元禄'],
		[1704,1711,'宝永'],
		[1711,1716,'正徳'],
		[1716,1736,'享保'],
		[1736,1741,'元文'],
		[1741,1744,'寛保'],
		[1744,1748,'延享'],
		[1748,1751,'寛延'],
		[1751,1764,'宝暦'],
		[1764,1772,'明和'],
		[1772,1781,'安永'],
		[1781,1789,'天明'],
		[1789,1801,'寛政'],
		[1801,1804,'享和'],
		[1804,1818,'文化'],
		[1818,1830,'文政'],
		[1830,1844,'天保'],
		[1844,1848,'弘化'],
		[1848,1854,'嘉永'],
		[1854,1860,'安政'],
		[1860,1861,'万延'],
		[1861,1864,'文久'],
		[1864,1865,'元治'],
		[1865,1868,'慶応'],
		[1868,1912,'明治'],
		[1912,1926,'大正'],
		[1926,1989,'昭和'],
		[1989,2050,'平成']
	),
		
	wareki1:new Array(
		[1331,'元徳3','元徳3/元弘元'],
		[1332,'元徳4/正慶元','元弘2'],
		[1333,'正慶2','元弘3'],
		[1334,'正慶3/建武元','元弘4'],
		[1335,'建武2','元弘5'],
		[1336,'建武3','元弘6/延元元'],
		[1337,'建武4','延元2'],
		[1338,'建武5/暦応元','延元3'],
		[1339,'暦応2','延元4'],
		[1340,'暦応3','延元5/興国元'],
		[1341,'暦応4','興国2'],
		[1342,'暦応5/康永元','興国3'],
		[1343,'康永2','興国4'],
		[1344,'康永3','興国5'],
		[1345,'康永4/貞和元','興国6'],
		[1346,'貞和2','興国7/正平元'],
		[1347,'貞和3','正平2'],
		[1348,'貞和4','正平3'],
		[1349,'貞和5','正平4'],
		[1350,'貞和6/観応元','正平5'],
		[1351,'観応2','正平6'],
		[1352,'観応3/文和元','正平7'],
		[1353,'文和2','正平8'],
		[1354,'文和3','正平9'],
		[1355,'文和4','正平10'],
		[1356,'文和5/延文元','正平1元'],
		[1357,'延文元','正平12'],
		[1358,'延文2','正平13'],
		[1359,'延文3','正平14'],
		[1360,'延文4','正平15'],
		[1361,'延文5/康安元','正平16'],
		[1362,'貞治元','正平17'],
		[1363,'貞治元','正平18'],
		[1364,'貞治2','正平19'],
		[1365,'貞治3','正平20'],
		[1366,'貞治4','正平2元'],
		[1367,'貞治5','正平22'],
		[1368,'貞治6/応安元','正平23'],
		[1369,'応安2','正平24'],
		[1370,'応安3','正平25/建徳元'],
		[1371,'応安4','建徳2'],
		[1372,'応安5','建徳3/文中元'],
		[1373,'応安6','文中2'],
		[1374,'応安7','文中3'],
		[1375,'応安8/永和元','文中4/天授元'],
		[1376,'永和2','天授2'],
		[1377,'永和3','天授3'],
		[1378,'永和4','天授4'],
		[1379,'永和5/康暦元','天授5'],
		[1380,'康暦2','天授6'],
		[1381,'康暦3/永徳元','天授7/弘和元'],
		[1382,'永徳2','弘和2'],
		[1383,'永徳3','弘和3'],
		[1384,'永徳4/至徳元','弘和4/元中元'],
		[1385,'至徳2','元中2'],
		[1386,'至徳3','元中3'],
		[1387,'至徳4/嘉慶元','元中4'],
		[1388,'嘉慶2','元中5'],
		[1389,'嘉慶3/康応元','元中6'],
		[1390,'明徳元','元中7'],
		[1391,'明徳2','元中8'],
		[1392,'明徳3','元中9/明徳3']
	)
}


/*
----------------------------------------------------------------
	CreativeDevece JavaScript Library
	Part of CreativeDevice JavaScript Liabrary
	anchor link targetControl
----------------------------------------------------------------
	version			0.82
	last update		2010/05/17
	author			Yoshihisa Kato/YAH!-cyberstudio
----------------------------------------------------------------
*/

var CD_anchorCtrl={

	Setting:function(){
		this.externalLinkTypes="_blank";

		this.internalLinkClass=new Array(
			"internalLinkText",
			"internalLink"
		);

		this.externalLinkClass=new Array(
			"externalLinkText",
			"externalLink"
		);

		this.popupLinkClass=new Array(
			"popupLinkText",
			"popupLink"
		);

		this.ajaxLinkClass=new Array(
			"ajaxLinkText",
			"ajaxLink"
		);
	},

	Load:function(){
		var Config=new this.Setting();
		var anchors=document.getElementsByTagName("a");
		var anchorType=null;

		var parseTargetClass=function(classVal){
			for(var i=0;i<Config.externalLinkClass.length;i++){
				if(classVal==Config.externalLinkClass[i]){
					return "extra";
					break;
				}
			}
			for(var i=0;i<Config.popupLinkClass.length;i++){
				if(classVal==Config.popupLinkClass[i]){
					return "popup";
					break;
				}
			}
			for(var i=0;i<Config.ajaxLinkClass.length;i++){
				if(classVal==Config.ajaxLinkClass[i]){
					return "ajax";
					break;
				}
			}
			for(var i=0;i<Config.internalLinkClass.length;i++){
				if(classVal==Config.internalLinkClass[i]){
					return "internal";
					break;
				}
			}
			return false;
		}

		for(var i=0;i<anchors.length;i++){
			attrRel=CD_core.getAttribute(anchors[i],"rel");

			if(attrRel && attrRel.indexOf("CD_anchorCtrl")!=-1){
				anchorType=(CD_core.getAttribute(anchors[i],"class")||anchors[i].className);

				switch(parseTargetClass(anchorType)){
					//externalLink;
					case "extra":
						CD_core.setAttribute(anchors[i],"target",Config.externalLinkType);
						CD_core.addEvent(anchors[i],"click",function(){
							return true;
						});
					break;
					//popup
					case "popup":
						if(attrRel.indexOf(":")!=-1){
							anchors[i].args=CD_core.getAttribute(anchors[i],"rel").split(":")[1].split(",");
							anchors[i].anchorTarget=anchors[i].args[0];
							anchors[i].args.splice(0,1);
							anchors[i].anchorOption=anchors[i].args.join(",");
							anchors[i].anchorHref=CD_core.getAttribute(anchors[i],"href");
							CD_core.setAttribute(anchors[i],"href",'JavaScript:void(0)');
							CD_core.addEvent(anchors[i],"click",function(){
								var obj=(CD.UA.asn=="ie")?CD_core.getAnchorObject(event.srcElement):this;
								CD_popup.Open(obj.anchorHref,obj.anchorTarget,obj.anchorOption);
								return false;
							});
						}else{
							CD_core.setAttribute(anchors[i],"target","_blank");
							CD_core.addEvent(anchors[i],"click",function(){
								return true;
							});
						}
					break;
					//ajax send
					case "ajax":
						if(attrRel.indexOf(":")!=-1){
							anchors[i].args=CD_core.getAttribute(anchors[i],"rel").split(":")[1].split(",");
							anchors[i].anchorTarget=anchors[i].args[0];
							anchors[i].anchorSetting=(anchors[i].args[1])?anchors[i].args[1]:'';
							anchors[i].args.splice(0,2);
							anchors[i].anchorOption=anchors[i].args.join(",");
							anchors[i].anchorHref=CD_core.getAttribute(anchors[i],"href");
							CD_core.setAttribute(anchors[i],"href",'JavaScript:void(0)');

							//attach trriger function
							CD_core.addEvent(anchors[i],"mousedown",function(e){
								CD_anchorCtrl.Trigger=e.srcElement||this;
							});
							CD_core.addEvent(anchors[i],"click",function(){
								var obj=(CD.UA.asn=="ie")?CD_core.getAnchorObject(event.srcElement):this;
								CD_ajax.Send(obj.anchorHref,obj.anchorTarget,obj.anchorSetting,obj.anchorOption);
								return false;
							});
						}else{
							CD_core.setAttribute(anchors[i],"target","_blank");
							CD_core.addEvent(anchors[i],"click",function(){
								return true;
							});
						}
					break;
					//internal
					case "internal":
						if(attrRel.indexOf(":")!=-1 && CD_core.getAttribute(anchors[i],"href").indexOf("#")!=-1){
							anchors[i].args=CD_core.getAttribute(anchors[i],"rel").split(":")[1].split(",");
							anchors[i].anchorTarget=anchors[i].args[0];
							anchors[i].args.splice(0,1);
							anchors[i].anchorOption=anchors[i].args.join(",");
							anchors[i].anchorHref=CD_core.getAttribute(anchors[i],"href").replace(/#/g,'');
							CD_core.setAttribute(anchors[i],"href",'JavaScript:void(0)');
							CD_core.addEvent(anchors[i],"click",function(){
								var obj=(CD.UA.asn=="ie")?CD_core.getAnchorObject(event.srcElement):this;
								CD_pageScroll.move(obj.anchorHref,obj.anchorTarget);
								return false;
							});
						}else{
							CD_core.addEvent(anchors[i],"click",function(){
								return true;
							});
						}
					break;
				}
			}
		}
	},
	Trigger:null	//clicked anchor object
}

/*_____HTTP_REQUEST_____*/
var CD_ajax={

	Setting:function(){
		this.loadingTag='<div align="center" style="width:100%;"><img src="'+CD.imageDir+'loading.gif" alt="読み込み中"></div>';		
		this.abortTag='<div align="center" style="background-color:#fff;width:100%;padding:10px">読み込みを中断しました</div>';		
		this.timeOutTag='<div align="center" style="background-color:#fff;width:100%;padding:10px">タイムアウトしました</div>';		
		this.notFoundTag='<div align="center" style="background-color:#fff;width:100%;padding:10px">ファイルが存在しません</div>';		
		this.accessDenyTag='<div align="center" style="background-color:#fff;width:100%;padding:10px">アクセス権限がありません</div>';		
		this.serverErrorTag='<div align="center" style="background-color:#fff;width:100%;padding:10px">サーバーエラーです</div>';		

		this.loadingSign='<img src="'+CD.imageDir+'loading_sign.gif" alt="読み込み">';
		this.abortSign='<img src="'+CD.imageDir+'arrow_c.gif" alt="中断">';
		this.reloadSign="";
		this.abortAutoSign="読み込み中断";
		this.reStartSign="読み込み再開";

		this.cacheControlEnabler=false;
		this.cacheControlParam="ccp";

		this.timeOutSecond=60;

		this.eventOption='';
		//this.eventOption='start:ajaxStart();loading:ajaxLoading();complete:ajaxComplete();timeOut:ajaxTimeout();abort:ajaxAbort();';
		/*
			start
			loading
			complete
			accessDeny
			notFound
			serverError
			abort
			timeoOut
			abortAuto			
		*/
	},

	setOption:function(obj,option){
		CD_ajax.Options[obj]=new Array();
		option=(option)?option:CD_ajax.Config[obj].eventOption;
		if(option){
			var optVals=option.split(";");
			for(i=0;i<optVals.length;i++){
				CD_ajax.Options[obj][optVals[i].split(":")[0]]=optVals[i].split(":")[1];
			}
		}
	},


/*================================================================*/
/*_____GLOBAL_variable_____*/
	xmlHttpObject:new Array(),
	xmlHttp:new Array(),
	timeOutID:new Array(),
	Config:new Array(),
	Options:new Array(),
	reloadTimerID:new Array(),

/*_____Method_____*/
	Send:function(sendURL,obj,setting,option){
		
		obj=this.withExtendDiv(obj);//with_extendDiv

		this.Config[obj]=(!setting)?new this.Setting():window[setting];
		this.setOption(obj,option);
		if(CD_ajax.Options[obj]['start'])eval(CD_ajax.Options[obj]['start']);

		if(CD_anchorCtrl.Trigger){
			var loadingReplace='<span id="ajaxloading">'+CD_ajax.Config[obj].loadingSign;
			loadingReplace+='<a href="JavaScript:void(0);" onclick="CD_ajax.Abort(\''+obj+'\')">'+CD_ajax.Config[obj].abortSign;
			loadingReplace+='</a></span>';
			//CD_anchorCtrl.Trigger.insertAdjacentHTML("afterEnd",loadingReplace);
		}

		this.Display(sendURL,obj,'get',null);
		return false;
	},

	Auto:function(sendURL,obj,setting,timer,option){

		obj=this.withExtendDiv(obj);//with_extendDiv

		this.Config[obj]=(!setting)?new this.Setting():setting;
		this.setOption(obj,option);

		if(CD_ajax.Options[obj]['startAuto'])eval(CD_ajax.Options[obj]['startAuto']);

		reSend=function(){
			CD_anchorCtrl.Trigger=null;	//他のアンカークリックに影響しないようにする
			//clearTimeout(CD_ajax.timeOutID[obj]);	//読み込み中にリロードが発生した場合の処理

			CD_ajax.Display(sendURL,obj,'get',null);

			if(CD_anchorCtrl.Trigger){
				var loadingReplace='<span id="ajaxloading">'+CD_ajax.Config[obj].loadingSign;
				loadingReplace+='<a href="JavaScript:void(0);" onclick="CD_ajax.Abort(\''+obj+'\')">'+CD_ajax.Config[obj].abortSign;
				loadingReplace+='</a></span>';
				CD_anchorCtrl.Trigger.insertAdjacentHTML("afterEnd",loadingReplace);
			}
		}

		reSend();
		timer=timer*1000;
		this.reloadTimerID[obj]=setInterval("reSend()",timer);

		if(setting==''){setting="''";}
		var abortTag='<a href="JavaScript:void(0)" ';
		abortTag+='onclick="CD_ajax.abortAuto(\''+sendURL+'\',\''+obj+'\','+setting+','+(timer/1000)+',\''+option+'\')">'+this.Config[obj].abortAutoSign+'</a>';

		if(!$('CD_autoAjaxTrigger'+obj)){
			document.write('<span id="CD_autoAjaxTrigger'+obj+'">'+abortTag+'</span>');
		}else{
			$('CD_autoAjaxTrigger'+obj).innerHTML=abortTag;
		}
	},

	Post:function(formID,obj,setting,option){
		this.Config[obj]=(!setting)?new this.Setting():setting;
		this.setOption(obj,option);

		if(CD_ajax.Options[obj]['start'])eval(CD_ajax.Options[obj]['start']);

		sendURL=document.forms[formID].action;
		var postValue='';
		formObj=document.forms[formID];
		for(i=0;i<formObj.elements.length;i++){
			postValue+=formObj.elements[i].name+"="+encodeURIComponent(formObj.elements[i].value);
			if(i!=formObj.elements.length-1){postValue+="&";}
		}
		this.Display(sendURL,obj,'post',postValue);
	},

	Display:function(sendURL,obj,methods,sendVal){
		//IE6 Cache Control(commentout)
		/*
		if(this.Config[obj].cacheControlEnabler && methods=="get"){
			var paramVal=new Date();
			if(sendURL.indexOf("?")==-1){
				sendURL+="?"+this.Config[obj].cacheControlParam+"="+paramVal.getTime();
			}else{
				sendURL+="&amp;"+this.Config[obj].cacheControlParam+"="+paramVal.getTime();
			}
		}
		*/
		this.xmlHttp[obj]=this.Query(obj);
		if(this.xmlHttp[obj]){
			this.xmlHttp[obj].onreadystatechange=function(){
				if(CD_ajax.xmlHttp[obj].readyState==4){
					if(CD_ajax.xmlHttp[obj].status==200){
						if($(obj).type=="text"){
							$(obj).value=CD_ajax.xmlHttp[obj].responseText;
						}else{
							$(obj).innerHTML=CD_ajax.xmlHttp[obj].responseText;
						}
						if(CD_ajax.Options[obj]['complete'])eval(CD_ajax.Options[obj]['complete']);
					}else if(CD_ajax.xmlHttp[obj].status==401){
						if($(obj).type=="text"){
							$(obj).value==CD_ajax.Config[obj].accessDenyTag;
						}else{
							$(obj).innerHTML=CD_ajax.Config[obj].accessDenyTag;
						}
						if(CD_ajax.Options[obj]['accessDeny'])eval(CD_ajax.Options[obj]['accessDeny']);
					}else if(CD_ajax.xmlHttp[obj].status==404){
						if($(obj).type=="text"){
							$(obj).value=CD_ajax.Config[obj].notFoundTag;
						}else{
							$(obj).innerHTML=CD_ajax.Config[obj].notFoundTag;
						}
						if(CD_ajax.Options[obj]['notFound'])eval(CD_ajax.Options[obj]['notFound']);
					}else if(CD_ajax.xmlHttp[obj].status==500){
						if($(obj).type=="text"){
							$(obj).value=CD_ajax.Config[obj].serverErrorTag;
						}else{
							$(obj).innerHTML=CD_ajax.Config[obj].serverErrorTag;
						}
						if(CD_ajax.Options[obj]['serverError'])eval(CD_ajax.Options[obj]['serverError']);
					}
					CD_ajax.delStatus(obj);
				}else{
					if($(obj) && $(obj).type=="text"){
						$(obj).value=CD_ajax.Config[obj].loadingTag;
					}else{
						$(obj).innerHTML=CD_ajax.Config[obj].loadingTag;
					}
					if(CD_ajax.Options[obj]['loading'])eval(CD_ajax.Options[obj]['loading']);
				}
			}
			CD_ajax.xmlHttp[obj].open(methods,sendURL,true);
			CD_ajax.xmlHttp[obj].send(sendVal);
			//CD_ajax.timeOutID[obj]=setTimeout("CD_ajax.timeOut('"+obj+"')",CD_ajax.Config[obj].timeOutSecond*1000);
		}
	},

	Load:function(sendURL,obj,setting,option){
		this.Config[obj]=(!setting)?new this.Setting():window[setting];
		this.setOption(obj,option);
		if(CD_ajax.Options[obj]['start'])eval(CD_ajax.Options[obj]['start']);

		if(CD_anchorCtrl.Trigger){
			var loadingReplace='<span id="ajaxloading">'+CD_ajax.Config[obj].loadingSign;
			loadingReplace+='<a href="JavaScript:void(0);" onclick="CD_ajax.Abort(\''+obj+'\')">'+CD_ajax.Config[obj].abortSign;
			loadingReplace+='</a></span>';
			//CD_anchorCtrl.Trigger.insertAdjacentHTML("afterEnd",loadingReplace);
		}
		this.getXML(sendURL,obj,'get',null);
		return false;
	},

	getXML:function(sendURL,obj,methods,sendVal){
		this.xmlHttp[obj]=this.Query(obj);
		if(this.xmlHttp[obj]){
			this.xmlHttp[obj].onreadystatechange=function(){
				if(CD_ajax.xmlHttp[obj].readyState==4){
					switch(CD_ajax.xmlHttp[obj].status){
						case 200:
							window[obj]=CDs_ajax.xmlHttp[obj].responseXML;
							if(CD_ajax.Options[obj]['complete'])eval(CD_ajax.Options[obj]['complete']);
						break;
						case 401:
							trace(CD_ajax.Config[obj].accessDenyTag);
							if(CD_ajax.Options[obj]['accessDeny'])eval(CD_ajax.Options[obj]['accessDeny']);
						break;
						case 404:
							trace(CD_ajax.Config[obj].notFoundTag);
							if(CD_ajax.Options[obj]['notFound'])eval(CD_ajax.Options[obj]['notFound']);
						break;
						case 500:
							trace(CD_ajax.Config[obj].serverErrorTag);
							if(CD_ajax.Options[obj]['serverError'])eval(CD_ajax.Options[obj]['serverError']);
						break;
					}
					CD_ajax.delStatus(obj);
				}else{
					//trace(CD_ajax.Config[obj].loadingTag);
				}
			}
			CD_ajax.xmlHttp[obj].open(methods,sendURL,true);
			CD_ajax.xmlHttp[obj].send(sendVal);
		}
	},

	Abort:function(obj){
		//clearTimeout(this.timeOutID[obj]);
		this.xmlHttp[obj].abort();
		this.delStatus(obj);
		$(obj).innerHTML=this.Config[obj].abortTag;
		if(CD_ajax.Options[obj]['abort'])eval(CD_ajax.Options[obj]['abort']);
	},

	abortAuto:function(sendURL,obj,setting,timer,option){
		var abortTime=new Date();

		this.xmlHttp[obj].abort();
		clearInterval(this.reloadTimerID[obj]);
		//clearTimeout(this.timeOutID[obj]);

		if(setting==''){setting="''";}
		var restartCode='<a href="JavaScript:CD_ajax.Auto(\''+sendURL+'\',\''+obj+'\','+setting+','+timer+',\''+option+'\')">'+this.Config[obj].reStartSign;
		restartCode+='('+abortTime.getHours()+':'+abortTime.getMinutes()+':'+abortTime.getSeconds()+'に中断)</a>';
		$('CD_autoAjaxTrigger'+obj).innerHTML=restartCode;

		if(CD_ajax.Options[obj]['abortAuto'])eval(CD_ajax.Options[obj]['abortAuto']);
	},

	timeOut:function(obj){
		this.xmlHttp[obj].abort();
		this.delStatus(obj);
		$(obj).innerHTML=this.Config[obj].timeOutTag;
		if(CD_ajax.Options[obj]['timeOut'])eval(CD_ajax.Options[obj]['timeOut']);
	},

	delStatus:function(obj){
		//clearTimeout(CD_ajax.timeOutID[obj]);
		if(CD_anchorCtrl.Trigger){
			for(i=0;i<CD_anchorCtrl.Trigger.parentNode.childNodes.length;i++){
				if(CD_anchorCtrl.Trigger.parentNode.childNodes[i].id && CD_anchorCtrl.Trigger.parentNode.childNodes[i].id=="ajaxloading"){
					CD_anchorCtrl.Trigger.parentNode.removeChild(CD_anchorCtrl.Trigger.parentNode.childNodes[i]);
				}
			}
			if(this.Config[obj].reloadSign && CD_anchorCtrl.Trigger.childNodes[0].nodeValue.indexOf(this.Config[obj].reloadSign)==-1){
				CD_anchorCtrl.Trigger.childNodes[0].nodeValue+=this.Config[obj].reloadSign;
			}
		}
	},

	Query:function(obj){
		this.xmlHttpObject[obj]=null;
		try{
			this.xmlHttpObject[obj]=new XMLHttpRequest();
		}catch(e){
			try{
				this.xmlHttpObject[obj]=document.implementation.createDocument("","",null);
			}catch(e){
				try{
					this.xmlHttpObject[obj]=new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try{
						this.xmlHttpObject[obj]=new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){
						return null;
					}
				}
			}
		}
		return this.xmlHttpObject[obj];
	},

/*_____use with other library_____*/
	withExtendDiv:function(obj){
		if(CD_extendDiv && CD_extendDiv.extended.length>=0){
			for(i=0;i<CD_extendDiv.extended.length;i++){
				if(CD_extendDiv.extended[i]==obj){
					obj='extendDiv-content'+obj;
				}
			}
		}
		return obj;
	}
}


/*Window scroll*/
var CD_pageScroll={
	timer:'',
	moveEnd:true,
	speed:6,

	move:function(obj,pos){
		switch(pos){
			case "x":
				this.moveX(obj)
			break;
			case "y":
				this.moveY(obj)
			break;
		}
		return false;
	},

	moveX:function(obj){
		if(this.moveEnd){
			this.moveEnd=false;
			if($(obj).offsetLeft<CD_core._scrollX()){
				this.timer=setInterval('CD_pageScroll.right("'+obj+'")',33);
			}
			if($(obj).offsetLeft>CD_core._scrollX()){
				this.timer=setInterval('CD_pageScroll.left("'+obj+'")',33);
			}
		}
	},

	moveY:function(obj){
		if(this.moveEnd){
			this.moveEnd=false;
			if($(obj).offsetTop<CD_core._scrollY()){
				this.timer=setInterval('CD_pageScroll.upto("'+obj+'")',33);
			}
			if($(obj).offsetTop>CD_core._scrollY()){
				this.timer=setInterval('CD_pageScroll.down("'+obj+'")',33);
			}
		}
		return false;
	},

	upto:function(obj){
		var tY=$(obj).offsetTop;
		var sY=CD_core._scrollY();
		if(sY-tY<0){
			clearInterval(this.timer);
			this.moveEnd=true;
			return;
		}
		var mY=Math.floor((sY-tY)/this.speed);
		var set=(mY>=1)?sY-mY:tY;
		window.scrollTo(CD_core._scrollX(),set);
		if(tY==sY){
			clearInterval(this.timer);
			this.moveEnd=true;
		}
	},

	down:function(obj){
		var tY=((CD_core._documentHeight()-($(obj).offsetTop+$(obj).offsetHeight))<CD_core._windowHeight())?$(obj).offsetTop+$(obj).offsetHeight-CD_core._windowHeight():$(obj).offsetTop;
		var sY=CD_core._scrollY();
		if(tY-sY<0){
			clearInterval(this.timer);
			this.moveEnd=true;
			return;
		}
		var mY=Math.floor((tY-sY)/this.speed);
		var set=(mY>=1)?sY+mY:tY;
		window.scrollTo(CD_core._scrollX(),set);
		if(tY==sY){
			clearInterval(this.timer);
			this.moveEnd=true;
		}
	},

	right:function(obj){
		var tY=$(obj).offsetLeft;
		var sY=CD_core._scrollX();
		if(sY-tY<0){
			clearInterval(this.timer);
			this.moveEnd=true;
			return;
		}
		var mY=Math.floor((sY-tY)/this.speed);
		var set=(mY>=1)?sY-mY:tY;
		window.scrollTo(set,CD_core._scrollY());
		if(tY==sY){
			clearInterval(this.timer);
			this.moveEnd=true;
		}
	},

	left:function(obj){
		var tY=((CD_core._documentWidth()-($(obj).offsetLeft+$(obj).offsetLeft))<CD_core._windowWidth())?$(obj).offsetLeft+$(obj).offsetWidth-CD_core._windowWidth():$(obj).offsetLeft;
		var sY=CD_core._scrollX();
		if(tY-sY<0){
			clearInterval(this.timer);
			this.moveEnd=true;
			return;
		}
		var mY=Math.floor((tY-sY)/this.speed);
		var set=(mY>=1)?sY+mY:tY;
		window.scrollTo(set,CD_core._scrollY());
		if(tY==sY){
			clearInterval(this.timer);
			this.moveEnd=true;
		}
	}
}



/*______________EXECUTE______________*/
//CD.Load();
