$(document).ready(function() { 




	$('div.slider').hide().css({opacity:0});
	$('.sheader').
		addClass('clickable').
		click(function(){				
			toggleSection($(this).next());
			$(this).blur();
			return false;
		}).
		keypress(function(e){
			if(e.which == 13){
				toggleSection($(e.target).next());
				$(this).blur();
			}
		});
		
	$('.scrubback').
		addClass('clickable').
		click(function(){				
			toggleSection($(this).parent());
			$(this).blur();
			return false;
		}).
		keypress(function(e){
			if(e.which == 13){
				toggleSection($(e.target).parent());
				$(this).blur();
			}
		});

function toggleSection(section){
	if(section.is(':visible')){
		section.animate({opacity:0}, {duration:300, queue: false});
		section.slideUp(500, 'easeInOutCubic');
	} else {
		section.slideDown({duration:400, queue: false, easing:'easeInOutCubic'});
		section.animate({opacity:1, duration:300, easing:'easeInOutCubic'});
	}	
}


//*******************************************************************************************************************	 

// initialize tooltip 
    $('.descimg img[title], .gallery-large span[title]').tooltip({ 
     
        // use single tooltip element for all tips 
        tip: '#tooltipdesc',  
         
        // tweak the position 
        offset: [100, -200], 
         
        // use "slide" effect 
        effect: 'slide' 
         
    // add dynamic plugin  
    }).dynamic( { 
     
        // customized configuration on bottom edge 
        bottom: { 
         
            // slide downwards 
            direction: 'down', 
             
            // bounce back when closed 
            bounce: true 
        } 
    });
	
	// pamietac o podmienieniu obrazka i opisu w wersji angielskiej
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="img/fancybox/closelabel-PL.png" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Obrazek ' + (currentIndex + 1) + ' z ' + currentArray.length + '</div>';
}
	
		$("a.pic").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'changeSpeed'	:	200,
		'overlayShow'	:	true,
		'overlayColor'	:	'#000',
		'overlayOpacity':	0.5,
		'titlePosition'	:	'inside',
		'titleFormat'	:	formatTitle,
		'showCloseButton':	false,
	});
     
//*******************************************************************************************************************	 
//*******************************************************************************************************************	 
	 
    // initialize tooltip 
    $('.smallgallery img[title]').tooltip({ 
     
        // use single tooltip element for all tips 
        tip: '#tooltipdesc',  
         
        // tweak the position 
        offset: [100, 100], 
         
        // use "slide" effect 
        effect: 'slide' 
         
    // add dynamic plugin  
    }).dynamic( { 
     
        // customized configuration on bottom edge 
        bottom: { 
         
            // slide downwards 
            direction: 'down', 
             
            // bounce back when closed 
            bounce: true 
        } 
    });
	
	// pamietac o podmienieniu obrazka i opisu w wersji angielskiej
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="img/fancybox/closelabel-PL.png" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Obrazek ' + (currentIndex + 1) + ' z ' + currentArray.length + '</div>';
}
	
		$("a.pic").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'changeSpeed'	:	200,
		'overlayShow'	:	true,
		'overlayColor'	:	'#000',
		'overlayOpacity':	0.5,
		'titlePosition'	:	'inside',
		'titleFormat'	:	formatTitle,
		'showCloseButton':	false,
	});	 

//*******************************************************************************************************************	 

	 //scrollTo
	$('a').click(function(e) {$.scrollTo( this.hash, 2500, {easing:'easeInOutCubic'} ); e.preventDefault(); });
	 
});

