/*
    Filename: control.js
    Author: Jason S. Webb
    
    NOTE: jquery must be loaded prior to loading this file
*/

var fadeTimeout = 5000;

$(document).ready(function(){
    /**
     * Feature Image fading (HOME/DEFAULT PAGES)
     **/
    var elm = $("#center-stage-img img");

    if(elm.length > 0){
        var curr = 1;
        var last = 0;
        
        setInterval(function() {
            $(elm[last]).fadeOut(3000);
            $(elm[curr]).fadeIn(3000, function(){
                if ((curr + 1) < elm.length) {
                    curr = curr + 1;
                    last = curr - 1;
                } else {
                    curr = 0;
                    last = elm.length - 1;
                }
            });
        }, fadeTimeout);
        $(elm[0]).show();
     }
     
     /**
      * External DIY Carousel Controls
      **/
     var numItems = $(".diy-item").length;
     
     /*
     $(".diy-carousel-controls a").bind("click", function(e){
        e.preventDefault();
        
        var nextItem = $(this).html();
        var curLocation = $(".diy-item-container").position().left;
        
        // by dividing by the width of the item container, we account for margins that
        // may have been set on the left/right of each item
        var nextLocation = ($(".diy-item-container").width() / numItems) * (nextItem - 1);
        
        $(".diy-item-container").animate({
            left: nextLocation *(-1)+ "px"
        }, "slow");        
     });
     */
});