$(document).ready(function () {

	// Rozwijanie nizszego elementu 
	$('.accordion h2').click(function() {
		$(this).next().toggle('slow');
		return false;
	}).next().hide();

	// Elementy o tej klasie beda mialy taka sama wysokosc 
	$('.info-box').equalHeights();
	
	// Nadpisanie funkcji Toogle - plynny toggle 
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);};

  // Zamykanie elementu, plynne znikanie 
  $('a.close ').click(function() {
		$('.table').fadeOut('medium');
		$('.table').removeClass();
		return false; 
	});
	
	// Cross-browser Hover
	$(".hov").hover( function () { $(this).addClass("hover"); }, function () {$(this).removeClass("hover"); } );

	// Slider wraz z nawigacja generowana automatycznie
	$('.portfolio-image-slideshow').cycle({ 
        fx:     'scrollHorz', 
        speed:   500, 
        timeout: 0, 
		  prev:   '.prev', 
    	  next:   '.next',
        after: onAfter,
		  timeout: 0 
    }); 
	function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('.prev')[index == 0 ? 'hide' : 'show']();
    $('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

	 
	// Parzyste, nieparzyste - nadaj styl, klase
	 $("#feature-table tr:even").css("background-color", "#fff");
 	 $("#feature-table tr:odd").css("background-color", "#f8f8f8").addClass("odd");


    //
    $("#gone").hide();
	// Simple Show/Hide Dialog Box
	$(".popup-show").click( function (){
												$(this).next('.popup-dialog').fadeIn('medium');
												return false;
												} );
	$(".popup-show .close").click( function (){
												$(this).prev('.popup-dialog').fadeOut('medium');
												return false;
												}
												
												
												);

$("#portfolio-navigation ul li a:last").css("margin-right","0");
$("#portfolio-navigation ul li a:first").css("margin-left","0");

 // Go Back link animation and scroll
 
 $(function () { 

	var scroll_timer;
	var displayed = false;
	var $message = $('#go2top a');
	var $window = $(window);
	var top = 10;
 
	/* react to scroll event on window */
	$window.scroll(function () {
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () {  
			if($window.scrollTop() <= 40) // hide if at the top of the page
			{
				displayed = false;
				$message.fadeOut(800);
			}
			else if(displayed == false) // show if scrolling down
			{
				displayed = true;
				$message.stop(true, true).fadeIn('medium').click(function () { $message.fadeOut(800); });
			}
		}, 200);
	});
});

// SeeAll/ShowMore

$("#show-more a").click( function(){
											 $(this).toggleClass('zwin');
											 $(".see-all").slideToggle();
											 return false;
											 })

// ScrollTo
 
$('#top-navigation a:eq(0), #top-navigation a:eq(1)').click(function(){
		$.scrollTo('#disclaimer', 800);
	});
$('#top-navigation a:eq(2),#top-navigation a:eq(3)').click(function(){
		$.scrollTo('#clients', 800);
	});
$('#top-navigation a:eq(4),#top-navigation a:eq(5)').click(function(){
		$.scrollTo('#portfolio', 800);
	});
$('#top-navigation a:eq(6),#top-navigation a:eq(7)').click(function(){
		$.scrollTo('#footer', 800);
	});


$('#go2top a').click(function(){
		$.scrollTo('#header', 800);
	});

// Portfolio Navigation
$("#portfolio-navigation a").css("opacity","0.7");
$("#portfolio-navigation a").each(function(index){
        $(this).click(function(){ 
				$("#portfolio-navigation a").removeClass("active");
            $(this).addClass("active").css("opacity","1");
				$('.active-ribbon').remove();
            $(this).prepend("<div class='active-ribbon'></div>")
				$("#portfolio").children().hide();
            
            $("#portfolio").children().eq(index).show();
            return false;
        });
    });

// Portfolio 

$('#go2top a').hover( 
									function(){ $(this).animate({opacity:1},300)}, 
									function(){ $(this).animate({opacity:0.5},300) });


// Email Protection

$('#email_two').html('<a href="mailto:'+$('#email_two').html().replace('|','@').replace('/','').replace(':','.')+'" title="Email: '+$('#email_two').html().replace('|','@').replace('/','').replace(':','.')+'">'+$('#email_two').html().replace('|','@').replace('/','')+'</a>');


$('#portfolio-navigation li a').hover( 
									function(){ $(this).animate({top:-3, opacity: 1},100)}, 
									function(){ $(this).animate({top:0, opacity:0.8},100) });
});



