$(document).ready(function(){

    // tooltip - dymek
    tooltip();

    // lightbox - colorbox
    $("a[rel='lightbox']").colorbox({transition:"elastic"});
    $("a[rel='galeria']").colorbox({transition:"elastic"});
    
    $(".collapse").hide();
	$('.expand').click(function(){
	    $(".collapse").slideToggle("slow,");
	});

	// We only want these styles applied when javascript is enabled
	// $('div.navigation').css({'width' : '130px', 'float' : 'right'});
	// $('div.content').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
	
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     2500,
		numThumbs:                 10,
		preloadAhead:              10,
		enableTopPager:            false,
		enableBottomPager:         true,
		maxPagesToShow:            4,
		imageContainerSel:         '#slideshow',
		controlsContainerSel:      '#controls',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		renderSSControls:          false,
		renderNavControls:         true,
		playLinkText:              'Play Slideshow',
		pauseLinkText:             'Pause Slideshow',
		prevLinkText:              '',
		nextLinkText:              '',
		nextPageLinkText:          '&rsaquo;&rsaquo;',
		prevPageLinkText:          '&lsaquo;&lsaquo;',
		enableHistory:             false,
		autoStart:                 false,
		syncTransitions:           true,
		defaultTransitionDuration: 900,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onPageTransitionOut:       function(callback) {
			this.fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:        function() {
			this.fadeTo('fast', 1.0);
		}
	});
});

noweOkienko = null;
function otworz(adres, w, h) {

  if(window.screen){
    aw=screen.availWidth;
    ah=screen.availHeight;
  }else{
    aw=640;
    ah=450;
  }
  if(noweOkienko==null || noweOkienko.closed){
    ustawienia=
     "left=" + (aw-w)/2 + ","
    +"top=" + (ah-h)/2 + ","
    +"screenX=" + (aw-w)/2 + ","
    +"screenY=" + (ah-h)/2 + ","
    +"width=" + w + ","
    +"height=" + h + ","
    +"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"status=no,"
    +"menubar=no,"
    +"scrollbars=1,"
    +"resizable=no"
    noweOkienko = window.open(adres,'drukuj',ustawienia);
  }
  noweOkienko.document.close();
  noweOkienko.focus();
}

