// funkcje do obsługi zakładek

function StronyClass(id)
{
	this.strony = Array();
	this.wybrana = null;
	this.iloscKropek = 0;
	this.link = null;

	this.id = id;
}

StronyClass.podswietlPoprzedni = function(obj, podswietl)
{
	getElement('pagePrevL').className = podswietl ? 'page_left_blue' : 'page_left_light';
	getElement('pagePrevM').className = podswietl ? 'page_blue' : 'page_light';

	if (obj.strony.length > 0)
		getElement(obj.strony[0] + 'L').className = 'page_' + (podswietl ? 'blue' : 'light') + '_' + (obj.wybrana == 1 ? 'blue' : 'dark');
}

StronyClass.podswietlNastepny = function(obj, podswietl)
{
	getElement('pageNextL').className = podswietl ? 'page_' + (obj.wybrana == obj.strony.length ? 'blue' : 'dark') + '_blue' : 'page_' + (obj.wybrana == obj.strony.length ? 'blue' : 'dark') + '_light';
	getElement('pageNextM').className = podswietl ? 'page_blue_np' : 'page_light_np';
	getElement('pageNextR').className = podswietl ? 'page_right_blue' : 'page_right_light';
}

StronyClass.prototype.poczatek = function()
{
	document.write('<TABLE ALIGN="CENTER" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR>');
}

StronyClass.prototype.koniec = function()
{
	document.write('</TR></TABLE>');
}

StronyClass.prototype.dodajPoprzedni = function()
{
	document.write('<TD ID="pagePrevL" CLASS="page_left_light" ONMOUSEOVER="StronyClass.podswietlPoprzedni(' + this.id + ', true);" ONMOUSEOUT="StronyClass.podswietlPoprzedni(' + this.id + ', false);"><IMG SRC="gfx/pixel.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>');

	if (this.wybrana > 1)
		document.write('<TD ID="pagePrevM" CLASS="page_light" ONMOUSEOVER="StronyClass.podswietlPoprzedni(' + this.id + ', true);" ONMOUSEOUT="StronyClass.podswietlPoprzedni(' + this.id + ', false);" ONCLICK="window.location.href = \'' + this.link + (this.wybrana - 1) + '\';"><A HREF="' + this.link + (this.wybrana - 1) + '">&laquo;</A></TD>');
	else
		document.write('<TD ID="pagePrevM" CLASS="page_light">&nbsp;</TD>');
}

StronyClass.prototype.dodajNastepny = function()
{
	var klasa = 'page_' + (this.wybrana == this.strony.length ? 'blue' : 'dark') + '_light';

	document.write('<TD ID="pageNextL" CLASS="' + klasa + '" ONMOUSEOVER="StronyClass.podswietlNastepny(' + this.id + ', true);" ONMOUSEOUT="StronyClass.podswietlNastepny(' + this.id + ', false);"><IMG SRC="gfx/pixel.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>');

	if (this.wybrana < this.strony.length)
		document.write('<TD ID="pageNextM" CLASS="page_light_np" ONMOUSEOVER="StronyClass.podswietlNastepny(' + this.id + ', true);" ONMOUSEOUT="StronyClass.podswietlNastepny(' + this.id + ', false);" ONCLICK="window.location.href = \'' + this.link + (this.wybrana + 1) + '\';"><A HREF="' + this.link + (this.wybrana + 1) + '">&raquo;</A></TD>');
	else
		document.write('<TD ID="pageNextM" CLASS="page_light_np">&nbsp;</TD>');

	document.write('<TD ID="pageNextR" CLASS="page_right_light" ONMOUSEOVER="StronyClass.podswietlNastepny(' + this.id + ', true);" ONMOUSEOUT="StronyClass.podswietlNastepny(' + this.id + ', false);"><IMG SRC="gfx/pixel.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>');
}

