$(document).ready(function(){
	$(".wiecej").toggle(function(){
		var id = $(this).attr('id').substring(4);
		$.ajax({
			type: "POST",
			url: "aktualnosci/getnews",
			data: "id="+id+"&null=1",
			success: function(content) {
				$("#short"+id).after('<div class="text2" id="long'+id+'">'+content+'</div>');
				$("#show"+id).addClass('zwin');
			}
		});
	}, function(){
		var id = $(this).attr('id').substring(4);
		$("#long"+id).slideUp('slow').remove();
		$(this).removeClass('zwin');
	});

	$("button[id^=ogloszenie]").toggle(function(){
		var id = $(this).attr('id').substring(10);
		$.ajax({
			type: "POST",
			url: "ogloszenia/gettext",
			data: "id="+id+"&null=1",
			success: function(content) {
				$("#short"+id).after('<div class="text2" id="long'+id+'">'+content+'</div>');
				$("#ogloszenie"+id).addClass('zwin');
			}
		});
	}, function(){
		var id = $(this).attr('id').substring(10);
		$("#long"+id).slideUp('slow').remove();
		$(this).removeClass('zwin');
	});

	$('a.go_login[rel], a.go_url[rel]').overlay({
		closeOnEsc: true,
		mask: {
			color: null,
			maskId: 'denimMask',
			opacity: 1
		},
		closeOnClick: true,
		onBeforeLoad: function () {
			var wrapper = this.getOverlay().find(".contentWrap .load_here");
			wrapper.load(this.getTrigger().attr('href')+"?null=1");
		},
		onClose: function () {
			if(this.getTrigger().attr('id') == 'go_ustawienia') location.reload();
		}
	});
	$('a.close').click(function() {
		return false;
	});
	$('.motor_slider .motor_big').fadeIn(800);
	$('.slide_me').bxSlider({
		mode: 'fade',
		controls: false,
		auto: true,
		autoStart: true,
		pause: 3000
	});
});

function new_overlay(reload){ //do text_here daj tekst
	if($('#overlay_function')) $('#overlay_function').remove();
	var over = '<div id="overlay_function"><div class="contentWrap"><div class="over_logo"><a href="http://www.piffap.pl"><img src="templates/home/logo.png" alt="piffap.pl" /></a></div><div class="load_here"><div class="overlay_box2"><div class="text_here"></div><a href="#close" class="button_red close button_close">Zamknij</a></div></div></div></div>';
	$("body").prepend(over)
	if(reload == 'reloadMe') {
		$("#overlay_function").overlay({
			closeOnEsc: true,
			mask: {
				color: null,
				maskId: 'denimMask',
				opacity: 1
			},
			load: true,
			onClose: function () {
				location.reload();
			}
		});
	} else {
		$("#overlay_function").overlay({
			closeOnEsc: true,
			mask: {
				color: null,
				maskId: 'denimMask',
				opacity: 1
			},
			load: true,
			onClose: null
		});
	}
}

