// JavaScript Document
function  Random_Adv( class_name, adv_visible  )
{
	this.class_name = class_name;
	this.adv_visible = adv_visible;
	this.adv_arr = $$(class_name) || Array();
	this.adv_arr_length = this.adv_arr.length || 0;
	//
	this.if_adv_exist = function ()
	{
		return (this.adv_arr.length>0 ? true : false);
	};
	this.show_all_adv = function ()
	{
		if(this.if_adv_exist())
		{
			this.adv_arr.each( function(el){
			el.setStyles({'display':'block'});
			});
		}
	};
	this.close_all_adv = function()
	{
		if(this.if_adv_exist())
		{
			this.adv_arr.each( function(el){
			el.setStyles({'display':'none'});
			});
		}
	};
	this.show_random_adv = function ()
	{
		if(this.if_adv_exist()   )
		{
			this.close_all_adv();
			var iterator = this.adv_visible;
			var last_index;
			for(i=0; i < iterator; i++)
			{
				index =  Math.round(Math.random() * ( this.adv_arr_length - 1 ));
				// give an other chance
				(this.last_index == index) ?  iterator++ : this.last_index = index;
				this.adv_arr[index].setStyles({'display':'block'});
			}
		}
	}
}
//----------------- rotator ---------------

