/**
 * @author Sławomir Kokłowski {@link http://www.kurshtml.boo.pl}
 * @copyright NIE usuwaj tego komentarza! (Do NOT remove this comment!)
 */

function News(days)
{
	this.config = {

//////////
// Konfiguracja:
'days': 0,	// ilo¶ć dni wy¶wietlania newsów (0 = zawsze)
// Ustawienia domy¶lne:
'author': 'Info AAI-Polska',	// autor
'email': "info@aai-polska.pl",	// e-mail	
'img': 'gfx/newsico/aaips.gif',	// obrazek
'width': '88',	// szeroko¶ć obrazka
'height': '96',	// wysoko¶ć obrazka
'target': ''	// ramka (target="...")
//////////

	};
	
	this.il_dni = typeof days != 'undefined' ? days : this.config['days'];
	var now = new Date();
	var content = '';
	
	this.dodaj = function(dzien,dzienkon,miesiac,miesiackon,rok, etykieta,tytul,tresc, adres,adresa,ramka, dodal,email, obraz,width,height,kal)
	{
		if (!this.il_dni || (now - new Date(rok, miesiac-1, dzien))/(24*60*60*1000) < this.il_dni)
		{
			if (typeof kal == 'undefined') 
			{
			if(miesiac==1)kal='sty' + rok;
			if(miesiac==2)kal='lut' + rok;
			if(miesiac==3)kal='mar' + rok;
			if(miesiac==4)kal='kwi' + rok;
			if(miesiac==5)kal='maj' + rok;
			if(miesiac==6)kal='cze' + rok;
			if(miesiac==7)kal='lip' + rok;
			if(miesiac==8)kal='sie' + rok;
			if(miesiac==9)kal='wrz' + rok;
			if(miesiac==10)kal='paz' + rok;
			if(miesiac==11)kal='lis' + rok;
			if(miesiac==12)kal='gru' + rok;
			}
			if (typeof kal == '') 
			{
			if(miesiac==1)kal='sty' + rok;
			if(miesiac==2)kal='lut' + rok;
			if(miesiac==3)kal='mar' + rok;
			if(miesiac==4)kal='kwi' + rok;
			if(miesiac==5)kal='maj' + rok;
			if(miesiac==6)kal='cze' + rok;
			if(miesiac==7)kal='lip' + rok;
			if(miesiac==8)kal='sie' + rok;
			if(miesiac==9)kal='wrz' + rok;
			if(miesiac==10)kal='paz' + rok;
			if(miesiac==11)kal='lis' + rok;
			if(miesiac==12)kal='gru' + rok;
			}
			if (dzien < 10) dzien = '0' + dzien;
			if (dzienkon < 10) dzienkon = '0' + dzienkon;
			if (miesiac < 10) miesiac = '0' + miesiac;
			if (miesiackon < 10) miesiackon = '0' + miesiackon;
			if (typeof dodal == 'undefined') dodal = this.config['author'];
			
			if (typeof email == 'undefined') email = this.config['email'];
			if (typeof obraz == 'undefined') obraz = this.config['img'];
			if (typeof obraz == 'undefined') width = this.config['width'];
			if (typeof obraz == 'undefined') height = this.config['height'];
			if (typeof ramka == 'undefined') ramka = this.config['target'];
			var link = adres ? new Array('<a ' + (ramka ? ' target="' + ramka + '"' : '') + 'href="' + adres + '">', '</a>') : new Array('', '');
			if (adresa == 'undefined')
			{
			adresa=0;
			}
			else
			{
			var linka = adres ? new Array('<a ' + (ramka ? ' target="' + ramka + '"' : '') + 'href="' + adresa + '">', '</a>') : new Array('', '');
			}
			
			if (adresa == 0)
			{
			if (dzienkon==0)
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '.' + miesiac + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			else
			{
			if (miesiackon==0)
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '-' + dzienkon + '.' + miesiac + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			else
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '.' + miesiac + ' - ' + dzienkon + '.' + miesiackon + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			}
			}
			else
			{
			if (dzienkon==0)
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '.' + miesiac + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '<br>' + linka[0] + 'More information <IMG SRC="gfx/brit.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="More information">' + linka[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			else
			{
			if (miesiackon==0)
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '-' + dzienkon + '.' + miesiac + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '<br>' + linka[0] + 'More information <IMG SRC="gfx/brit.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="More information">' + linka[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			else
			{
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><a name="' + etykieta + '"></a><a class="linki3" href="index.php?show=news&kal=' + kal + '#top"><span>Dnia:</span> ' + dzien + '.' + miesiac + ' - ' + dzienkon + '.' + miesiackon + '.' + rok + '</a></div>' +
					'<div class="news_content">' +
						(obraz != '' ? link[0] + '<img src="' + obraz + '" alt="" class="news_img"' + (width ? ' width="' + width + '"' : '') + (height ? ' height="' + height + '"' : '') + ' />' + link[1] : '') +
						tresc +
					'</div>' +
					(adres ? '<div class="news_more">' + link[0] + 'Zapisz ulotkę <IMG SRC="gfx/pol.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="Zapisz polsk± ulotkę">' + link[1] + '<br>' + linka[0] + 'More information <IMG SRC="gfx/brit.jpg" WIDTH="31" HEIGHT="21" BORDER="0" ALIGN="MIDDLE" ALT="More information">' + linka[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Info' : '¬ródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '<div class="wroc"><a href="#top">Góra</a></div></div>' : '') +
				'</dd>';
			}
			}
			}
		}
	}
	
	this.wyswietl = function()
	{
		if (content) document.write('<dl class="news">' + content + '</dl>');
	}
}
