(function(a){
    a.fn.slideshow=function(b){
        b=a.extend({timeout:1e3,slidespeed:1e3,fadespeed:1e3,delay:1e3},b);
        return this.each(function(){
            var c=a(this);
            c.children().eq(0).find('h2').css('left','608px');
            c.children().eq(0).find('p').css('left','608px');
            c.children().eq(0).css('top',0).appendTo(c).show();
            c.children().last().find('h2').animate({left:0},b.slidespeed,function(){
                $(this).parent().find('p').animate({left:0},b.slidespeed,function(){
                    setTimeout(function(){
                        d();
                    },b.timeout);
                });
            });
            d = function(){
                c.children().last().find('h2').animate({left:'-608px'},b.slidespeed,function(){
                    $(this).parent().find('p').animate({left:'-608px'},b.slidespeed,function(){
                        c.children().eq(0).hide().css('top',0);
                        c.children().eq(0).find('h2').css('left','608px');
                        c.children().eq(0).find('p').css('left','608px');
                        c.children().last().fadeOut(b.fadespeed,function(){
                            c.children().eq(0).appendTo(c).delay(b.delay).fadeIn(b.fadespeed,function(){
                                $(this).find('h2').animate({left:'0'},b.slidespeed,function(){
                                    $(this).parent().find('p').animate({left:'0'},b.slidespeed,function(){
                                        setTimeout(function(){
                                            d();
                                        },b.timeout);
                                    });
                                });
                            });
                        });
                    });
                });
            };
        });
    };
})(jQuery);

(function(a){
    a.fn.quotes=function(b){
        b=a.extend({timeout:1e3,fadespeed:1e3},b);
        return this.each(function(){
            var c=a(this);
            // reduce heigh of ul to 0, then set ul and all li's to largest height li
            c.css('height',0);
            c.children().each(function(){
                var that    = $(this),
                    thatH   = parseInt(that.css('height'),10),
                    parent  = that.parent(),
                    parentH = parseInt(parent.css('height'),10);
                if ( thatH > parentH ) parent.css('height',thatH+'px');
            });
            c.children().each(function(){
                $(this).css('height',$(this).parent().css('height'));
            });
            // animate
            c.children().first().appendTo(c).show();
            setTimeout(function(){
                d();
            },b.timeout);
            d = function(){
                c.children().last().fadeOut(b.fadespeed,function(){
                    c.children().last().prependTo(c).show();
                    setTimeout(function(){
                        d();
                    },b.timeout);
                });
            };
        });
    };
})(jQuery);

$(document).ready(function(){
    // quotes on pretty much all but homepage
    $('#quotes').quotes({timeout:6e3,fadespeed:2e3});
    // stallions on the homepage
    $('#stallions').slideshow({timeout:3e3,slidespeed:750,fadespeed:2e3,delay:500});
});
