function PromoBanner(divname, boxWidth, catid, zone, initial_promo_nr,max_promo_nr)
{
	this.divname = divname;
	this.boxWidth = boxWidth;
	//this.catid = catid;
	//this.zone = zone;
	//this.initial_promo_nr = initial_promo_nr;

	//this.nextBox = 4;
	this.currentBox = 3;
	this.scrollright = 1;
	this.boxRotationSpeed =  1000;
	this.userclicked = 0;
	//this.boxNumbers = 10000/this.boxWidth;

	this.rotate = function(action)
	{
		//if (this.initial_promo_nr < 3)
		//	return;
			
		
	if(action != "scroll")
	{
	this.userclicked = 1;
	}
		if( action == "inc" ) 
		{
		//	if (this.currentBox <= max_promo_nr-1)	
			this.currentBox++;
			
			if(this.scrollright<1) {this.scrollright =1;}
		}
		else
		if(action == "dec") 
		{
			if(this.scrollright>0) {this.scrollright =0;}

		//	if (this.currentBox >3)	
		this.currentBox--;
		}
		else
		if(action == "scroll")
		{
		if (this.userclicked>0)
		{
		 this.userclicked = 0;
		 return;
		}
		//alert(this.scrollright);
		if(this.scrollright>0)
				{this.currentBox++;}
					else
				{this.currentBox--;}
		}

		

	
//		if(this.currentBox > this.boxNumbers) 
//		{ this.currentBox--; return; }

		if(this.currentBox > max_promo_nr) 
		{ this.currentBox--;
		
		if (action =="scroll")
		{this.scrollright = 0;};
		
		//this.currentBox = max_promo_nr;
		//return;
		
		//$j('#'+this.divname).animate({"left": ((action == "inc") ? "+=" : "+=")  + this.boxWidth*(max_promo_nr-3) + "px"}, this.boxRotationSpeed*(max_promo_nr-3));

		/*for(var i=0;i<(max_promo_nr-3);i++)
		{
		
		$j('#'+this.divname).animate({"left": ((action == "inc") ? "+=" : "+=")  + this.boxWidth + "px"}, this.boxRotationSpeed/(max_promo_nr-3));
		}*/
		//this.currentBox = 3;
		
		return;
		}
		
		
		if(this.currentBox < 3) 
		{ this.currentBox++;
		
		if (action =="scroll")
		{this.scrollright = 1;};
		
		//this.currentBox = 4;
		//return;
		
		//$j('#'+this.divname).animate({"left": ((action == "inc") ? "+=" : "+=")  + this.boxWidth*(max_promo_nr-3) + "px"}, this.boxRotationSpeed*(max_promo_nr-3));

		/*for(var i=0;i<(max_promo_nr-3);i++)
		{
		
		$j('#'+this.divname).animate({"left": ((action == "inc") ? "+=" : "+=")  + this.boxWidth + "px"}, this.boxRotationSpeed/(max_promo_nr-3));
		}*/
		//this.currentBox = 3;
		
		return;
		}


//Animez automat
		if(action == "scroll")
		{ if (this.scrollright>0){action = "inc";} else {action="dec";};}

		//alert(this.currentBox);
		
		if(this.currentBox < 3) { this.currentBox = 3; return; }
	
		$j('#'+this.divname).animate({"left": ((action == "inc") ? "-=" : "+=") + this.boxWidth + "px"}, this.boxRotationSpeed);
	
		/*if(this.currentBox  == this.nextBox)
		{
			var IDs = "";
			$j('#'+this.divname).children().each(function(){ IDs+=this.id+"-"; });
			IDs = IDs.slice(0,-1);
			
			var self = this;
	
			$j.ajax({
				url : "/get_promo_product?ids="+IDs+"&zone="+this.zone+"&catid="+this.catid,
				success: function(html){
					if(html.length <= 1000) self.boxNumbers = self.nextBox-1;
					else {$j('#'+self.divname).append(html);}
				}
			});
			
			this.nextBox++;
		}*/
	}
}


