 (function($){

// Creating the sweetPages jQuery plugin:
$.fn.sweetPages = function(opts){
	
	// If no options were passed, create an empty opts object
	if(!opts) opts = {};
	
	var resultsPerPage = opts.perPage || 3;
	
	// The plugin works best for unordered lists, althugh ols would do just as well:
	var ul = this;
	var li = ul.find('li');
	

	
	// Calculating the total number of pages:
	var pagesNumber = Math.ceil(li.length/resultsPerPage);
	
	

	
	
	for(var i=0;i<pagesNumber;i++)
	{
		// Slice a portion of the lis, and wrap it in a swPage div:
		li.slice(i*resultsPerPage,(i+1)*resultsPerPage).wrapAll('<span id="portfol6"></span>');
	
	}


	
	return this;
	
}})(jQuery);


$(document).ready(function(){
	/* The following code is executed once the DOM is loaded */
	
	// Calling the jQuery plugin and splitting the
	// #holder UL into pages of 3 LIs each:
	
	$('#holder').sweetPages({perPage:3});
	
	// The default behaviour of the plugin is to insert the 
	// page links in the ul, but we need them in the main container:

	var controls = $('.swControls').detach();
	controls.appendTo('#main');
	
});

 
jQuery.fn.each_slice = function(num, fn) {
    for ( var i=0,l=this.length,count=0,slice=[]; i<=l; i++ ) {
      

        if ( count >= num ) {
            fn.apply( jQuery( slice ) );
            count=0, slice=[];
        }
        slice.push( this[i] );
        count++;
    }
    return this;
};


// start skryptow
$(document).ready(function() {
     // menu poziom
      $('#menu-glowne').find('> li').hover(function(){
        $(this).find('ul')
        .removeClass('sub-menu')
        .stop(true, true).slideToggle('fast');
    });
   

   $('#portfollio li').each_slice(6, function() {
    $(this).wrapAll('<span id="portfol6"></span>');
});
	 
   $('#portfolli').sweetPages({perPage:6});	
   
    
    
    // scrolling na glownej
	
  $('#wnaszport').bxSlider({
           
            mode: 'horizontal',         
            displaySlideQty: 1,
            moveSlideQty: 1,  
            auto: true,
                                   
        });
    $('#portfolli').bxSlider({
           
            mode: 'horizontal',         
            displaySlideQty: 1,
            moveSlideQty: 1,  
            
                                   
        });     
        
 

  // assign a click event to the external thumbnails
  $('.buttsli, .men-1').hover(function(){
         // call the "goToSlide" public function
   
    slider.goToSlide(1);}, function(){
	}
    );
    $('.buttsli2, .men-4').hover(function(){
        
    slider.goToSlide(2);}, function(){
	}     );
   $('.buttsli3, .men-2').hover(function(){
        
    slider.goToSlide(4);}, function(){
	}     );
   $('.buttsli4, .men-3').hover(function(){
        
    slider.goToSlide(3);}, function(){
	}     );
                  
  // hoverek      
    $(".wwmen").css({"opacity" : 0})
   $(".buttsli, .buttsli2, .buttsli3, .buttsli4").css({"opacity" : 0}).hover(function(){
	  $.anihov(this);
     
		}, function(){
	   $.anihov2(this);
	  
	});
   $("#menu-main-menu2 li a").hover(function(){
	  
      $(".wwmen", this).stop().animate({"opacity" : 1}, 200);
		}, function(){
	   $.anihov2(".wwmen", this);
	  
	});
    $(".men-4").hover(function(){
	  $.anihov(".buttsli2");
     
		}, function(){
	   $.anihov2(".buttsli2");
	  
	});
   $(".men-1").hover(function(){
	  $.anihov(".buttsli");
     
		}, function(){
	   $.anihov2(".buttsli");
	  
	});
    $(".men-2").hover(function(){
	  $.anihov(".buttsli3");
     
		}, function(){
	   $.anihov2(".buttsli3");
	  
	});
  $(".men-3").hover(function(){
	  $.anihov(".buttsli4");
     
		}, function(){
	   $.anihov2(".buttsli4");
	  
	});
 
   
 
 
 
  
  // wiecej mniej w opisach
  if ($('.wiecej').length) {
     
    $('.listprszer p ~  p:last-child').after('</div> <div class="zwin" >zwin</div> ');
	  
    $('.schowane').hide();
    $('.zwin').hide();
$('.wiecej').click(function() {
   
    $(this).parent().find('.wiecej, .schowane, .zwin').slideToggle();
   })  
   $('.zwin ').click(function() {     
    $(this).parent().parent().find('.wiecej, .schowane, .zwin').slideToggle();
    })
    
    $('.ddanetyt').click(function() {     
    $(this).next().find('.wiecej, .schowane, .zwin').slideToggle();
    })
    $(".ddanetyt").css("cursor","pointer");
      }
    
  
    
    
   // wyrownanie do dolu   
    $('.dodolu .gallery-row dl').each(function() {     
   var $img = $(this);
var h = $img.height();
    var c = 240 - h;
$img.css('margin-top', +c  + "px");
    })
    
                            
// koniec skryptow      
});
    
   
