function oneway_promo(options)
{
  // internal
  this.shift = 0;
  this.lock = false;
  this.id = 0;
  this.easing = 0;
  this.slide_speed = 0;
  this.delay_speed = 0;
  this.fade_speed = 0;
  this.cycling = 0;
  
  this.current = 0;
  
  this.border = function(sign)
  {
   this.lock = false; 
   sign == '+' ? this.shift++ : this.shift--;
   
   //this.btn_left.css('display', this.shift >= 0 ? 'none' : 'block');
   //this.btn_right.css('display', this.shift <= -(this.block_count-1) ? 'none' : 'block');
  }
  
  this.move = function(sign)
  {
   if(sign == '+' && this.current == 0)
   {
    //return;
	this.current = this.block_count-1;
	this.ribbon.css('left', -this.block_width*this.current);
   }

   if(sign == '-' && this.current == this.block_count-1)
   {
    //return;
	this.current = 0;
	this.ribbon.css('left', 0);
   }
	
   if(sign == '+')
    this.current--;
   else	
    this.current++;
	
   var obj = this;
   this.ribbon.stop(true).animate({left: -this.block_width*this.current}, this.slide_speed, this.easing, function(){obj.border(sign)}); 
  };

  this.scroll = function()
  {
   var obj = this;

   this.container.oneTime(this.delay_speed, this.id, function (){
   
   if(this.current == this.block_count-1 && !obj.cycling)
    return;

    obj.move('-');
	obj.scroll();
	
   });
  };

  this.button_clicked = function(sign)
  {
   this.container.stopTime(this.id);
   
   this.move(sign);
   this.scroll();
  };
  
  this.turn_on = function()
  {
   this.container.css('background', 'none 0 0');
   this.ribbon.css('display', 'block');
   this.btn_left.css('display', 'block');
   this.btn_right.css('display', 'block');
  };

  this.__construct = function(options)
  {
   this.id = options.id;
   if(!this.id)
   {
    document.write('ID not specified!<br />');
	return false;
   }
  
   var obj = this;
  
   // dom
   this.container = $('.ow_promo[pid='+this.id.toString()+']');
   this.ribbon = $('.ow_p_ribbon', this.container);
   this.btn_left = $('.ow_p_left', this.container);
   this.btn_right = $('.ow_p_right', this.container);
   
   //options
   this.easing = options.easing || 'linear';
   this.slide_speed = parseInt(options.slide_speed) || 300;
   this.delay_speed = parseInt(options.delay_speed) || 1000;
   this.fade_speed = parseInt(options.fade_speed) || 200;
   this.cycling = options.cycling;
   
   // sizes
   this.block_width = this.container.width();
   this.block_count = this.ribbon.children().length;
   
   $('.ow_p_cell', this.container).css('width', this.block_width);
   this.ribbon.css('width', this.block_count * this.block_width);
  
   // signals
   this.btn_left.bind('click', function(){obj.button_clicked('+')});
   this.btn_right.bind('click', function(){obj.button_clicked('-')});
   
   // init
   this.turn_on();
   this.scroll();
  };
  
  this.__construct(options);
};

/*
 $(document).ready(function(){
 
  //############################################################
  
  var ow_promo = $('.ow_promo');
  var ow_ribbon = $('.ow_p_ribbon');
  var ow_block_width = ow_promo.width();
  var ow_block_count = ow_ribbon.children().length;
  var ow_shift = 0;
  var ow_lock = false;
  
  function _ow_p_move(sign)
  {
   if(sign == '+' && ow_shift >= 0)
    return;

   if(sign == '-' && ow_shift <= -(ow_block_count-1))
    return;
	
   if(ow_lock)
    return;
   ow_lock = true;
 
   ow_ribbon.animate({left: sign+'='+ow_block_width.toString()}, _ow_p_slide_speed, _ow_p_easing, function(){ow_lock = false; sign == '+' ? ow_shift++ : ow_shift--;});
  }

  function _ow_p_scroll()
  {
   ow_promo.oneTime(_ow_p_delay_speed, 'SHIFT', function(){
   
    if(ow_shift <= -(ow_block_count-1))
	{
	 if(!_ow_p_cycling)
	  return;

	 ow_lock = true;
	 ow_ribbon.fadeOut(_ow_p_fade_speed, function(){ow_ribbon.css('left', 0)}).fadeIn(_ow_p_fade_speed);
	 ow_shift = 0;
	 ow_lock = false;
	}
    else
     _ow_p_move('-');
   
	_ow_p_scroll();
   });
  }
  
  function _ow_button_clicked(sign)
  {
   ow_promo.stopTime('SHIFT');
   
   _ow_p_move(sign);
   _ow_p_scroll();
  }
  
  function _ow_p_turn_on()
  {
   ow_ribbon.css('display', 'block');
   $('.ow_p_left').css('display', 'block');
   $('.ow_p_right').css('display', 'block');
  }

function _ow_p_preload_images()
{ 
  var d=document; 
  
  if(d.images)
  {
   if(!d.MM_p)
    d.MM_p=new Array();
   
   var i, j = d.MM_p.length, a = preloadImages.arguments; 
   
   for(i = 0; i < a.length; i++)
    if (a[i].indexOf("#")!=0)
	{
	 d.MM_p[j]=new Image;
	 d.MM_p[j++].src=a[i];
	}
  }
}
  
  $('.ow_p_cell').css('width', ow_block_width);
  ow_ribbon.css('width', ow_block_count * ow_block_width);
  
  $('.ow_p_left').bind('click', function(){_ow_button_clicked('+')});
  $('.ow_p_right').bind('click', function(){_ow_button_clicked('-')});
  
 //_ow_p_preload_images(<?=implode(',', $images)?>);
 _ow_p_turn_on();
 _ow_p_scroll();
  
 });
 */
