// Ukrywanie adresów email przed botami
jQuery.fn.nospam = function(settings) {
	settings = jQuery.extend({
		replaceText: true,
		filterLevel: 'normal'
	}, settings);

	return this.each(function() {
		e = null;
		if(settings.filterLevel == 'low') {
			if($(this).is('a[rel]')) {
				e = $(this).attr('rel').replace('//', '@').replace(/\//g, '.');
			} else {
				e = $(this).text().replace('//', '@').replace(/\//g, '.');
			}
		} else {
			if($(this).is('a[rel]')) {
				e = $(this).attr('rel').split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
			} else {
				e = $(this).text().split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
			}
		}
		if(e) {
			if($(this).is('a[rel]')) {
				$(this).attr('href', 'mailto:' + e);
				if(settings.replaceText) {
					$(this).text(e);
				}
			} else {
				$(this).text(e);
			}
		}
	});
};

$(document).ready(function(){

	// Maskowanie adresów email
	$('a.nospam').nospam();

	// Aktywacja tabeli z sortowaniem
	$(function(){
		if($('table').length){
			$('table').tablesorter({
				sortList: [[0,1]] 
			});
		}
	});

	// Mapa i punkty przyjęć
	$('#search-point').change(function(){
		$('#map').fadeTo('slow', 0.01, function(){
			$('#map').attr('src', '/_images/maps/map-' + $('#search-point').find('option:selected').attr('value') + '.png');
			$('#map').fadeTo('slow', 1.0);
		});

		$('#place-0, #place-1, #place-2').fadeOut('slow', function(){
			$('#place-' + $('#search-point').find('option:selected').attr('value')).delay(800).fadeIn('slow');
		});
	});

});
