Shadowbox.init({
	    displayNav:         true,
	    handleUnsupported:  "remove",
	    autoplayMovies:     false,
		continuous:			true,
		modal:				true,
		handleOversize:		"resize",
		handleUnsupported:  "remove",
		overlayOpacity:		0.7
});
	
$(document).ready(function() {

	$(".img_banner33").click(function () {
		$(this).fadeTo("fast", Math.random());
	});

	$( ".img_banner" ).animate({ opacity: 0.8}, { duration: 10000, queue: false });

	$('#slider1') // Demo 2 code, using FX base effects
	  .anythingSlider({
				theme        : 'metallic',						
				buildArrows  : false,			
				easing              : "easeInOutQuad",
				delay               : 20000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
				resumeDelay         : 15000,     // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
				animationTime       : 10000, 		// How long the slideshow transition takes (in milliseconds)		
				autoPlay     : true
	  })
	 .anythingSliderFx({
	   // base FX definitions can be mixed and matched in here too.
	   '.fade' : [ 'fade' ],
	
	   // for more precise control, use the "inFx" and "outFx" definitions
	   // inFx = the animation that occurs when you slide "in" to a panel
	   inFx : {
		'.img_banner'  : { opacity: 0.8, duration: 6000 },		
		'.flash_banner' : {top: 0, duration: 10}
		},
	   // out = the animation that occurs when you slide "out" of a panel
	   // (it also occurs before the "in" animation)
	   outFx : {
		'.img_banner'      : { opacity: 1, duration: 600 },		
		'.flash_banner' : {top : -500, duration: 50}		
	   }
	  });
 
	//########################################################//
	//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	//########################################################//
	
	
	//########################################################//
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
	$('.menu-nav li').hover(
		function() {
			$(this).addClass("active");
			$(this).find('.ulwrapper').stop(false, true).slideDown('normal');
			$(this).find('.ulwrapper .ulwrapper').stop(false, true).slideUp('slow');
		},
		function() {
			$(this).removeClass("active");        
			$(this).find('div').stop(false, true).slideUp('slow');
		}
	);
	
	$('.ulwrapper').hover(
		function() {
			$('.parent').addClass("active");
		},
		function() {
			$('.parent').removeClass("active");        
		}
	);
	//########################################################//
	
	//########################################################//
	// Galeria i fade galerii
	$(".obrazek").fadeTo("fast", 1);
	$(".obrazek").hover(function(){
		$(this).fadeTo("normal", .5);
	},
	function(){
		$(this).fadeTo("slow", 1);
	});
	//########################################################//	
	
	//########################################################//		
	$(function(){  
		$('#wrap1').corner("6px");		
		$('#column_right1').corner( "tr 6px" ).corner("bl 6px").corner("br 6px");	
		$('ul.menu-nav li a1').corner( "top 5px" );			
		$('ul.menu-nav li div ul li a1').uncorner();					
	});
	//########################################################//	
	
	var flaga = false;
	
	var top =$('.left').offset().top - parseFloat($('.left').css('marginTop').replace(/auto/, 0));
	$(window).scroll(function () {
    // what is the y position of the scroll?
    var y = $(window).scrollTop();    
    // whether that's below the start of article?
	
    if (y >= top && !flaga && $(window).height() > 748 ) {
      // if so, add the fixed class
	  flaga = true;
	  $('.main').append('<div class="temp_left" style="height:' + $('.left').height()  + 'px;"></div>');
      $('.left').addClass('fixed');
    } if (y < top ) {
		flaga = false;
      // otherwise, remove it
      $('.left').removeClass('fixed');
      $('.temp_left').remove();	  
    }
  });
	$(".img_banner_png").fadeTo(5000, 1);
});

