// Aktywacja funkcji po starcie strony
$(function() {
	// Przewijanie tekstu na stronie
	$('#main-content').jScrollPane();

	// Maskowanie adresu email
	$('a.nospam').nospam();
});

// Automatycznie przejście do pola tekstowego
function AutoFocus(elem) {
    var element = document.getElementById(elem);
    element.focus();
}

// 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);
			}
		}
	});
};

