/*
 * Jquery goGallery Plugin by Ignacio Ricci (www.ignacioricci.com)
 * Based on the code created by Lateral Code = http://demo.lateralcode.com/slideshow-with-buttons/
 * V.1.0 = 19/02/2010
 *
 * Plugin options:
 *
 * 		$('#goSlider ul').goSlider({
 *			fadeSpeed : 1000,
 *			intervalSpeed : 4000, [Between each slide]
 *			prevId : 'prevBtn',
 *			nextId : 'nextBtn',
 *			stopId : 'stopBtn',
 *			playId : 'playBtn',
 *			currentClass : 'current',
 *			showControls : false, [If you don't want to show these controls HTML create the elements with the ID's you choose above]
 *			hideControls : false [If set to true when you click stop the play element hides and viceversa]
 *
 * 		})
 */
 
(function($){$.fn.goGallery=function(options){var defaults={fadeSpeed:1000,intervalSpeed:4000,prevId:'prevBtn',nextId:'nextBtn',stopId:'stopBtn',playId:'playBtn',currentClass:'current',showControls:false,hideControls:false},settings=$.extend({},defaults,options);$(this).each(function(){var element=$(this);var firstHeight=$(element).children('li:first').height();$(element).children('li:gt(0)').hide();$(element).children('li:last').addClass('last');$(element).children('li:first').addClass('first');$(element).parent().height(firstHeight);$(settings.playId).hide();if(settings.showControls==true){$(element).after('<p id="controllers"><a href="javascript:void(0);" id="'+settings.prevId+'">« Previous</a> <a href="javascript:void(0);" id="'+settings.nextId+'">Next »</a> <a href="javascript:void(0);" id="'+settings.stopId+'">Stop</a> <a href="javascript:void(0);" id="'+settings.playId+'">Play</a></p>');}var current=$(element).children('li:first');var interval;$(('#'+settings.nextId)).click(function(){goFwd();stop();if(settings.hideControls==true){showPause();}});$(('#'+settings.prevId)).click(function(){goBack();stop();if(settings.hideControls==true){showPause();}});$(('#'+settings.stopId)).click(function(){stop();if(settings.hideControls==true){showPlay();}});$(('#'+settings.playId)).click(function(){start();if(settings.hideControls==true){showPause();}});function goFwd(){stop();forward();start();}function goBack(){stop();back();start();}function back(){current.fadeOut(settings.fadeSpeed);current.removeClass(settings.currentClass);if(current.hasClass('first')){current=current.siblings('.last');current.fadeIn(settings.fadeSpeed);current.addClass(settings.currentClass);$(element).parent().css({'height':current.height()});}else{current=current.prev();current.fadeIn(settings.fadeSpeed);current.addClass(settings.currentClass);$(element).parent().css({'height':current.height()});}}function forward(){current.fadeOut(settings.fadeSpeed);current.removeClass(settings.currentClass);if(current.hasClass('last')){current=current.siblings('.first');current.fadeIn(settings.fadeSpeed);current.addClass(settings.currentClass);$(element).parent().css({'height':current.height()});}else{current=current.next();current.fadeIn(settings.fadeSpeed);current.addClass(settings.currentClass);$(element).parent().css({'height':current.height()});}}function showPause(){$(('#'+settings.playId)).hide();$(('#'+settings.stopId)).show();}function showPlay(){$(('#'+settings.stopId)).hide();$(('#'+settings.playId)).show();}function start(){interval=setInterval(forward,settings.intervalSpeed);}function stop(){clearInterval(interval);}$(function(){start();});});}})(jQuery);