function addToCart(id, type) {
    $('#cart_loading_'+id).css('display','inline');
	
    $.ajax({
        type: 'GET',
        url: '?module=payment&controller=cart&command=add&id='+id+'&type='+type,
        dataType: 'html',
        error: function(){
            $('#cart_loading_'+id).css('display','none');
        },
        success: function(data){
            $('#cart_loading_'+id).attr('src','www/img/i16_ksieguj.gif');
        }
    });							
}

$(window).load(function(){

        (function() {
            $('.rotator').css('display', 'block');
            var divW = $('.rotator').parent().width();

            $('.rotator').prevAll().each(function() {
                divW -= $(this).outerWidth(true);
            });

            if (divW < 0) {
                $('.rotator').remove();
                return;
            }

            $('.rotator').width(divW);

            //var contenerW = $('.partners').width();
            var ulW = 0;

            $('.rotator li').each(function() {
                ulW += $(this).outerWidth(true);
            });

            if ($('.rotator ul').width() >= ulW)
            {
                return;
            }

            var clone = $('.rotator li').clone(true).addClass('test');

            clone.reverse = [].reverse;

            clone.reverse().insertAfter($('.rotator li:last'));

            $('.rotator ul').width(ulW*2);


            var ul = $('.rotator ul');

            function slide() {
                var duration = Math.round((ulW + parseInt(ul.css('margin-left'))) * 20);
                ul.animate({
                    marginLeft: -ulW
                }, duration, 'linear', function() {
                    ul.css('margin-left', 0);
                    slide();
                });
            }

            slide();

            ul.mouseenter(function() {
                $(this).stop();
            })

            ul.mouseleave(function() {
                slide();
            })


        })();



        (function() {
            $('.hrotator').css('display', 'block');
            var divH = $('.hrotator').parent().height();

            $('.hrotator').prevAll().each(function() {
                divH -= $(this).outerHeight(true);
            });

            if (divH < 0) {
                $('.hrotator').remove();
                return;
            }

            $('.hrotator').height(divH);

            //var contenerW = $('.partners').width();
            var ulH = 0;

            $('.hrotator li').each(function() {
                ulH += $(this).outerHeight(true);
            });

            if ($('.hrotator ul').height() >= ulH)
            {
                return;
            }

            var clone = $('.hrotator li').clone(true).addClass('test');

            clone.reverse = [].reverse;

            clone.reverse().insertAfter($('.hrotator li:last'));

            $('.hrotator ul').width(ulH*2);


            var ul = $('.hrotator ul');

            function slide() {
                var duration = Math.round((ulH + parseInt(ul.css('margin-top'))) * 20);
                ul.animate({
                    marginTop: -ulH
                }, duration, 'linear', function() {
                    ul.css('margin-top', 0);
                    slide();
                });
            }

            slide();

            ul.mouseenter(function() {
                $(this).stop();
            })

            ul.mouseleave(function() {
                slide();
            })

        })();

       //$('#campMain').jshowoff({controls:false,speed:10000,links:false });
       
       //$('#banner').jshowoff({controls:false,speed:15000,links:false});
});

$(document).ready(function(){

    $('div.row').hover(function(){
        $(this).children('.sub').show();
    },function(){
        $(this).children('.sub').hide();
    });
	
    $('#newsletter_field').focus(function(){
        if($(this).val() == 'Twój e-mail')
        {
            $(this).val('');
        }
    });
    $('#newsletter_field').blur(function(){
        if($(this).val() == '')
        {
            $(this).val('Twój e-mail');
        }
    });
});

$(document).ready(function() {

    
    var licznik = $('#campMain').find('div');
    if(licznik.length >1 ){
        contentRotatorCamp($("#campMain > div:first"));
    }
    licznik = $('#banner').find('div');
    if(licznik.length >1 ){
        contentRotatorBanner($("#banner > div:first"));
    }

});

var doAnimate = true;
function contentRotatorCamp(content) {
    if (doAnimate) {

        content.fadeOut("fast", function(content) {

            return function() {

                /* HIDE ALL ITEMS */
                $("#campMain > div").css('z-index','8');
                $("#campMain > div").fadeOut(2500);
                content.css('z-index','10');

                content.fadeIn(2500, function() {

                    /* GO BACK TO FIRST ITEM */

                    if ($(this).attr("id") == $("#campMain > div:last").attr("id")) {

                        setTimeout(function() {

                            contentRotatorCamp($("#campMain > div:first"));

                        }, 5000);

                    }

                    else { /* FADE IN NEXT ITEM  */

                        setTimeout(function() {

                        contentRotatorCamp($(content.next()));

                        }, 5000);

                    }

                });

            };

        } (content));

    }

}
function contentRotatorBanner(content) {
    if (doAnimate) {

        content.fadeOut("fast", function(content) {

            return function() {

                /* HIDE ALL ITEMS */
                $("#banner > div").css('z-index','8');
                $("#banner > div").fadeOut(2500);
                content.css('z-index','10');
                content.fadeIn(2500, function() {


                    /* GO BACK TO FIRST ITEM */

                    if ($(this).attr("id") == $("#banner > div:last").attr("id")) {

                        setTimeout(function() {

                            contentRotatorBanner($("#banner > div:first"));

                        }, 5000);

                    }

                    else { /* FADE IN NEXT ITEM  */

                        setTimeout(function() {

                        contentRotatorBanner($(content.next()));

                        }, 5000);

                    }

                });

            };

        } (content));

    }

}
