<?xml version="1.0" encoding="utf-8"?>
<!-- XBL Fantasy Color 0.9 版				-->
<!-- 作者：心藍 Dennis hkdennis2k@yahoo.com.hk		-->
<!-- http://hkdennis2k.virtualave.net			-->
<!-- 感謝各位使用，有任何建議歡迎來信！			-->
<bindings xmlns="http://www.mozilla.org/xbl">
	<binding id="fantasy">
		<implementation>
			<property name="RainbowColorH">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v)){
						if(this.__o>=this.__f){
							if((v>=this.__f)&&(v<=this.__o))	this.__h=val;
							}else if((v>=this.__f)||(v<=this.__o)){
								if(v>359){	v-=359;
								}else if(v<0){	v=360+v;
							}
							this.__h=v;
						}
						if(this.__h!=v){
							if(this.__m){
								this.__h=Math.max(0,Math.min(v,359));
								this.__r=-this.__r;
								if(this.__l>-1){
									this.__l-=0.5;
									if(this.__l<=0)this.RainbowStop(true);
								}
							}else{	
								this.__h=v+((this.__r>0)?this.__f-this.__o:this.__o-this.__f);
								if(this.__l>-1){
									this.__l-=1;
									if(this.__l<=0)this.RainbowStop(true);
								}
							}
						}
					}
					return this.__h;
				]]></setter>
				<getter>
					return this.__h;
				</getter>
			</property>
			<property name="RainbowColorV">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v))this.__v=Math.max(0,Math.min(v,255));
					return this.__v;
				]]></setter>
				<getter>
					return this.__v}
				</getter>
			</property>
			<property name="RainbowColorS">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v))this.__s=Math.max(0,Math.min(v,255));
					return this.__s;
				]]></setter>
				<getter>
					return this.__s}
				</getter>
			</property>
			<property name="RainbowSpeed">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v)){
						v=Math.max(1,Math.min(v,200));
						if(this.__u){
							clearInterval(this.__u);
							var tmp=this;
							this.__u=setInterval(function(){tmp.RainbowRun()},v);
						}
					}
					return this.__p=v;
				]]></setter>
				<getter>
					return this.__p}
				</getter>
			</property>
			<property name="RainbowRate">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v))this.__e=this.__r=Math.max(-179,v%180);
					return this.__r;
				]]></setter>
				<getter>
					return this.__r}
				</getter>
			</property>
			<property name="RainbowRunning">
				<setter><![CDATA[
					var v=val;
					if(v==0)v=false;
					switch(String(v).toLowerCase()){
						case '0':
						case 'false':
						case 'no':	if(this.__u)this.RainbowStop();		break;
						default:	if(!this.__u)this.RainbowStart();	break;
					}
					return this.__u!=false;
				]]></setter>
				<getter>
					return this.__u!=false}
				</getter>
			</property>
			<property name="RainbowAuto">
				<setter><![CDATA[
					var v=val;
					if(v==0)v=false;
					switch(String(v).toLowerCase()){
						case '0':
						case 'false':
						case 'no':
							this.__a=false;
							try{
							this.removeEventListener('mouseover',	this.RainbowStart	,false);
							this.removeEventListener('mouseout',	this.RainbowStop	,false);
							}catch(e){}
							try{
							this.removeEventListener('focus',	this.RainbowStart	,false);
							this.removeEventListener('blur',	this.RainbowStop	,false);
							}catch(e){}
							break;
						default:
							this.__a=true;
							try{
							this.addEventListener('mouseover',	this.RainbowStart	,false);
							this.addEventListener('mouseout',	this.RainbowStop	,false);
							}catch(e){}
							try{
							this.addEventListener('focus',		this.RainbowStart	,false);
							this.addEventListener('blur',		this.RainbowStop	,false);
							}catch(e){}
					}
					return this.__a;
				]]></setter>
				<getter>
					return this.__a;
				</getter>
			</property>
			<property name="RainbowTarget">
				<setter><![CDATA[
					var v=val.toString();
					v=v.charAt(0).toLowerCase()=='b'?'backgroundColor':'color';
					if(this.RainbowRunning){
						clearInterval(this.__u);
						this.style[this.__t]='';
						this.__t=v;
						var tmp=this;
						this.__u=setInterval(function(){tmp.RainbowRun()},this.__p);
					}else{
						this.__t=v;
					}
					return this.__t;
				]]></setter>
				<getter>
					return this.__t;
				</getter>
			</property>
			<property name="RainbowFrom">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v))this.__f=Math.max(0,Math.min(v,359));
					return this.__f;
				]]></setter>
				<getter>
					return this.__f;
				</getter>
			</property>
			<property name="RainbowTo">
				<setter><![CDATA[
					var v=parseInt(val,10);
					if(!isNaN(v))this.__o=Math.max(0,Math.min(v,359));
					return this.__o;
				]]></setter>
				<getter>
					return this.__o;
				</getter>
			</property>
			<property name="RainbowBiMode">
				<setter><![CDATA[
					var v=val;
					if(v==0)v=false;
					switch(String(v).toLowerCase()){
						case '0':
						case 'false':
						case 'no':	this.__m=false;	break;
						default:	this.__m=true;
					}
					return this.__m;
				]]></setter>
				<getter>
					return this.__m;
				</getter>
			</property>
			<property name="RainbowLoop">
				<setter><![CDATA[
					var v=val;
					if(!isNaN(v))this.__k=this.__l=Math.max(-1,parseInt(v,10));
					return this.__k;
				]]></setter>
				<getter>
					return this.__l;
				</getter>
			</property>
			<method name="RainbowStart"><body><![CDATA[
				if(this.__u)return false;
				if(!isNaN(arguments[0])){	this.__l=Math.max(-1,parseInt(arguments[0],10));
				}else{				this.__l=this.__k;
				}
				var tmp=this;
				this.__u=setInterval(function(){tmp.RainbowRun()},this.__p);
				this.__onrainbowstart();
				return true;
			]]></body></method>
			<method name="RainbowStop"><body><![CDATA[
				if(!this.__u)return false;
				clearInterval(this.__u);
				try{
				this.style[this.__t]='';
				}catch(e){}
				this.__u=false;
				if(arguments[0]==true){
					this.__r=this.__e;
					this.__h=this.__f;
				}
				this.__onrainbowstop();
				return true;
			]]></body></method>
			<method name="RainbowRun"><body><![CDATA[
				this.RainbowUpdate();
				this.RainbowColorH=this.__h+this.__r;
				this.__onrainbowrun();
			]]></body></method>
			<method name="RainbowUpdate"><body><![CDATA[
				var R,G,B,E;
				if(this.__s==0){
					R=G=B=this.__v;
				}else{ 
					var t1=this.__v;
					var t2=(255-this.__s)*this.__v/255;
					var t3=(t1-t2)*(this.__h%60)/60;
					if(this.__h<60){	R=t1;	G=t2+t3;B=t2;
					}else if(this.__h<120){	R=t1-t3;G=t1;	B=t2;
					}else if(this.__h<180){	R=t2;	G=t1;	B=t2+t3;
					}else if(this.__h<240){	R=t2;	G=t1-t3;B=t1;
					}else if(this.__h<300){	R=t2+t3;G=t2;	B=t1;
					}else if(this.__h<360){	R=t1;	G=t2;	B=t1-t3;
					}else{			R=0;	G=0; 	B=0;
					}
				}
				try{
					this.style[this.__t]='rgb('+
						Math.max(0,Math.min(Math.floor(R),255))+','+
						Math.max(0,Math.min(Math.floor(G),255))+','+
						Math.max(0,Math.min(Math.floor(B),255))+')';
				}catch(e){}
			]]></body></method>
			<property name="onrainbowstart">
				<setter><![CDATA[
					if((typeof val=='string')||(val.constructor==String)){
						this.__onrainbowstart=new Function(val);
					}else if((typeof val=='function')||(val.constructor==Function)){
						this.__onrainbowstart=val;
					}else{
						this.__onrainbowstart=new Function(val.toString());
					}
					return this.__onrainbowstart;
				]]></setter>
				<getter>
					return this.__onrainbowstart;
				</getter>
			</property>
			<property name="onrainbowstop">
				<setter><![CDATA[
					if((typeof val=='string')||(val.constructor==String)){
						this.__onrainbowstop=new Function(val);
					}else if((typeof val=='function')||(val.constructor==Function)){
						this.__onrainbowstop=val;
					}else{
						this.__onrainbowstop=new Function(val.toString());
					}
					return this.__onrainbowstop;
				]]></setter>
				<getter>
					return this.__onrainbowstop;
				</getter>
			</property>
			<property name="onrainbowrun">
				<setter><![CDATA[
					if((typeof val=='string')||(val.constructor==String)){
						this.__onrainbowrun=new Function(val);
					}else if((typeof val=='function')||(val.constructor==Function)){
						this.__onrainbowrun=val;
					}else{
						this.__onrainbowrun=new Function(val.toString());
					}
					return this.__onrainbowrun;
				]]></setter>
				<getter>
					return this.__onrainbowrun;
				</getter>
			</property>
			<constructor><![CDATA[
				this.__h	=0;
				this.__v	=255;
				this.__s	=128;
				this.__r	=10;
				this.__e	=10;
				this.__p	=50;
				this.__a	=true;
				this.__u	=false;
				this.__t	='color';
				this.__f	=0;
				this.__o	=359;
				this.__m	=false;
				this.__l	=-1;
				this.__k	=-1;
				this.__onrainbowstart	=function(){};
				this.__onrainbowstop	=function(){};
				this.__onrainbowrun	=function(){};
				var q=[	"RainbowColorH"	,"RainbowColorV"	,"RainbowColorS"	,"RainbowRate",
					"RainbowRunning","RainbowAuto"		,"RainbowTarget"	,"RainbowFrom",
					"RainbowTo"	,"RainbowBiMode"	,"RainbowLoop"		,
					"onrainbowstart","onrainbowstop"	,"onrainbowrun"];
				var i=0;
				for(i=0;i<q.length;i++){
					try{
						if(typeof this.attributes[q[i]]!='undefined')
							this[q[i]]=this.attributes.getNamedItem(q[i]).nodeValue;
					}catch(e){
					}finally{
						this[q[i]]=this[q[i]];
					}
				}
			this.RainbowAuto=this.__a;
			]]></constructor>
		</implementation>
	</binding>
</bindings>