
var Project = {

    current: 0,
    maximum: 0,

    init: function(maximum)
    {
        this.maximum = maximum;
        $('#page-project-image-alt > span:not(:first)').hide();
        $('#panel').addClass('bg-0');
    },


    nextImage: function()
    {
        if (this.current < (this.maximum-1)) {
            this.current++;
        } else {
            this.current = 0;
        }

        this.showImage();
    },

    prevImage: function()
    {
        if (this.current > 0) {
            this.current--;
        } else {
            this.current = this.maximum-1;
        }
        this.showImage();
    },

    setImage: function (cur)
    {
        if ((cur >= 0) && (cur < this.maximum)) {
            this.current = cur;
            this.showImage();
        }
    },

    showImage: function()
    {

        //$('#panel').removeClass().addClass('bg-' + this.current).fadeIn(500);

        $('#panel').stop().animate({opacity:0.3}, 'fast', function() { $(this).removeClass().addClass('bg-' + Project.current).animate({opacity:1.0}, 'fast'); });


        $('#page-project-image-alt > span').hide();
        $('#page-project-image-alt > span#thumb-' + this.current).show();

        //alert(document.preloaded[this.current].src);
        //$('#panel').css({backgroundImage: 'url(' + document.preloaded[this.current].src + ')'});


    }


}
