
var IndexObject = {

    OnIndexLoad: function ()
    {
        var index_marquee_div = document.getElementById("IndexMarquee");
        if(index_marquee_div)
        {
            this.index_marquee = new Marquee(index_marquee_div, {
                direction: MarqueeDirection.Right,
                interval: 25,
                autoStart: false});
            
            this.index_marquee.StartScrolling();
        }

        jQuery("#SiteTitle").animate({marginRight: "0px"}, 1200, IndexObject.StartGlowing);

        var imagesToPreload = jQuery("#ThumbnailPics img")
            .css("cursor", "pointer")
            .click(IndexObject.OnThumbnailClick);

        var i;
        var paths = new Array();
        for(i = 0; i < imagesToPreload.length; i++)
        {
            paths[i] = IndexObject.GetRealSource(imagesToPreload[i].getAttribute("src"));
        }
        var preloader = new ImagePreloader(paths);
        preloader.StartLoading();
    },

    OnThumbnailClick: function()
    {
        jQuery("#FullPic")
            .attr("src", IndexObject.GetRealSource(this.getAttribute("src")));
    },

    GetRealSource: function(cropped_src)
    {
        return cropped_src.replace("/crop_on_the_fly.php?img=", "").replace("&mw=50&mh=40", "");
    },

    StartGlowing: function() {

        var _animDuration = 700;

        jQuery("#SiteTitle").animate({color: "#424242"}, _animDuration, function() {
            jQuery("#SiteTitle").animate({color: "#A6A6A6"}, 1500, function() {
                jQuery("#SiteTitle").animate({color: "#C1C1C1"}, 1500, function() {
                    jQuery("#SiteTitle").animate({color: "#985689"}, 1500, function() {
                        jQuery("#SiteTitle").animate({color: "#326598"}, 1500, function() {
                            jQuery("#SiteTitle").animate({color: "#145753"}, 1500, IndexObject.StartGlowing);
                        });
                    });
                });
            });
        })
    },

    index_marquee: null

}


addEvent(window, "load", IndexObject.OnIndexLoad);