/*
* WaterImage
* @version 1.0
* @updated 2009-09-15
* @author abgne.tw http://abgne.tw/jquery-plugins/jquery_waterimage-1-0.html
* @requires jQuery 1.2.6 or later
* 
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/

;(function($){
	$.fn.waterimage = $.fn.waterImage = function(options){
		var opts = $.extend({}, $.fn.waterImage.defaults, options || {});

		return this.each(function(){
			var _this = $(this),
				_position = _this.position(),
				_height = _this.height(),
				_width = _this.width(),
				_alt = _this.attr('alt') || '';

			$('<img />').css({
				position: 'absolute',
				zIndex: opts.zIndex,
				top: _position.top,
				left: _position.left
			}).attr({
				className: opts.prex+'_img',
				src: opts.blank,
				height: _height,
				width: _width,
				title: _alt
			}).appendTo('body');
			
			if(opts.logo!=''){
				$('<div />').css({
					height: _height,
					width: _width,
					position: 'absolute',
					zIndex: opts.zIndex - 1,
					top: _position.top,
					left: _position.left,
					backgroundImage: 'url('+opts.logo+')',
					backgroundPosition: opts.position,
					backgroundRepeat: 'no-repeat'
				}).attr('className', opts.prex+'_logo').appendTo('body');
			}
		});
	};

	$.fn.waterImage.defaults = {
		blank: 'images/blank.gif',
		logo: '',
		position: 'bottom right',
		prex: 'waterImage',
		zIndex: 10000
	};
})(jQuery);
