/*******************************************************************
 * cfc.carousel object is for using the jquery.cfc_carousel plugin. 
 * The start method starts the carousel and creates initializes callback
 * functions for the play, pause, next, and back buttons on the carousel.
 *
 * @Author primmee
 *
 * JavaScript File Dependencies  (in order):
 *   jQuery
 *   cfc.js
 *   jquery.cfc_carousel.js
 *******************************************************************/
//Create Namespace
cfc.namespace("carousel");

/*
 * Description of static object which in turn is actually
 * a property of the namespace you created with "yourNamespace"
 */
cfc.carousel = (function(objSpec) {

    /****************************************
     * PRIVATE Members -- Dependencies
     ****************************************/
    // state any objects this object is dependent upon like jQuery
	     var $ = objSpec.$;

    
    /****************************************
     * PRIVATE Members
     ****************************************/
    // Except this object's dependencies, place all private functions, variables, etc. here 
    
    /****************************************
     * PUBLIC API
     ****************************************/
    // create obj to hold the public API and will be returned to the namespace
    var publicApi = {};
    
    // assign public members to publicApi
  //start carousel on page load and bind actions to page events
    publicApi.start = (function(){
        $('#c-carousel ul.c-carouselList').cfc_carousel({
            initCallback: function(c){
                $('#c-pauseCtrl').click(function(ev){
                    $('#c-carouselCtrls').toggleClass('c-carouselPlay').toggleClass('c-carouselPause');
                    if (c.timer) 
                        c.stopAuto();
                    else 
                        c.startAuto();
                    ev.preventDefault();
                });
                
                $('#c-nextCtrl').click(function(ev){
                    c.stopAuto();
                    c.goNext();
                    ev.preventDefault();
                });
                
                $('#c-prevCtrl').click(function(ev){
                    c.stopAuto();
                    c.goPrev();
                    ev.preventDefault();
                });
            }
        });


	 });
	 
	 //initialize the page
    publicApi.initPage = (function(){
        publicApi.start(); 
  
    }); 
	
    return publicApi;
 
/*
 * Optional literal objSpec parameter used to set all necessary intenral parameters.
 * All dependencies should be provided through this objSpec parameter.
 */ 
})(
{
	$: jQuery
});

/*******************************************************************
 Load scripts in page when DOM ready
 *******************************************************************/
$(document).ready(function(){
    cfc.carousel.start();
});

//alert("cfc.carousel");


