// @author xueyu 滚动广告
(function($){
		  $.fn.xScroll = function(param)
		  {
			  var defaults = {'width':400,'height':200,wpClass:'',interval:100};
			  defaults = $.extend(defaults,param);
			  var instance = this;
			  
			  var marginTp = defaults.height;
			  
			  return this.each(function(){
										var $this = $(this);
										var _wphtml = '<div class="'+defaults.wpClass+'" style="overflow:hidden; width:'+defaults.width+'px; height:'+defaults.height+'px;"></div>';
										$this.wrap(_wphtml);
										$this.css({'margin-top':marginTp});
										
										var contentH = $this.height();
										
										this.autoScroll = function(){
												marginTp--;
												if(marginTp==-contentH)
												{
													marginTp = defaults.height;
												}

												$this.css({'margin-top':marginTp});
				  							};
											
										var timerHandle = 	setInterval(this.autoScroll,defaults.interval);
										
										this.scrollStart = function(){ timerHandle = setInterval(this.autoScroll,defaults.interval);};
										
										this.scrollStop = function(){ clearInterval(timerHandle);};
										
										$this.mouseover(this.scrollStop);
										
										$this.mouseout(this.scrollStart);
										
										
										
										});
			  
		  };
		  
		  })(jQuery);
