/**
 * @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': '',	// autor
'email': '',	// e-mail	
'img': '',	// obrazek
'width': '',	// szerokość obrazka
'height': '',	// 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,miesiac,rok, tytul,tresc, adres,ramka, dodal,email, obraz,width,height)
	{
		if (!this.il_dni || (now - new Date(rok, miesiac-1, dzien))/(24*60*60*1000) < this.il_dni)
		{
			if (dzien < 10) dzien = '0' + dzien;
			if (miesiac < 10) miesiac = '0' + miesiac;
			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('', '');
			
			content +=
				'<dt>' + link[0] + tytul + link[1] + '</dt>' +
				'<dd>' +
					'<div class="news_date"><span>Dodano:</span> ' + dzien + '.' + miesiac + '.' + rok + '</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] + 'Więcej...' + link[1] + '</div>' : '') +
					(dodal != '' ? '<div class="news_author"><span>' + (email == '' || email.indexOf('@') > 0 ? 'Dodane przez' : 'Źródło')  + ':</span> ' + (email.replace(/(^ +| +$)/g, '') ? '<a href="' + (email.indexOf('@') > 0 ? 'mailto:' : '') + email + '">' + dodal + '</a>' : dodal) + '</div>' : '') +
				'</dd>';
		}
	}
	
	this.wyswietl = function()
	{
		if (content) document.write('<dl class="news">' + content + '</dl>');
	}
}
