/*
(function ($) {
	$.event.special.load = {
		add: function (hollaback) {
			if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
				// Image is already complete, fire the hollaback (fixes browser issues were cached
				// images isn't triggering the load event)
				if ( this.complete || this.readyState === 4 ) {
					hollaback.handler.apply(this);
				}

				// Check if data URI images is supported, fire 'error' event if not
				else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
					$(this).trigger('error');
				}
				
				else {
					$(this).bind('load', hollaback.handler);
				}
			}
		}
	};
}(jQuery));
*/

(function(jQuery) {
	jQuery.fn.shadow = function(options) {	
		var opts = jQuery.extend({}, jQuery.fn.shadow.defaults, options);
		
		return this.each(function() {	 
			var o = jQuery.meta ? jQuery.extend({}, opts, JQuery.data()) : opts;
			
			var html_before = "";
			var html_after = "";
			
			if ((o.top)) {
				var class_extra = "";
				html_before += '<div class="shadow-top-' + o.width + '">';
				
				if (o.top && o.left) {
					class_extra += " ext-left";
					html_before += '<div class="shadow-t-l-' + o.width + '"></div>';
				}
				if (o.top && o.right) {
					class_extra += " ext-right";
					html_before += '<div class="shadow-t-r-' + o.width + '"></div>';
				}
				
				html_before += '<div class="shadow-t-' + o.width + class_extra + '"></div>';
				
				html_before += '</div>';
			}
			
			
			if (o.left) {
				html_before += '<div class="shadow-left-' + o.width + '">';	
				html_after += '</div>';	
			}
			if (o.right) {
				html_before += '<div class="shadow-right-' + o.width + '">';	
				html_after += '</div>';	
			}
			
			if ((o.bottom)) {
				var class_extra = "";
				html_after += '<div class="shadow-bottom-' + o.width + '">';
				
				if (o.bottom && o.left) {
					class_extra += " ext-left";
					html_after += '<div class="shadow-b-l-' + o.width + '"></div>';
				}
				if (o.bottom && o.right) {
					class_extra += " ext-right";
					html_after += '<div class="shadow-b-r-' + o.width + '"></div>';
				}
				
				html_after += '<div class="shadow-b-' + o.width + class_extra + '"></div>';
				
				html_after += '</div>';
			}

			
			var html_current = jQuery.trim(jQuery(this).html());
			
			
			jQuery(this).html(html_before + html_current + html_after);
		});
	};
	
	jQuery.fn.shadow.defaults = {
			top: true,
			right: true,
			bottom: true,
			left: true,
			width: 9
	};
 })(jQuery);

jQuery(document).ready(function(){
	jQuery("li.widget_nav_menu").shadow();
	jQuery("li.widget_links").shadow();
	jQuery("li.widget_search div").shadow();
	jQuery("#title").shadow({top: false});
	jQuery("#posts-container").shadow();
	
	/*
	jQuery("div.post-image img").load(function() {
		var img_width = jQuery(this).width() + 44;
		jQuery(this).parent('div.post-image').width(img_width).shadow();
	});
	
	jQuery("div.page table td img").load(function() {
		var img_width = jQuery(this).width() + 9;
		var wrapper = jQuery("<div />");
		wrapper.width(img_width);
		jQuery(this).wrap(wrapper);
		jQuery(this).parent().shadow({top: false, left: false});
	});
	
	jQuery("li.adrotate_widget img").load(function() {
		var img_width = jQuery(this).width() + 9;
		var wrapper = jQuery("<div />");
		wrapper.width(img_width);
		jQuery(this).parent().wrap(wrapper).shadow({left: false});
	});
	*/
	
	jQuery("#slideshow-container").shadow();
});

$(window).load(function () {
	jQuery("div.post-image img").each(function() {
		var img_width = jQuery(this).width() + 44;
		jQuery(this).parent('div.post-image').width(img_width).shadow();
	});
	
	jQuery("div.page table td img").each(function() {
		var img_width = jQuery(this).width() + 9;
		var wrapper = jQuery("<div />");
		wrapper.width(img_width);
		jQuery(this).wrap(wrapper);
		jQuery(this).parent().shadow({top: false, left: false});
	});
	
	jQuery("li.adrotate_widget img").each(function() {
		var img_width = jQuery(this).width() + 9;
		var wrapper = jQuery("<div />");
		wrapper.width(img_width);
		jQuery(this).parent().wrap(wrapper).shadow({left: false});
	});
})

