/*
	このプラグインはDavid Walsh(http://davidwalsh.name)によって作成された
	dwProtectorを元にjQuery用プラグインに作り替えたものです。
	
	Class				:	ImageProtector
	BaseSourceAuthor	:   David Walsh
	RebuildAuthor		:	Takaaki Mizota
	Version				:	1.0
	URL					:	http://www.mizoochi.com/jquery/protecter
	Date				:	2008/08/20
	
	arguments
		image	:	set Image Path
		elements:	set XPath
		zIndex	:	Image z-index
	
	setting sample
		$(function(){
			$(".protect").dwProtector({
				image: "images/blank.gif",
				elements: jQuery(".protect"),
				zIndex: 5
			});
		});
	
*/


jQuery.fn.ImageProtector = function(setting){
	
	//setting
	config = jQuery.extend({
		image	: "blank.gif",
		elements: this,
		zIndex	: 10
	},setting);
	
	//protect
	function protect(config){
		var makers = config.elements;
		var img = '<img src="'+config.image+'" />';
		//
		jQuery.each(makers,function(){
			var my = jQuery(this);
			var w = my.width();
			var h = my.height();
			my.after(img).next().css({
				"position"	: "absolute",
				"width"		: w+"px",
				"height"	: h+"px",
				"margin-left"	: "-"+w+"px",
				"z-index"	: config.zIndex
			});
		});
		
	}
	protect(config);
};
