/*
Version 1.1
Ne fonctionne pas pour Safari 2-, Opera 9.4-, Firefox 3.0-
A appeler dans jQuery(window).ready(function(){ });
Si l'élément n'est pas affiché (display: none) lors de l'appel à PastelShadow, il fera 0 de largeur et de hauteur, donc les textes qui suivent risquent de se superposer.

Exemple d'utilisation :
	jQuery(window).ready(function(){
		jQuery(".pastelShadow").PastelShadow(
			{
				x: 3,
				y: 3,
				blur: 5,
				color: "#999"
			}
		);
	});

*/



jQuery.fn.PastelShadow = function(option) {
	var x = option.x!=null?option.x:2;
	var y = option.y!=null?option.y:2;
	var blur = option.blur!=null?option.blur:3;
	var opacity = option.opacity!=null?option.opacity:0.3;
	var color = option.color!=null?option.color:'#000';
	
	if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 9) {
		jQuery(this).each(function(){
			var text = jQuery(this).html();
			var width = jQuery(this).width();
			var height = jQuery(this).height();
			var textAlign = jQuery(this).css('textAlign');
			
			jQuery(this).html('<div>');
			var jContainer = jQuery(this).children();
			jContainer.css('position', 'relative');
			if (width > 0 && height > 0)
				jContainer.css({
					'width': width,
					'height': height
				});

			var span=document.createElement("span");
			jQuery(span).html(text);
			jQuery(span).css({
				'position': 'absolute',
				'left': '0',
				'top': '0',
				'z-index': '1'
			});
			if (!(textAlign == ''))
				jQuery(span).css('textAlign', textAlign);
			if (width > 0 && height > 0)
				jQuery(span).css({
					'width': width,
					'height': height
				});
			jQuery(span).clone().prependTo(jContainer);

			jQuery(span).css({
				'color':		color,
				'z-index':	'0',
				'left':			Math.round(x/5) + "px",
				'top':			Math.round(y/5) + "px",
				'filter':		"progid:DXImageTransform.Microsoft.Blur(pixelradius="+Math.round(blur/2)+", enabled='true', makeShadow='true', ShadowOpacity="+opacity+")"
			});
			if (!(textAlign == ''))
				jQuery(span).css('textAlign', textAlign);
			if (width > 0 && height > 0)
				jQuery(span).css({
					'width': width,
					'height': height
				});
			jQuery(jContainer).append(span);
		});
	}
	else {
		jQuery(this).css('text-shadow', x+'px '+y+'px '+blur+'px '+color);
	}
};

jQuery(window).ready(function(){
		jQuery(".Shadow").PastelShadow(
			{
				x: 2,
				y: 2,
				blur: 3,
				color: "#999"
			}
		);
	});
