// JavaScript Document
(function($) {
		  
		  $.fn.marquee = function(a){
			  
			  if(typeof(a)=='undefined') a = {};
			  
			  var settings=defaultSettings();
			  
		      $.extend(settings,a);
			  
			  var b=0,speed=0,id=$(this).attr("id");
			  
			  var id=document.getElementById(id);
			  
			  var thisthml=$(this).html();
			  if(settings.type=='left'||settings.type=='right'){
				  
			  var html='<table border="0" cellspacing="0" cellpadding="0"><tr><td id="id1">'+thisthml+'</td><td id="id2">'+thisthml+'</td></tr></table> ';
			  }else if(settings.type=='top'||settings.type=='bottom'){
				 var html='<table border="0" cellspacing="0" cellpadding="0"><tr><td id="id1">'+thisthml+'</td></tr><tr><td id="id2">'+thisthml+'</td></tr></table> '; 
				  
				  }
			  $(this).html(html);
			  
			  if(settings.speed=='') speed=15; else speed=settings.speed;
			  
			  if(settings.type!=''&&settings.istrue){
				  
				 
				  
				  switch (settings.type){
					  
					  case 'left':
					   
					  var MyMar=setInterval(function(){
						  
						  if($('#id2').width()-id.scrollLeft ==0){
							  
							   id.scrollLeft-=$('#id1').width(); 
							   
							   }else{ 
							   
							   id.scrollLeft++;
							   
							   }  
							   
							   },speed);
					  
					  id.onmouseover=function() {clearInterval(MyMar)} 
					  
                      id.onmouseout=function() {
						  
						  MyMar=setInterval(function(){
							  
							  if($('#id2').width()-id.scrollLeft ==0)
							  { 
							  
							  id.scrollLeft-=$('#id1').width(); 
							  
							  }
							  else{
								  
								   id.scrollLeft++;
								   
								   }
								   
								     },speed);} 

					  break;
					  
					  case 'right':
					  
					  var MyMar=setInterval(function(){
						  					  
						  if(id.scrollLeft ==0){
							  
							   id.scrollLeft=$('#id1').width(); 
							   
							   }else{ 
							   
							   id.scrollLeft--;
							   
							   }  
							   
							   },speed);
					  
					  id.onmouseover=function() {clearInterval(MyMar)} 
					  
                      id.onmouseout=function() {
						  
						  MyMar=setInterval(function(){
							  
							  if(id.scrollLeft ==0){
							  
							   id.scrollLeft=$('#id1').width(); 
							   
							   }else{ 
							   
							   id.scrollLeft--;
							   
							   }  
								   
								     },speed);} 
					  
					  break;
					  
					  case 'top':
					  
					  var MyMar=setInterval(function(){
						  
						  if($('#id1').width()-id.scrollTop ==0){
							  
							   id.scrollTop-=$('#id1').width(); 
							   
							   }else{ 
							   
							   id.scrollTop++;
							   
							   }  
							   
							   },speed);
					  
					  id.onmouseover=function() {clearInterval(MyMar)} 
					  
                      id.onmouseout=function() {
						  
						  MyMar=setInterval(function(){
							  
							  if($('#id1').height()-id.scrollTop ==0)
							  { 
							  
							  id.scrollTop-=$('#id1').height(); 
							  
							  }
							  else{
								  
								   id.scrollTop++;
								   
								   }
								   
								     },speed);} 

					   					  
					  break;
					  
					  
					  case 'bottom':
					  
					  var MyMar=setInterval(function(){
						  					  
						  if(id.scrollTop ==0){
							  
							   id.scrollLeft=$('#id1').height(); 
							   
							   }else{ 
							   
							   id.scrollTop--;
							   
							   }  
							   
							   },speed);
					  
					  id.onmouseover=function() {clearInterval(MyMar)} 
					  
                      id.onmouseout=function() {
						  
						  MyMar=setInterval(function(){
							  
							  if(id.scrollTop ==0){
							  
							   id.scrollLeft=$('#id1').height(); 
							   
							   }else{ 
							   
							   id.scrollTop--;
							   
							   }  
								   
								     },speed);} 

					  
					  break;
					  
					  
					  
					  }
				  
				  
				  
				  
				  
				  
				  
				  
				  }
			 
			 };
			 
			 

			 
			 var defaultSettings=function() {
					return {
						type:'left',		//类型（left,right,top,bottom）
						speed:15,           //滚动速度
						istrue: true	    //是否启用插件
					}
				};
			  
			  })(jQuery);



