/*
	Example call of the function:
	
	getStyle(document.getElementById("container"), "font-size");
*/
var hexVal;

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
		if (/^\s*rgb\s*\(/.test(strValue)) {
            strValue = rgbToHex(strValue);
         }
		//alert(strValue);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
		//alert(strValue);
		strValue = strValue.substring(1);
	}
	return strValue;
}
function rgbToHex(value) {
  if (typeof value !== "string") {
	 return false;
  }
  // Search for a pattern containing rgb followed by three sets of digits.
  var result = value.match(/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*/);
  if (result == null) { 
	 return value; 
  }
  // Use unary operator to force type conversion of result from string to digit.
  var rgb = +result[1] << 16 | +result[2] << 8 | +result[3];
  var hex = "";
  // Convert digits to hex value.
  var digits = "0123456789abcdef";
  while (rgb != 0) { 
	  hex = digits.charAt(rgb&0xf) + hex; 
	  rgb >>>= 4; 
  } 
  while (hex.length < 6) { 
	 hex = '0' + hex; 
  }
  // Don't forget to add this to the front of the value!
  
  return hex;
}