( function ( $ ) {
	
	$.fn.addShaddow = function(  ) {
		var imgPath = '/ccds_tpl_img/shaddows/';
		
		return this.each( function() {
			
	var leftOffset = 0;
	var topOffset = 0;
	
			$this = $(this);
			
			var borderWidth = 11;
			var borderHeight = 9;
			
			
			// calculate object position
			var margin_left = $this.css('margin-left').replace('px','') * 1;
			var margin_top = $this.css('margin-top').replace('px','') * 1;
			
			var top = margin_top;
			var left = margin_left;
			var height = $this.height();
			var width = $this.width();
			
		
			
			
			var shaddows = {
				
				'l': {
					'background-image'			:	'url('+imgPath+'l.png)',
					'height' 					:	height + 'px',
					'top'						:	top + 'px',
					'left'						:	left - borderWidth  + 'px'
				},
				'r': {
					'background-image'			:	'url('+imgPath+'r.png)',
					'height'					:	height + 'px',
					'top'						:	top + 'px',
					'left'						:	left + width + 'px'
				},
				'b': {
					'background-image'			:	'url('+imgPath+'b.png)',
					'width'						:	width + 'px',
					'top'						:	top + height + 'px',
					'left'						:	left + 'px'
				},
				't': {
					'background-image'			:	'url('+imgPath+'t.png)',
					'width'						:	width + 'px',
					'top'						:	top - borderHeight + 'px',
					'left'						:	left + 'px'
				},
				'tr' : {
					'background-image'			:	'url('+imgPath+'tr.png)',
					'top'						:	top - borderHeight + 'px',
					'left'						:	left + width + 'px'
				},
				'tl' : {
					'background-image'			:	'url('+imgPath+'tl.png)',
					'top'						:	top - borderHeight + 'px',
					'left'						:	left - borderWidth + 'px'
				},
				'bl' : {
					'background-image'			:	'url('+imgPath+'bl.png)',
					'top'						:	top + height + 'px',
					'left'						:	left - borderWidth + 'px'
				},
				'br' : {
					'background-image'			:	'url('+imgPath+'br.png)',
					'top'						:	top + height + 'px',
					'left'						:	left + width + 'px'
				}
				
			};
			
			
			for (shaddow in shaddows) 
			{
				// check if shaddow element already exists
				var clazz = shaddow+'_shaddow';
				var tmp = $('.' + clazz, $this); 
				if( 0 < tmp.length  ) continue;
				
				// create new shaddow element and apply settings
				var elem = $('<div />').
				addClass(shaddow+'_shaddow').
				css(shaddows[shaddow]);
				
				$this.prepend(elem);
				
			}
  
			

			
		});
	};
	
})( jQuery );		





