//###############################################################################################
//###############################################################################################
//##											       ##
//## << RGB-Color Class V1.0 by Uhu >>							       ##
//##											       ##
//## Fri, August 6th, 1999								       ##
//##											       ##
//## !! Requires conversion.js !!							       ##
//##											       ##
//##-------------------------------------------------------------------------------------------##
//##											       ##
//## Constructors:	RGBcolor(r, g, b, numberFormat) [ red, green, blue values, "D"/"H"  ]  ##
//## 			RGBcolor(RGBcode) [ color values like "RRGGBB" 			    ]  ##
//##											       ##
//## Properties:	r.decValue [ red Component, decimal format       		    ]  ##
//##			r.hexValue [ red Component, hexadecimal format   		    ]  ##
//##			g.decValue [ green Component, decimal format     		    ]  ##
//##			g.hexValue [ green Component, hexadecimal format 		    ]  ##
//##			b.decValue [ blue Component, decimal format      		    ]  ##
//##			b.hexValue [ blue Component, hexadecimal format  		    ]  ##
//##											       ##
//## Methods:		r.setColor(colorValue, numberFormat) [ set new red value, "D"/"H"   ]  ##
//##			g.setColor(colorValue, numberFormat) [ set new green value, "D"/"H" ]  ##
//##			b.setColor(colorValue, numberFormat) [ set new blue value, "D"/"H"  ]  ##
//##											       ##
//##			setColor(r, g, b, numberFormat) [ set all color values, "D"/"H"     ]  ##
//##			setColor(RGBcode) [ set all color values like "RRGGBB", "D"/"H"     ]  ##
//##											       ##
//##			getRGBcode(prefixed) [ get color code like "RRGGBB", "#" true/false ]  ##
//##											       ##
//##-------------------------------------------------------------------------------------------##
//##											       ##
//## Uhu's Anime Zone:	http://www.anizone.de						       ##
//##			http://www.geocities.com/Tokyo/Flats/2711			       ##
//##			http://kei.animenetwork.com/anime/uhu				       ##
//##											       ##
//## Lum's World:	http://www.lumsworld.com					       ##
//##											       ##
//## ShampooCat's Cafe:	http://kei.animenetwork.com/ranma/catcafe			       ##
//##											       ##
//###############################################################################################
//###############################################################################################

function ColorComponent (colorValue, numberFormat) {
	if (numberFormat.toUpperCase()=="D") {
		colorValue=Math.floor(parseInt(colorValue.substring(0, 3)));
		this.decValue=colorValue;
		this.hexValue=fillZero(decToHex(colorValue), 2);
	}
	else {
		colorValue=colorValue.substring(0, 2);
		this.decValue=parseInt(hexToDec(colorValue));
		this.hexValue=fillZero(colorValue.toUpperCase(), 2);
	}

	this.setColor=setColor;

}

	function setColor(colorValue, numberFormat) {
		if (numberFormat.toUpperCase()=="D") {
			colorValue=Math.floor(parseInt(colorValue.toString().substring(0, 3)));
			this.decValue=colorValue;
			this.hexValue=fillZero(decToHex(colorValue), 2);
		}
		else {
			colorValue=colorValue.toString().substring(0, 2);
			this.decValue=parseInt(hexToDec(colorValue));
			this.hexValue=fillZero(colorValue.toUpperCase(), 2);
		}
	}

//-----------------------------------------------------------------------------------------------

function RGBcolor (r, g, b, numberFormat) {

	if (RGBcolor.arguments.length<4) {
		if (r.charAt(0)=="#") {offset=1} else offset=0;
		this.r=new ColorComponent(r.substring((0+offset), (2+offset)), "H");
		this.g=new ColorComponent(r.substring((2+offset), (4+offset)), "H");
		this.b=new ColorComponent(r.substring((4+offset), (6+offset)), "H");
	}
	else {
		this.r=new ColorComponent(r, numberFormat);
		this.g=new ColorComponent(g, numberFormat);
		this.b=new ColorComponent(b, numberFormat);
	}
	this.setColor=setRGBColor;
	this.getRGBcode=getRGBcode;

}

	function setRGBColor(r, g, b, numberFormat) {
		if (setRGBColor.arguments.length<4) {
			if (r.charAt(0)=="#") {offset=1} else offset=0;
			this.r.setColor(r.substring((0+offset), (2+offset)), "H")
			this.g.setColor(r.substring((2+offset), (4+offset)), "H")
			this.b.setColor(r.substring((4+offset), (6+offset)), "H")
		}
		else {
			this.r.setColor(r, numberFormat);
			this.g.setColor(g, numberFormat);
			this.b.setColor(b, numberFormat);
		}
	}

	function getRGBcode(prefixed) {
		if (prefixed) return("#"+this.r.hexValue+this.g.hexValue+this.b.hexValue);
		else return(this.r.hexValue+this.g.hexValue+this.b.hexValue);
	}