StronyClass.prototype.dodajStrone = function(strona, wybrana)
{
	if (typeof wybrana == 'undefined')
		wybrana = false;

	//

	if (wybrana)
		this.wybrana = strona;

	//

	this.strony.push('pagePage' + strona);

	var klasaL = this.strony.length == 1 ? 
					'page_light_' + (wybrana ? 'blue' : 'dark') : 
					'page_' + (this.wybrana == strona - 1 ? 'blue' : 'dark') + '_' + (wybrana ? 'blue' : 'dark');

	var klasaM = wybrana ? 'page_blue' : 'page_dark';

	document.write('<TD ID="pagePage' + strona + 'L" CLASS="' + klasaL + '" ONMOUSEOVER="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', true);" ONMOUSEOUT="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', false);"><IMG SRC="gfx/pixel.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>');
	document.write('<TD ID="pagePage' + strona + 'M" CLASS="' + klasaM + '" ONMOUSEOVER="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', true);" ONMOUSEOUT="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', false);" ONCLICK="window.location.href = \'' + this.link + strona + '\';"><A HREF="' + this.link + strona + '">' + strona + '</A></TD>');
}

StronyClass.prototype.dodajWybranaStrone = function(strona)
{
	this.dodajStrone(strona, true);
}

StronyClass.podswietlStrone = function(obj, strona, podswietl)
{
	if (obj.wybrana != strona)
	{
		getElement('pagePage' + strona + 'M').className = podswietl ? 'page_blue' : 'page_dark';

		if (strona == 1)
		{
			getElement('pagePage' + strona + 'L').className = 'page_light_' + (podswietl ? 'blue' : 'dark');

			getElement('pagePage' + (strona + 1) + 'L').className = 'page_' + (podswietl ? 'blue' : 'dark') + '_' + (strona + 1 == obj.wybrana ? 'blue' : 'dark');
		}
		else if (strona == obj.strony.length)
		{
			getElement('pagePage' + strona + 'L').className = podswietl ? 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_blue' : 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_dark';

			getElement('pageNextL').className = podswietl ? 'page_blue_light' : 'page_dark_light';
		}
		else
		{
			getElement('pagePage' + strona + 'L').className = podswietl ? 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_blue' : 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_dark';
			getElement('pagePage' + (strona + 1) + 'L').className = 'page_' + (podswietl ? 'blue' : 'dark') + '_' + (strona + 1 == obj.wybrana ? 'blue' : 'dark');
		}
	}
}

StronyClass.podswietlKropki = function(obj, strona, podswietl)
{
	if (obj.wybrana != strona)
	{
		getElement('pagePage' + strona + 'M').className = podswietl ? 'page_blue' : 'page_dark';

		if (strona == 1)
		{
			getElement('pagePage' + strona + 'L').className = 'page_light_' + (podswietl ? 'blue' : 'dark');

			getElement('pagePage' + (strona + 1) + 'L').className = 'page_' + (podswietl ? 'blue' : 'dark') + '_' + (strona + 1 == obj.wybrana ? 'blue' : 'dark');
		}
		else if (strona == obj.strony.length)
		{
			getElement('pagePage' + strona + 'L').className = podswietl ? 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_blue' : 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_dark';

			getElement('pageNextL').className = podswietl ? 'page_blue_light' : 'page_dark_light';
		}
		else
		{
			getElement('pagePage' + strona + 'L').className = podswietl ? 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_blue' : 'page_' + (obj.wybrana == strona - 1 ? 'blue' : 'dark') + '_dark';
			getElement('pagePage' + (strona + 1) + 'L').className = 'page_' + (podswietl ? 'blue' : 'dark') + '_' + (strona + 1 == obj.wybrana ? 'blue' : 'dark');
		}
	}
}

StronyClass.prototype.dodajKropki = function()
{
	this.iloscKropek++;

	this.strony.push('pageKropki' + this.iloscKropek);

	var klasaL = this.strony.length == 1 ? 
					'page_light_dark' : 
					'page_' + (this.wybrana == this.iloscKropek - 1 ? 'blue' : 'dark') + '_dark';

	var klasaM = 'page_dark';

//	document.write('<TD ID="pageKropki' + this.iloscKropek + 'L" CLASS="' + klasaL + '" ONMOUSEOVER="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', true);" ONMOUSEOUT="StronyClass.podswietlKropki(' + this.id + ', ' + strona + ', false);"><IMG SRC="gfx/pixel.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>');
//	document.write('<TD ID="pageKropki' + this.iloscKropek + 'M" CLASS="' + klasaM + '" ONMOUSEOVER="StronyClass.podswietlStrone(' + this.id + ', ' + strona + ', true);" ONMOUSEOUT="StronyClass.podswietlKropki(' + this.id + ', ' + strona + ', false);">..</TD>');
}
