$(document).ready(function(){

   $("#newsletter-join").fadeIn(900);

	$("#primary-nav li a").hover(function() {

		$(this).stop().parent().find("ul").fadeIn('fast').show();
		$(this).addClass("subhover");
		$(this).parent().hover(function() {
		}, function(){
			$(this).stop().parent().find("ul").fadeOut('fast');
			$(this).removeClass("subhover");
		});
		});
	
	$("#menu ul li a").hover(function() {

		$(this).stop().parent().find("ul").fadeIn('fast').show();
		$(this).addClass("subhover");
		$(this).parent().hover(function() {
		}, function(){
			$(this).stop().parent().find("ul").fadeOut('fast');
			$(this).removeClass("subhover");
		});
		});
	
	//$("#newsletter-form .button").attr('src', ''); 
	
		$("#newsletter-join a.close").click(function() { 
       $("#newsletter-join").fadeOut('slow');
        return false;});
		
	// Primary Nav Hover Animation
	
	$("#primary-nav li a").hover(function() {
$(this).animate({ backgroundColor: "#c60001" }, 600);
},function() {
$(this).animate({ backgroundColor: "#fff" }, 400);
});

// Click Jump
	$("a").mousedown(function(){
		if( $(this).css('position') == 'absolute') {}
		else
			{	$(this).css({'position' : 'relative', 'top' : '1px'} ) 
			
	
	$(this).mouseup(function()  {
     		 $(this).css({'position' : 'none', 'top' : '0px'})
									 });
	}
});

$("a img, #logo a").hover( 
									function(){ $(this).animate({opacity:0.6}, 200) }, 
									function(){ $(this).animate({opacity:1}, 200) } 
								);
// Losowe
$("#random ul li:eq(2)").css("marginRight","18px");
$("#random ul li:eq(5)").css("marginRight","18px");
$("#random ul li:eq(8)").css("marginRight","0");
$(".connect a").css({opacity: 0.7});
$(".connect a").hover( function (){ $(this).animate({opacity:1}, 200); $(this).animate({top:-3},300);}, function(){ $(this).animate({ opacity:0.7},350); $(this).animate({top:0},300);} )

// Tipsy
$('#random ul li a').tipsy({gravity:'s'});

$('#random ul li a').hover( 
									function(){ $(this).animate({top:-3},100)}, 
									function(){ $(this).animate({top:0},100) });

 // border-bottom: 1px solid #DDDDDD;
  //  margin-top: 1px;

// Equal Height

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

equalHeight($(".content .excerpt"));

 $('#slider').cycle({ 
        fx:     'fade', 
        speed:   600, 
        timeout: 5000,  
        before: function() {  
            $('#caption').html(this.alt); 
        } 
    }); 
  $('#references-slider').cycle({ 
        fx:     'fade', 
        speed:   400, 
        timeout: 10000, 
		  after: onAfter,
        before: function() {  
            $('#caption').html(this.alt); 
        } 
    }); 
// Autoheight referencji
function onAfter(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#prev,#prev2,#prev3,#prev4,#prev5')[index == 0 ? 'hide' : 'show']();
$('#next,#next2,#next3,#next4,#next5')[index == opts.slideCount - 1 ? 'hide' : 'show']();
//get the height of the current slide
var $ht = $(this).height();
//set the container's height to that of the current slide
$(this).parent().animate({height: $ht});
}



});
