 
/**
 * 作者：whl
 * 日期：2009-9-25
 * 功能：使图片变大效果
 */
 
/*
 
 *	用法： $(".img").style({size:50,speed:300});
 *  说明:  .img 是图片的 class

 *  例: 
 *   $(function(){     $(".img").style({size:50,speed:300});         });
 *	
 *
 */
(function($) {
	

	$.fn.style = function(options){
	  
		// default configuration properties
		var defaults = {			
			zoom: 		true,
			fade: 		false,
			speed: 		100,
			size:		30

		}; 
		
		var options = $.extend(defaults, options);  
		
		
		//alert(options);
		speed = options.speed;
		size  = options.size;

		this.each(function() {  

			var obj = $(this); 	

			var actualWidth = this.offsetWidth;
			var actualHeight = this.offsetHeight;


			//alert( 'actual: x='+actualWidth+',h='+actualHeight );
			if( actualWidth < 10 ){
				var w = 120;
				var h = 120;
				
				return;
				//获取元素绝对高度
				var offset = obj.offset();

			}else{
				var w = actualWidth;
				var h = actualHeight;	
				//获取元素绝对高度
				var offset = obj.offset();
			}

			//alert( 'affter: x='+w+',h='+h );


			//alert( actualWidth );
			//alert( actualHeight );

 			//var w = obj.width(); 
			//var h = obj.height(); 
			


			
			/**
			 * 设置CSS样式
			 */
			obj.css('position','absolute');
			obj.css('top',offset.top);
			obj.css('left',offset.left);

			obj.mouseover(function(){
				obj.animate(
					{ width: w+size,height:h+size,top:offset.top-size/2,left:offset.left-size/2 }, 
					speed
				);	
			});

			obj.mouseout(function(){
				obj.animate(
					{ width: w,height:h,top:offset.top,left:offset.left  }, 
					speed
				);	
			});


		});
 
	  
	};

})(jQuery);



