/**
 * Слайдер
 */
$(function(){
	if ($('div#slider ul li').size() > 1) {
        function animate(direction, click)
        {
            if (direction == 'prev') {
                $('div#slider ul').animate({marginLeft: '-=290'}, function(){
                    $('div#slider ul li:first-child').appendTo('div#slider ul');
                    $('div#slider ul').css({'margin-left':'0'});
                });
            } else if (direction == 'next') {
                $('div#slider ul li:last-child').prependTo('div#slider ul');
                $('div#slider ul').css({'margin-left':'-290px'});
                $('div#slider ul').animate({marginLeft: '+=290'});
            }
            if (click) {
                clearInterval(timeout);
            }
        }
        $('img.#slider_prev').click(function(){animate('prev', true);});

        $('img.#slider_next').click(function(){animate('next', true);});
    
        var timeout = setInterval(function(){animate('next', false);}, 5000);
	}
});
