jQuery(document).ready( function() {

    //    *
    //    *       BANER GŁÓWNY - KARUZELA
    //    *
    jQuery("#mainBanerCarousel").carousel({
        dispItems: 1,
        pagination: true,
        nextBtn: '',
        prevBtn: '',
        loop: true,
        autoSlide: true,
        autoSlideInterval: 5000,
        effect: 'fade'
    });

    //*
    //*       PARTNERZY - LISTA PIERWSZA
    //*
    jQuery('#partnersGroup1').cycle({
        fx: 'custom',
        cssBefore: {
            top:  15,
            left: 0,
            zIndex: 1,
            opacity: 0
        },
        animIn:  {
            width: 155,
            height: 60,
            opacity: 1,
            top: 0
        },
        animOut: {
            opacity: 0
        },
        cssAfter: {
            zIndex: 0
        },
        delay: 0,
        speedIn: 1000,
        speedOut: 100
    });

    //*
    //*       PARTNERZY - LISTA DRUGA
    //*
    jQuery('#partnersGroup2').cycle({
        fx: 'custom',
        cssBefore: {
            top:  15,
            left: 0,
            zIndex: 1,
            opacity: 0
        },
        animIn:  {
            width: 155,
            height: 60,
            opacity: 1,
            top: 0
        },
        animOut: {
            opacity: 0
        },
        cssAfter: {
            zIndex: 0
        },
        delay: 200,
        speedIn: 1000,
        speedOut: 100
    });

    //*
    //*       PARTNERZY - LISTA TRZECIA
    //*
    jQuery('#partnersGroup3').cycle({
        fx: 'custom',
        cssBefore: {
            top:  15,
            left: 0,
            zIndex: 1,
            opacity: 0
        },
        animIn:  {
            width: 155,
            height: 60,
            opacity: 1,
            top: 0
        },
        animOut: {
            opacity: 0
        },
        cssAfter: {
            zIndex: 0
        },
        delay: 400,
        speedIn: 1000,
        speedOut: 100
    });

    //*
    //*       PARTNERZY - LISTA CZWARTA
    //*
    jQuery('#partnersGroup4').cycle({
        fx: 'custom',
        cssBefore: {
            top:  15,
            left: 0,
            zIndex: 1,
            opacity: 0
        },
        animIn:  {
            width: 155,
            height: 60,
            opacity: 1,
            top: 0
        },
        animOut: {
            opacity: 0
        },
        cssAfter: {
            zIndex: 0
        },
        delay: 600,
        speedIn: 1000,
        speedOut: 100
    });

    //*
    //*       LABEL W INPUCIE FORMULARZA NEWSLETTERA
    //*
    jQuery("#newsletterForm label").inFieldLabels();

    //*
    //*       WŁĄCZENIE FANCYBOXA
    //*
    jQuery(".fancybox").fancybox({
        cyclic: true,
        titlePosition: 'over'
    });

    //*
    //*       WŁĄCZENIE TOOLTIPA W GALERII
    //*
    jQuery("#gallery a.fancybox img[title]").tooltip({
        layout : '<div><div class="tooltipLeftSide"></div><div class="tooltip-inner"></div><div class="tooltipRightSide"></div></div>',
        tipInner : 'tooltip-inner',
        offset : [0, 50]
    });

    //    *
    //    *       PARTNERZY - USUNIĘCIE OBRAMOWANIA PRAWEGO PRZY CO TRZECIM LOGU
    //    *
    var counter = 0;
    jQuery("#partners li").each(function() {
        if(counter%3 == 2) {
            jQuery(this).css({
                "border-right" : "none"
            });
        }
        counter++;
    });

    //*
    //*       PARTNERZY - USUNIĘCIE LOGOM NA SAMYM DOLE OBRAMOWANIA DOLNEGO
    //*
    counter = jQuery("#partners li").length;
    var tempCount = (counter%3);
    if(!tempCount) {
        tempCount = 3;
    }

    for(var i=0; i<tempCount; i++) {
        jQuery("#partners li:nth-child(" + (counter - i) + ")").css({
            "border-bottom" : "none"
        });
    }

    //    *
    //    *       PARTNERZY - WYRÓWNANIE PIONOWE
    //    *
    var height = parseInt(jQuery("#partners li").css("height"));
    jQuery("#partners li").each(function() {
        var tempHeight = jQuery(this).children().children().height();

        if(tempHeight == null) {
            tempHeight = jQuery(this).children().height();
        }

        var margines = parseInt((height - tempHeight)/2);
        jQuery(this).children().css({
            "margin-top" : margines + "px"
        });
    });

    //    *
    //    *       VALIDACJA FORMULARZA KONTAKTOWEGO
    //    *
    jQuery("#contactForm2").validator({
        position : "center right",
        lang : "pl"
    });

    jQuery.tools.validator.localize("pl", {
        ':email'  		: 'Podaj poprawny e-mail.',
        ':number' 		: 'Podaj liczbę',
        '[max]'	 		: 'Podaj wartość mniejszą niż $1',
        '[min]'	 		: 'Podaj wartość większą niż $1',
        '[required]' 	: 'To pole jest obowiązkowe.'
    });
});

//*
//*       WŁĄCZENIE CUFONA
//*
Cufon.replace(".cufon", {
    hover : true
});

