
jQuery.fn.reverse = function() { return this.pushStack(this.get().reverse(), arguments); };

$(function(){ try {

	$('a[rel=external]').attr('target','_blank');
	$('a[rel=lightbox]').lightBox({
		imageBlank: '/page/images/lightbox-blank.gif',
		imageLoading: '/page/images/lightbox-ico-loading.gif',
		imageBtnClose: '/page/images/lightbox-btn-close.gif',
		imageBtnPrev: '/page/images/lightbox-btn-prev.gif',
		imageBtnNext: '/page/images/lightbox-btn-next.gif',
		txtImage: 'Zdjęcie',
		txtOf: 'z'
	});

	$('form[action!='+window.location.href+']').attr('target','_blank');
	/* book slider */
	try {
	Books.init();
	} catch(err) { };
/*
	/* strech course row height * /
	var iItemCount = iItemHeight = 0;
	var iItemLastRow = $('#courses tr').length;
	$('#courses tr:not(.item)').reverse().each(function(i){
		iItemCount = iItemLastRow-this.rowIndex-1;
		if(iItemCount>0 && iItemCount<5)
		{
			iItemHeight = Math.floor(110/iItemCount);
			$('#courses tr').slice(this.rowIndex+1,iItemLastRow).each(function(i){
				$('th',this).css('height',(iItemHeight)+'px');
				$('td',this).css('height',(iItemHeight)+'px');
			});
		};
		iItemLastRow = this.rowIndex;
	});
*/
	setInterval("$('#bottom .partners a').last().fadeOut('slow',function() { $(this).prependTo($(this).parent()); $(this).show(); });",8000);

	if($('#participated_tak:checked').length===0)
		$('#row-oldcourse').hide();

	$('#participated_tak,#participated_nie').change(function(){
		if($('#participated_tak:checked').length)
			$('#row-oldcourse').show();
		else
			$('#row-oldcourse').hide();
	});

    nccms.baner.init();

} catch(err) { deb.log('[ERROR]',err); } });

var nccms = {
    baner: {
        _nodes: [],
        init: function()
        {
            $('.advertisement-container').each(function () {
                if($('li',this).length>1)
                    nccms.baner.add(this);
            });
            setInterval(nccms.baner.change,10000);
        },
        add: function(node)
        {
            nccms.baner._nodes.push(node);
        },
        change: function()
        {
            for(var i=0;i<nccms.baner._nodes.length;i++)
                $('li:last',nccms.baner._nodes[i]).each(function (){
                    $(this).fadeOut(400,function () {
                        $(this).prependTo(this.parentNode);
                        $(this).show();
                    });
                });
        }
    }
};

