jQuery(document).ready(function($) {

    // fade out error message bg color
    $("#messages, #comment_errors, #comment_msgs").animate({opacity: 1.0}, 3000).animate({backgroundColor: '#ffffff'}, 3000);


    // share icons on stories
    $("#bookmarks").bookmark({
        icons: "/images/bookmarks.png", 
        sites: ["delicious", "digg", "facebook", "fark", "google", "kaboodle", "mixx", "propeller", "reddit", "stumbleupon", "technorati", "twitthis", "yahoobuzz"]
    });
    $("#bookmarks ul").prepend('<li class="share">Share &#160;</li>');

    // share bookmarks on thankyou pages
    vanilla.baseUrl = location.href.split('?', 1);
    $(".thankyoubookmarks").bookmark({
        icons: "/images/bookmarks.png",
        url: vanilla.baseUrl,
        sites: ["delicious", "digg", "facebook", "fark", "google", "kaboodle", "mixx", "propeller", "reddit", "stumbleupon", "technorati", "twitthis", "yahoobuzz"]
    });
    $(".thankyoubookmarks").prepend('<p><strong>Share this with your friends:</strong></p>');

    // handlers for fields in signup stub form
    $("#updates_email, #updates_zip, #search_keywords").focus(function() {
        vanilla.swapValue(this, false);
    });
    $("#updates_email, #updates_zip, #search_keywords").blur(function() {
        vanilla.swapValue(this, true);
    });
    
    // rotating background images on homepage
    vanilla.bg_num = 2;
    $("#home_top").addClass('bg' + vanilla.bg_num);
    setInterval (function() {
        $("#home_top").removeClass('bg' + vanilla.bg_num);
        vanilla.bg_num++;
        if (vanilla.bg_num > 4) {
            vanilla.bg_num = 2;
        }
        $("#home_top").addClass('bg' + vanilla.bg_num);
    }, 15000);

});
