/*
 * MovingBoxes demo script
 */

$(function(){

	

	$('#slider').movingBoxes({
		startPanel   : 1,      // start with this panel
		width        : 585,    // overall width of movingBoxes (not including navigation arrows)
		panelWidth   : .7,     // current panel width adjusted to 70% of overall width
		buildNav     : false,   // if true, navigation links will be added
		navFormatter : function(index, panel){ return panel.find('h2 span').text(); } // function which gets nav text from span inside the panel header
	});

	// Add a slide
	var imageNumber = 0,
	// Set up demo external navigation links
	// could also set len = $('#slider-one').getMovingBoxes().totalPanels;
	navLinks = function(){
		var i, t = '', len = $('#slider-one').getMovingBoxes().totalPanels + 1;
		for ( i = 1; i < len; i++ ) {
			t += '<a href="#">' + i + '</a> ';
		}
		$('.dlinks').find('span').html(t);
	},
	
	slider = $('#slider-one'); // $('#slider-two'); // second slider

	navLinks();

	// Examples of how to move the panel from outside the plugin.
	// get (all 3 examples do exactly the same thing):
	//  var currentPanel = $('#slider-one').data('movingBoxes').currentPanel(); // returns # of currently selected/enlarged panel
	//  var currentPanel = $('#slider-one').data('movingBoxes').curPanel; // get the current panel number directly
	//  var currentPanel = $('#slider-one').getMovingBoxes().curPanel; // use internal function to return the object (essentially the same as the line above)

	// set (all 4 examples do exactly the same thing):
	//  var currentPanel = $('#slider-one').data('movingBoxes').currentPanel(2, function(){ alert('done!'); }); // returns and scrolls to 2nd panel
	//  var currentPanel = $('#slider-one').getMovingBoxes().currentPanel(2, function(){ alert('done!'); }); // just like the line above
	//  var currentPanel = $('#slider-one').movingBoxes(2, function(){ alert('done!'); }); // scrolls to 2nd panel, runs callback & returns 2.
	//  var currentPanel = $('#slider-one').getMovingBoxes().change(2, function(){ alert('done!'); }); // internal change function is the main function

	$('.dlinks').delegate('a', 'click', function(){
		// slider # stored in the text
		slider.movingBoxes( $(this).text() );
		return false;
	});


});
