Array.max = function( array ){
    return Math.max.apply( Math, array );
};

function equalColumns() {
    var h = new Array();
    $('.box-partner').each(function(){

         if ($.browser.webkit) h.push(($(this).height()+140))
         else h.push($(this).height());
        
    });
    var max = Array.max(h);
    $('.box-partner').css('height', max + 'px');
}

$(document).ready(function() {

    
    $('.yt-popup').colorbox({
        iframe:true,
        innerWidth:640,
        innerHeight:385,
        onOpen:function(){ var obj = document.getElementById('flashContent'); if (obj) obj.pause(); },
        onClosed:function(){ var obj = document.getElementById('flashContent'); if (obj) obj.resume(); }
    });
    

     $('.clients-bar').logoSlider({rows: 6});

    Cufon.replace('.tabs2-nav a', { fontFamily: 'DINProPl-Bold' });
    Cufon.replace('#navigation a', { fontFamily: 'DINProPl-Medium', textShadow: '#000 1px 1px', hover: true });
    Cufon.replace('.tabs-nav a, .tabs2-content-inner span', { fontFamily: 'DINProPl-Medium' });
    Cufon.replace('h2, h3, h4:not(.nasza-misja), h5', { fontFamily: 'DINProPl-Bold', letterSpacing: '0.3px' });
    Cufon.replace('h5',{fontSize: '14px', letterSpacing: '0.2px'});
    Cufon.replace('h3',{fontSize: '25px'});
    
    Cufon.replace('.pl h1.glowna',{fontSize: '36px', lineHeight: '38px', textTransform: 'uppercase'});
    Cufon.replace('.en h1.glowna',{fontSize: '34px', lineHeight: '38px', textTransform: 'uppercase'});

    equalColumns();

    var lang = $('body').attr('class');
    var currentpl = "obraz {current} z {total}";
    var currenten = "image {current} of {total}";

    $("a[rel='gallery']").colorbox({current: eval('current' + lang)});
	
   $('#navigation > li > a').addClass('level-0');
		$('#navigation > li').each(function(index, Element){
        $(this).css('z-index', 100-index);
        $(this).attr('id', 'level-0-' + (index+1));
    });

    $('#navigation ul li').each(function(index, Element){
        $(this).css('z-index', 100-index);
    });

 

    $('#navigation > li#level-0-2 > ul').addClass('nasze-spolki');

    if ($.fn.jcarousel) $('#mycarousel').jcarousel({scroll: 1});

    $('.tabs').tabs();
    $('.tabs2').tabs();

  
   
    if ($.browser.msie) {
        if ($.browser.version.substr(0,1) == '6') {
            $('#eagle, .freszlab-logo, .nasza-misja, .logo-fly-to-success, .layout-container, .shadow-top, .shadow-bottom, .logo-yt-small, .logo-fly-to, .logo-ffg-small, .logo-pah-small, .logo-iab-small, .box-partner h5').addClass('fixpng');
            DD_belatedPNG.fix('.fixpng');
            //$('#navigation > li').ie6hover();
        }
    }
    

});
