

/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 **/
var sim_handlePrevButtonState = function(type, args) {

    var enabling = args[0];
    var leftImage = args[1];
    if(enabling) {
        leftImage.src = "templates/newunimall/img/newunimall/mostpopular_left_active.gif";    
    } else {
        leftImage.src = "templates/newunimall/img/newunimall/mostpopular_left_arrow_idle.gif";    
    }
    
};

/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the next button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: nextButtonStateHandler
 **/
var sim_handleNextButtonState = function(type, args) {

    var enabling = args[0];
    var rightImage = args[1];
    
    if(enabling) {
        rightImage.src = "templates/newunimall/img/newunimall/mostpopular_right_arrow_active.gif";
    } else {
        rightImage.src = "templates/newunimall/img/newunimall/mostpopular_right_arrow_idle.gif";
    }
    
};


/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'mycarousel'.) See the
 * HTML code below.
 **/
var sim_carousel; // for ease of debugging; globals generally not a good idea
var sim_pageLoad = function() 
{
	
    sim_carousel = new YAHOO.extension.Carousel("similar_products", 
        {
            numVisible:        4,
            animationSpeed:    0.75,
            scrollInc:         3,
            navMargin:         10,
            prevElement:     "sim_prev-arrow",
            nextElement:     "sim_next-arrow",
            size:              20,
            prevButtonStateHandler:   sim_handlePrevButtonState,
            nextButtonStateHandler:   sim_handleNextButtonState
        }
    );

};