(function( $ ){

  $.fn.photoCorners = function() {  

    return this.each(function() {
    	
    	$(this).imagesLoaded(function() {
    	
			var $this = $(this);
			var imageSrc = $this.attr('src');
			var imageWidth = $this.width();
			var imageHeight = $this.height();
			
			$this.wrap('<div />');
			
			var $parent = $this.parent();
			
			$parent.prepend(
				'<div class="pc_image"><div class="pc_tl"><div class="pc_tr"><div class="pc_bl"><div class="pc_br"><img src="images/spacer.gif" alt="" width="1" height="1" border="0">'
			).append(
				'</div></div></div></div></div>'
			);
			
			$parent.find('.pc_image div').width(imageWidth).height(imageHeight);
			
			$parent.find('.pc_image').width(imageWidth).height(imageHeight).css('background', 'url('+imageSrc+') no-repeat left top');
			
			$this.remove();
			
    	});
    	
    });

  };
  
})( jQuery );
