// Convert "#000" to "rgb('0', '0', '0')". Return rgb(...) value.
function HexToRgb(HexValue){
	
	// Remove "#" from string [iff in string]
	HexValue = cutHex(HexValue);
	
	// Adjust '###' to '######'
	if(HexValue.length == 3){
		
		// Break out "###" to "#", "#", "#"
		var tempA = HexValue.substring(0,1);
		var tempB = HexValue.substring(1,2);
		var tempC = HexValue.substring(2,3);
		
		// Combine temp var's to form "######"
		HexValue = tempA+tempA+tempB+tempB+tempC+tempC;

	}
	
	// Call functions to go from hex to R, G, and B
	R = HexToR(HexValue);
	G = HexToG(HexValue);
	B = HexToB(HexValue);
	
	function HexToR(h) {
		return parseInt((h).substring(0,2),16);
	}
	
	function HexToG(h) {
		return parseInt((h).substring(2,4),16);
	}
	
	function HexToB(h) {
		return parseInt((h).substring(4,6),16);
	}
	
	function cutHex(h) {
		if(h.length == 4)
			return (h.charAt(0)=="#") ? h.substring(1,4):h;
		else
			return (h.charAt(0)=="#") ? h.substring(1,7):h;
	}
	
	// Combine result of Hex conversions above to form rgb(...) value
	var RgbResult = "rgb("+R+", "+G+", "+B+")";
	
	// Return resulting rgb(...) value
	return RgbResult;
	
}

