jQuery.noConflict();
     
     // Put all your code in your document ready area
jQuery(document).ready(function($){

	var popup = $('#popup'); 
	    popup.css({'margin-left': '-'+(popup.width()/2)+'px'});
	    popup.css({'margin-top': '-'+(popup.height()/2)+'px'});  
	    popup.fadeIn(500);
	    
	$('#popup').click(function() {
		popup.fadeOut(500);
	});

	// Use this example, or...
	//$("a[rel='lightbox']").lightbox( {
	//	fitToScreen : true,
	//	imageClickClose : false
	//}); // Select all links that contains lightbox in the attribute rel
	// This, or...
	// $('#gallery a').lightBox(); // Select all links in object with gallery ID
	// This, or...
	// $('a.lightbox').lightBox(); // Select all links with lightbox class
	// This, or...
	// $('a').lightBox(); // Select all links in the page
	// ... The possibility are many. Use your creative or choose one in the
	// examples above
	// Get our elements for faster access and set overlay width
	// $(".lightbox").lightbox({
	// fitToScreen: true,
	//imageClickClose: false
	// });

	var div = $('#galeria_obrazki');

	var ul = $('#galeria_obrazki ul');
	// unordered list's left margin
	var ulPadding = 15;
	
	var countPhoto = $('#galeria_obrazki ul li').size();
	var photoWidth = $('#galeria_obrazki ul li img').width();
	var photoSpace = photoWidth+15;

	// Get menu width
	var divWidth = div.width();

	// Remove scrollbars
	div.css( {
		overflow : 'hidden'
	});
	
	ul.css({
		width: countPhoto*photoSpace+10+'px'
	});

	// Find last image container
	//var lastLi = ul.find('li:last-child');
	// When user move mouse over menu

	
	//div.mousemove(function(e) {		
		// As images are loaded ul width increases,
			// so we recalculate it each time
		//	var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth()
			//		+ ulPadding;

		//	var left = (e.pageX - div.offset().left) * (ulWidth - divWidth)
					// divWidth;
		//	div.scrollLeft(left);
		//});
	
	var left = 0;
	var right = countPhoto*photoSpace;
	$("#btn_przewin_prawo").click(function() {
		if(countPhoto*photoSpace-left*(-1) > divWidth+15 ) {
			left = left-photoSpace;
			ul.animate({left: left+'px'}, 500);
		}
	});
	
	$("#btn_przewin_lewo").click(function() {
		if(left < 0 ) {
			left = left+photoSpace;
			ul.animate({left: left+'px'}, 500);
		}
	});
	
	//var a = 700;
	//$("#btn_przewin").click(function() {		
		// As images are loaded ul width increases,
			// so we recalculate it each time
		//	var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth()
		//			+ ulPadding;

	//		var left = (a - div.offset().left) * (ulWidth - divWidth)
					// divWidth;
	//		$("#ts1").html(div.offset().left);
	//		$("#ts2").html(e.pageX);
	//		div.scrollLeft(left);
	//		div.append(left);
	//		a=a-10;
	//	});

});

