/*
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.5;
	var color = option.color!=null?option.color:'#000';
	
	if (jQuery.browser.msie) { //  && parseInt(jQuery.browser.version) < 9 ???
		jQuery(this).each(function(){
			if (!(jQuery(this).children('.pastelShadow').length))
			{
				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 class="pastelShadow">');
				var jContainer = jQuery(this).children('.pastelShadow');
				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/2)-(blur/2) + "px",
					'top':			Math.round(y/2)-(blur/2) + "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('textShadow', x+'px '+y+'px '+blur+'px '+color);
	}
};
