function maxHeight(selector) {
    var maxHeight = null;

    $(selector).each(function() {
        if (null == maxHeight) {
            maxHeight = $(this).innerHeight();
        } else {
            if ($(this).innerHeight() > maxHeight) {
                maxHeight = $(this).innerHeight();
            }
        }
    });

    return maxHeight;
}



$(function() {

    Cufon.replace('.cambria_bold', {
        fontFamily: 'Cambria-Bold',
        hover: true
    });
    Cufon.replace('.cambria, #header #nav ul li a, #Slider_Box .Slider_content h3 a, #News_Box .column .item h4 a, #News_Box .column h2, #Our_objects h2, #Our_objects .item span, .Social h2, .Newsletter h2, .Our_partners h2, .Calendar_box h2, .subpage h2.title', {
        fontFamily: 'Cambria',
        hover: true
    });

		
    Shadowbox.init();
    
    // News i aura web
    $("#Slider").bxSlider({
        mode: 'fade',
        controls: false,
        pager: true,
        auto: true,
        speed: 1000,
        pause: 8000
    });
		
    // News i aura web
    $("#Our_partners_slider").bxSlider({
        controls: true,
        pager: false,
        auto: true,
        speed: 1000,
        pause: 2000
    });
		
    // Dodanie klasy last do ostatniego elementu
    $("#header #nav ul li ul li:last-child").addClass("last");
    $("#News_Box .column ul.others li:last-child").addClass("last");
    $(".Calendar_box .inside ul li:last-child").addClass("last");
		
    // Obliczanie wysokosci i przypisywanie wszystkim elementom
    //$(".Column_height").css("height", maxHeight(".Column_height"));
    $("#News_Box .column .item").css("height", maxHeight("#News_Box .column .item")+30);
    $("#News_Box .column .item h4").css("height", maxHeight("#News_Box .column .item h4"));
    $("#News_Box .column .item p").css("height", maxHeight("#News_Box .column .item p"));
    $("#News_Box .column ul.others").css("height", maxHeight("#News_Box .column ul.others"));

		


    $("#nav ul").jessmenu({
        delay: 100,
        hoverClass: 'hover',
        arrows: false,
        animation: 'fade'
    });
    
    $("#Go-to-top").click(function() {
    	$("html, body").animate( {
    		scrollTop : 0
    	}, 1000);
    	return false;
    });   
    
});


/*
 *  Newsletter
 */

$(function() {
    $('#submitNewsletter').click(function() {
        $.ajax({
            url: "/pl/_newsletter/zapisz_do_newslettera.ajax",
            data: {
                AdresEmail: $('#AdresEmail').val()
            },
            success: function(response){
                $("#odpowiedz").show().html(response);
            // $(".Newsletter form .submit").hide();
            }
        });
    });
    $('#odpowiedz, .Newsletter .text').click(function() {
        // $(".Newsletter .submit").show();
        $("#odpowiedz").html("").hide();
    });
});
