(function($){
		  
   $.fn.maquee=function(options){
	   options = $.extend({
	      target:'',
		  direction:'left',
		  x : 10 ,
		  time : 10 ,
		  timer:false,
		  stop :false 
	   },options);
	   
	  options.target = $(options.target).get(0);
	  //options.width = $('table:first',options.target).width();
	  if(options.direction == 'right'){
	     $(this).mousedown(function(){
									try{clearTimeout(options.timer);}catch(e){}
									$(options.target).maquee_right(options);}); 	     
	  }else{
	     $(this).mousedown(function(){
									try{clearTimeout(options.timer);}catch(e){}
									$(options.target).maquee_left(options);}); 	
	  }
	  $(this).mouseup(function(){  clearTimeout(options.timer);});
	   
	  $(this).click(function(){return false;});
	    
   } 
   
   $.fn.maquee_right = function(options){
	    //alert($(options.target));
	  
	   $this = this;
       if( this.scrollLeft() + options.x > $('table:first',this).width() ){
	       try{
			   clearTimeout(options.timer);
			   return ;
		   }catch(e){}
	   } else {
	      this.scrollLeft(this.scrollLeft() + options.x);
	   }
	   
	   function runRight(){
		   $this.maquee_right(options);
	   }
	   options.timer = setTimeout(runRight , options.time);
   }
   
   $.fn.maquee_left = function(options){
	    //alert($(options.target));
	  
	   $this = this;
       if( this.scrollLeft() - options.x < 0 ){
	       try{
			   clearTimeout(options.timer);
			   return ;
		   }catch(e){}
	   } else {
	      this.scrollLeft(this.scrollLeft() - options.x);
	   }
	   
	   function runLeft(){
		   $this.maquee_left(options);
	   }
	   options.timer = setTimeout(runLeft , options.time);
   }
   
})(jQuery)
