/* 
*	jQuery RGBA Fix For IE
*	Author: Jamie Knight
* 	Released into the public domain.
 */
(function($) {
	$.fn.RGBAFix = function() {
		
		if (!$.browser.msie) return;
		if($.browser.version > 8) return;
		
		return this.each(function(){
			
			var el = $(this);
			var HexString = el.ParseRGBA(this.currentStyle["background-color"]);
			
			if (HexString == null) return;
			
			el.css({
				background:		"transparent",
				filter:			"progid:DXImageTransform.Microsoft.gradient(startColorstr=" + HexString + ",endColorstr=" + HexString + ")"
			});
			
		});
	};
	
	/* Borrowed from textshadow plugin */
	$.fn.ParseRGBA = function(value) 
	{
		/*value = String(value)
			.replace(/^\s+|\s+$/gi, '')
			.replace(/\s*!\s*important/i, '')
			.replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3/$4)')
			.replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3)') */
		
		alert(value);
		
		//var HexStr		= "#801889F2";
		var HexStr		= "";
		
		var colour_opac	= 0.5;
		var colour_r	= 24;
		var colour_g	= 137;
		var colour_b	= 242;
		
		/*if (value.length > 1 || value[0].toLowerCase() != 'none') {
			value = value.replace(/\//g, ',');
			var color;
			if ( value.match(/(\#[0-9a-f]{6}|\#[0-9a-f]{3}|(rgb|hsb)a?\([^\)]*\)|\b[a-z]+\b)/i) && (color = RegExp.$1) ) {
				shadow.color = color.replace(/^\s+/, '');
				value = value.replace(shadow.color, '');
			}

			value = value
				.replace(/^\s+|\s+$/g, '')
				.split(/\s+/)
				.map(function(item) {
						return (item || '').replace(/^0[a-z]*$/, '') ? item : 0 ;
					});

			switch (value.length)
			{
				case 1:
					shadow.x = shadow.y = value[0];
					break;
				case 2:
					shadow.x = value[0];
					shadow.y = value[1];
					break;
				case 3:
					shadow.x = value[0];
					shadow.y = value[1];
					shadow.radius = value[2];
					break;
			}
			if ((!shadow.x && !shadow.y && !shadow.radius) || shadow.color == 'transparent') {
				shadow.x = shadow.y = shadow.radius = 0;
				shadow.color = null;
			}
		} */
		
		/* Convert all decimals into hexadecimal */
		colour_opac		= Math.floor((colour_opac * 255));
		colour_opac		= colour_opac.toString(16);
		colour_r		= colour_r.toString(16);
		colour_g		= colour_g.toString(16);
		colour_b		= colour_b.toString(16);
		
		HexStr			= "#" + colour_opac + colour_r + colour_g + colour_b;
		
		return HexStr;
	};
	
})(jQuery);
