

function naj_hit(szer_max,wys_max)
{
	this.ile = 0;

	this.tekst_id = new Array();
	this.tytul = new Array();
	this.opis = new Array();
	this.img_nazwa = new Array();
	this.img_szer = new Array();
	this.img_wys = new Array();
	
	this.szer_max = szer_max;
	this.wys_max = wys_max;
	
	//wartosc pozycji z tablicy "nr" wskazuje na pozycję w poprzednich tablicach
	this.nr = new Array(0,1,2);
	//this.nr[0]=0;this.nr[1]=1;this.nr[2]=2;
	//metody obiektu
	this.dodaj = naj_dodaj;
	this.zmien = naj_zmien;
	this.pokaz = naj_pokaz;
	this.zmien_wymiary = naj_zmien_wymiary;
}

function naj_dodaj(tekst_id,tytul,opis,nazwa,szer,wys)
{
	this.tekst_id.push(tekst_id);
	this.tytul.push(tytul);
	this.opis.push(opis);
	this.img_nazwa.push(nazwa);
	this.img_szer.push(szer);
	this.img_wys.push(wys);
	
	this.zmien_wymiary(this.ile);
	
	this.ile++;
}

function naj_zmien()
{
	var los;
	var tab_los = new Array();
	var nr_pom;
	
	if(this.ile>2)
	{
		this.nr[0] = this.nr[1];
		
		if(this.nr[1] < this.ile-1)
		{
			this.nr[1]++;
		}
		else
		{
			this.nr[1] = 0;
		}
	}
	this.pokaz(0,this.nr[0]);
	this.pokaz(1,this.nr[1]);
	
	setTimeout("najnowsze_wyd.zmien()",5000);
}

function naj_zmien_() //nie używane
{
	var los;
	var tab_los = new Array();
	var nr_pom;
	
	if(this.ile>3)
	{
  	 	nr_pom = this.nr[0];
		this.nr[0] = this.nr[1];
		this.nr[1] = this.nr[2];
		
		if(this.nr[2]<this.ile-1){
			this.nr[2]++;
		}else{
			this.nr[2] = nr_pom;
		}
	}
	this.pokaz(0,this.nr[0]);
	this.pokaz(1,this.nr[1]);
	this.pokaz(2,this.nr[2]);
	
	setTimeout("najnowsze_wyd.zmien()",5000);
}

function naj_pokaz(i,los)
{
	var txt = '';
	
	if(this.img_nazwa[los])
	{
		txt += '<img src="gazeta_img/'+this.img_nazwa[los]+'" vspace="10" hspace="5" width="'+this.img_szer[los]+'" height="'+this.img_wys[los]+'" style="border:0;"><br>';
	}
	if(this.tytul[los])
	{
		txt += '<b>'+this.tytul[los]+'</b><br>';
		
		txt += this.opis[los]+'<br><br>';
		txt += '<a href="javascript:pokaz_artykul('+this.tekst_id[los]+')">[więcej]</a>';
	}

	document.getElementById('div_naj_'+i).innerHTML = txt;
}

function naj_zmien_wymiary(i)
{
	var wsp;
	
	if(this.img_szer[i] > this.szer_max)
	{
		wsp = this.szer_max / this.img_szer[i];
		this.img_szer[i] = this.szer_max;
		this.img_wys[i] = Math.floor(this.img_wys[i] * wsp);
	}
	
	if(this.img_wys[i] > this.wys_max)
	{
		wsp = this.wys_max / this.img_wys[i];
		this.img_szer[i] = Math.floor(this.img_szer[i] * wsp);
		this.img_wys[i] = this.wys_max;
	}
}

