// JavaScript Document
(function($){
    $.fn.extend({
        carusel: function(){
            
            var items = $('img', this)
            
            items.css({
                'position': 'absolute',
                'top': 0,
                'left': 0,
                'z-index': 1,
                'opacity': 0
            });
            
            $('img:eq(0)', this).addClass('active').css({
                'z-index': 10,
                'opacity': 1
            });
            
            var speed = 5000
            var animspeed = 1000
            
            active = 0
            setInterval(function(){
                next = active+1              
                if ((active+1)>=items.size()){
                    next = 0
                }
                
                items
                    .filter(function(index){ return index !== active; })
                    .css({
                        'z-index': 1,
                        'opacity': 0
                    });
                                
                $(items[active])
                    .removeClass('active')
                    .css({
                        'z-index': 2
                    })
                
                $(items[next])
                    .addClass('active')
                    .css({
                        'z-index': 10
                    })
                    .animate({
                            'opacity': 1
                    },animspeed)
                active = next
            },speed)
        }
    })
})(jQuery)

$(document).ready(function()
{
    $('#all #header #search_top input[name="q"]').attr('placeholder','Поиск по сайту')
    	
    $(document).placeholder();
    $('.header-carusel').carusel()
})

