/* Created by Martin Hintzmann 2008 martin [a] hintzmann.dk
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 *
 * Version: 0.1
 *
 * Requires:
 *   jQuery 1.2+
 */
(function($) {
	$.fn.boxShadow = function(xOffset, yOffset, blurRadius, shadowColor) {
		if (!$.browser.msie) return;
		return this.each(function(){
			$(this).css({
				position:	"relative",
				zoom: 		1,
				zIndex:		"2"
			});
			$(this).parent().css({
					position:	"relative"
			});
			
			var div=document.createElement("div");
			$(this).parent().append(div);

			var _top, _left, _width, _height;
			if (blurRadius != 0) {
				$(div).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelRadius="+(blurRadius)+", enabled='true')");
				offsets = $(this).offset();
				_top = 		offsets.top-yOffset-(blurRadius/2)-1;
				_left =		offsets.left-xOffset-(blurRadius/2)-1;
				_width =	$(this).outerWidth(true)+blurRadius+1;
				_height =	$(this).outerHeight(true)+blurRadius+1;
			} else {
				_top = 		yOffset;
				_left =		xOffset;
				_width = 	$(this).outerWidth(true);
				_height = 	$(this).outerHeight(true);
			}
			$(div).css({
				top: 			_top,
				left:			_left,
				width:		_width,
				height:		_height,
				background:	shadowColor,
				position:	"absolute",
				zIndex:		1
			});
			
	  });
	};
})(jQuery);
(function($){$.extend({dropCurves:new function(){function doMask(s){s.ctx.save();s.ctx.translate(s.x+s.bSize,s.y+s.bSize);s.w-=s.bSize*2;s.h-=s.bSize*2;_doCorners(s);s.w+=s.bSize*2;s.h+=s.bSize*2;s.ctx.fillStyle=s.cl;s.ctx.fill();s.ctx.restore();s.ctx.clip();}function doShadow(s){s.ctx.save();s.ctx.translate(s.sX,s.sY);_doCorners(s);s.ctx.closePath();s.ctx.fillStyle=s.sColor;s.ctx.globalAlpha=s.o;s.ctx.fill();s.ctx.restore();}function doBorder(s){s.ctx.save();s.ctx.translate(s.x,s.y);_doCorners(s);s.ctx.closePath();s.ctx.fillStyle=s.cl=s.bColor;s.ctx.fill();s.ctx.restore();}function _doCorners(s){s.ctx.beginPath();s.ctx.moveTo(0,s.r);s.ctx.lineTo(0,s.h-s.r);s.ctx.quadraticCurveTo(0,s.h,s.r,s.h);s.ctx.lineTo(s.w-s.r,s.h);s.ctx.quadraticCurveTo(s.w,s.h,s.w,s.h-s.r);s.ctx.lineTo(s.w,s.r);s.ctx.quadraticCurveTo(s.w,0,s.w-s.r,0);s.ctx.lineTo(s.r,0);s.ctx.quadraticCurveTo(0,0,0,s.r);}function _setPos(s){s.x=(s.sX<0?s.x-s.sX:s.x);s.y=(s.sY<0?s.y-s.sY:s.y);s.sX=(s.sX>0?s.sX:0);s.sY=(s.sY>0?s.sY:0);}function _draw(s){_setPos(s);if(s.s)doShadow(s);if(s.bSize>0)doBorder(s);doMask(s);s.ctx.drawImage(s.el,s.x+s.bSize,s.y+s.bSize,s.w-(s.bSize*2),s.h-(s.bSize*2));}this.construct=function(s){var cv,attr,clazz,id,w,h,sX,sY,st;this.each(function(){if(this.tagName!='IMG')return;$(this).load(function(){st={el:this,ctx:null,w:$(this).width(),h:$(this).height(),x:0,y:0,bSize:4,bColor:'#f00',s:true,sX:-4,sY:-2,sColor:'#000',blur:0,o:0.5,r:20,cl:'#000'};attr='id="'+this.id+'" class="'+this.className+'" name="'+$(this).attr('name')+'"';if(typeof s!=undefined){for(o in s){st[o]=s[o];}}sX=Math.abs(st.sX);sY=Math.abs(st.sY);st.bSize=Math.abs(st.bSize);w=st.w+sX;h=st.h+sY;if($.browser.msie){cv=document.createElement('<v:roundrect arcsize="'+((st.r/100)-.06)+'" strokeweight="'+st.bSize+'" strokecolor="'+st.bColor+'" style="width:'+st.w+'px; height:'+st.h+'px;"></v:roundrect>');cv.appendChild(document.createElement('<v:fill type="frame" src="'+this.src+'" />'));if(st.s)cv.appendChild(document.createElement('<v:shadow on="True" color="'+st.sColor+'" opacity="'+st.o+'" offset="'+st.sX+'px,'+st.sY+'px" />'));$(this).replaceWith(cv);}else{cv=$('<canvas '+attr+' width="'+w+'" height="'+h+'"></canvas>');$(this).replaceWith(cv);st.ctx=cv[0].getContext('2d');_draw(st);}});});}}});$.fn.extend({dropCurves:$.dropCurves.construct});})(jQuery);

