/**
 * @author Garrette A. Hall <garrette.hall@gmail.com>
 * @copyright 2007
 * @license http://docs.jquery.com/Licensing
 */
GahRotator = {
    target : '#rotator',
    images : [],
    speed : 3000,
    count : 0,
    preload : function(){
        images = this.images;
        imagecache = new Array();
        for(i = 0; i < images.length; i++){
            imagecache[i] = new Image();
            imagecache[i].src = images[i];
        }
    },
    rotate : function(){
        target = this.target;
        images = this.images;
        speed = this.speed;
        count = this.count;
        $(target).fadeIn('slow',function(){
            $(target).fadeTo(speed,1,function(){
                $(target).fadeOut('slow',function(){
                    count += 1;
                    if(count >= images.length) count = 0;
                    $(target).attr('src',images[count]);
                    GahRotator.count = count;
                    GahRotator.rotate();
                });
            });
        });
    },
    init : function(target,images,speed){
        this.target = target;
        this.speed = speed;
        this.images = images;
        this.count = 0;
        this.preload();
        this.rotate();
    }
};