﻿// ON DOCUMENT READY
$(document).ready(function() {
    // BLOG FEED ON HOMEPAGE (JSON)
    $.getJSON('http://blog.souplantation.com/feed/json/?callback=?',
        function(data) {
            var result = '';
            $.each(data.items, function(i, item) {
                if (i == 1) return false; //only display 1 post
                var plen = (this.title.length > 25) ? 27 : 70;
                var blogimg = (this.image != "") ? this.image : "http://blog.souplantation.com/wp-content/uploads/2010/01/sprout11.jpg";
                result += "<a href=\"" + this.link + "\"><img class=\"blog-thumb\" src=\"" + blogimg + "\" width=\"215\" /></a><h4>" + this.title.substring(0, 50) + "</h4><p>" + this.description.substring(0, plen) + "... <a href=\"" + this.link + "\">read more</a></p>";
            })
            if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
                $("img.icon-featured-blog").attr({ src: "/images/icon-featured-blog.gif" });
            }
            $(".fresh-ideas").html(result);
        });

    // JCarousel LITE
    $(".jcarousel").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        auto: 9000,
        scroll: 1,
        speed: 550,
        easing: "backout",
        visible: 4
    });

    // HOMEPAGE FLASH
    $('#hmflash').flash(
        { src: '../flash/gardenfresh_home.swf',
            width: 1032,
            height: 356,
            wmode: 'transparent'
        },
        { expressInstall: true }
    );
});