currentProject = 0;
projectDescriptions = new Array();
projectDescriptions[0] = "<h3>Jabeh</h3><p class=\"featured-desc\" id=\"featured-desc\">With nothing but rave reviews, Jabeh is the most successful Shinro game in the Apple App Store. Its simple and intuitive interface makes playing it an effortless and enjoyable experience, and the original art and soundtrack add a level of appeal that's unrivaled by any other.<a href=\"/projects#Jabeh\" class=\"view_button\">VIEW PROJECT</a></p>";
projectDescriptions[1] = "<h3>Prayer Book</h3><p class=\"featured-desc\" id=\"featured-desc\">Prayer Book is an iPhone app that contains hundreds of prayers from the writings of the Bahá'í Faith in English, French and Spanish. Organized by category and also searchable, accessing any prayer is just a few taps away. Once you've selected a prayer, it's presented to you in a simple and elegant interface suitable for reading and meditation.<a href=\"/projects#PrayerBook\" class=\"view_button\">VIEW PROJECT</a></p>";
projectDescriptions[2] = "<h3>Animalizer</h3><p class=\"featured-desc\" id=\"featured-desc\">With this fun little app, you can take a picture with your camera, and put your face inside the body of an Animal. There are 30 animals to choose from, so you can find just the right animal to suit your personality. When you're done, upload your picture to Facebook for all your friends to see.<a href=\"/projects#Animalizer\" class=\"view_button\">VIEW PROJECT</a></p>";
projectDescriptions[3] = "<h3>APXML</h3><p class=\"featured-desc\" id=\"featured-desc\">When Apple released the iPhone SDK, it neglected to provide the NSXMLDocument class, so there's no Objective-C method for accessing XML using the DOM. APXML is a lightweight and easy to use solution to fill in that gap. Drop this tiny LGPL library into your project, and you'll be manipulating XML in no time.<a href=\"/projects#APXML\" class=\"view_button\">VIEW PROJECT</a></p>";



/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function featured_initCallback(carousel) {

    jQuery('#arrow-right').bind('click', function() {
        if (carousel.animating || currentProject == carousel.options.size-1)
            return false;
        carousel.next();
        currentProject += 1;
        jQuery("#project-desc").fadeOut(250, function callback()
        {
            var projectDescElement = jQuery("#project-desc").empty();
            projectDescElement.append(projectDescriptions[currentProject]);
            projectDescElement.fadeIn(250);
            if (currentProject == carousel.options.size-1)  // are we at the last carousel item?
            {
                var rightArrow = jQuery(".arrow-right");
                rightArrow.addClass("arrow-right-disabled");
                rightArrow.removeClass("arrow-right");
            }
            else
            {
                // enable the left arrow
                var disabledLeftArrow = jQuery(".arrow-left-disabled");
                disabledLeftArrow.addClass("arrow-left");
                disabledLeftArrow.removeClass("arrow-left-disabled");
            }
        });
        return false;
    });

    jQuery('#arrow-left').bind('click', function() {
        if (carousel.animating || currentProject == 0)
            return false;
        carousel.prev();
        currentProject -= 1;
        jQuery("#project-desc").fadeOut(250, function callback()
        {
            var projectDescElement = jQuery("#project-desc").empty();
            projectDescElement.append(projectDescriptions[currentProject]);
            projectDescElement.fadeIn(250);
            
            if (currentProject == 0)    // are we at the first carousel item?
            {
                var leftArrow = jQuery(".arrow-left");
                leftArrow.addClass("arrow-left-disabled");
                leftArrow.removeClass("arrow-left");
            }
            else
            {
                // enable the right hand arrow
                var disabledRightArrow = jQuery(".arrow-right-disabled");
                disabledRightArrow.addClass("arrow-right");
                disabledRightArrow.removeClass("arrow-right-disabled");
            }
        });
        
        return false;
    });
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#ap_carousel").jcarousel({
        scroll: 1,
        initCallback: featured_initCallback,
        wrap: null,
        animation: 500,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});
