$(document).ready(function(){

	$ ("div.carousel-prev").css("display","block");
	$ ("div.carousel-next").css("display","block");

});


/**
 * 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 handlePrevButtonState = function(type, args) {

	var enabling = args[0];
	var leftImage = args[1];
	if(enabling) {
		leftImage.src = "http://england.shelter.org.uk/__data/assets/image/0006/96936/up_active.gif";	
	} else {
		leftImage.src = "http://england.shelter.org.uk/__data/assets/image/0008/96938/up_inactive.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 handleNextButtonState = function(type, args) {

	var enabling = args[0];
	var rightImage = args[1];
	
	if(enabling) {
		rightImage.src = "http://england.shelter.org.uk/__data/assets/image/0011/96932/down_active.gif";
	} else {
		rightImage.src = "http://england.shelter.org.uk/__data/assets/image/0004/96934/down_inactive.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 carousel; // for ease of debugging; globals generally not a good idea
var pageLoad = function() 
{
	carousel = new YAHOO.extension.Carousel("mycarousel", 
		{
			numVisible:        1,
			animationSpeed:    0.3,
			scrollInc:         1,
			navMargin:         0,
			orientation:       "vertical",
			prevElement:     "prev-arrow",
			nextElement:     "next-arrow",
			size:              7,
			prevButtonStateHandler:   handlePrevButtonState,
			nextButtonStateHandler:   handleNextButtonState
		}
	);

};

YAHOO.util.Event.addListener(window, 'load', pageLoad);
