/*
 * Slides, A Slideshow Plugin for jQuery
 * Intructions: http://slidesjs.com
 * By: Nathan Searles, http://nathansearles.com
 * Version: 1.1.9
 * Updated: September 5th, 2011
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 *Changes made by Gary Escudero for sendtonews.com
 *Add options for:
 * loop
 * onFinish()
 * playPauseToggle
 * playPauseToggle class
 * pause on hover class
 *  
 *    
 */
(function($){
	
	var methods = {
		init : function( options ) {
			
			return this.each(function(){
				return	initSlides(this, options);
			});
				
		},
		destroy : function( ) {

			return this.each(function(){

				var $this = $(this),
				data = $this.data('slides');

				// Namespacing FTW
				
				data.tooltip.remove();
				$this.removeData('slides');

			})

		},
		next : function( ) { 
			return this.each(function(){
				var slidesObj = $(this).data('slides');
				if (slidesObj) {
					next(slidesObj);
					$(this).data('slides', slidesObj)
				}
				
				return $(this);
			})
		},
		play: function( interval ) { 
			return this.each(function(){
				var slidesObj = $(this).data('slides');
				if (slidesObj) {
					if (interval) {
						slidesObj.option.play = interval;
					}
					play(slidesObj);
					$(this).data('slides', slidesObj)
				}
				return $(this);
			})
				
		}	,
		current: function() { 
			//	return this.each(function(){
			var slidesObj = $(this).data('slides');
			if (slidesObj) {
				return slidesObj.control.children(':eq('+ slidesObj.current +')', slidesObj.elem);
				$(this).data('slides', slidesObj)
			}
			return null;
		//	})
		},
		stop: function() { 
			return this.each(function(){
				var slidesObj = $(this).data('slides');
				if (slidesObj) {
					stop(slidesObj);
					$(this).data('slides', slidesObj)
				}
				return $(this);
			})
		},
		lockCurrentSlide: function() { 
			return this.each(function(){
				var slidesObj = $(this).data('slides');
				if (slidesObj) {
					slidesObj.locked=1;
					$(this).data('slides', slidesObj)
				}
				return $(this);
			})
		},
		unlockCurrentSlide: function() { 
			return this.each(function(){
				var slidesObj = $(this).data('slides');
				if (slidesObj) {
					slidesObj.locked=0;
					$(this).data('slides', slidesObj)
				}
				return $(this);
			})
		}
		

	};
	
	$.fn.slides = function( method ) {
    
		if ( methods[method] ) {
			return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			return methods.init.apply( this, arguments );
		} else {
			$.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
		}    
  
	};

	
	function initSlides (target, option ) {
		// override defaults with specified option
		option = $.extend( {}, $.fn.slides.option, option );

		// wrap slides in control container, make sure slides are block level
		$('.' + option.container, target).children().wrapAll('<div class="slides_control"/>');
			
			
			
		var elem = target,
		slidesObj = $(elem).data('slides'),
		control = $('.slides_control',elem),
		total = control.children().size(),
		width = control.children().outerWidth(),
		height = control.children().outerHeight(),
		start = option.start - 1,
		effect = option.effect.indexOf(',') < 0 ? option.effect : option.effect.replace(' ', '').split(',')[0],
		paginationEffect = option.effect.indexOf(',') < 0 ? effect : option.effect.replace(' ', '').split(',')[1],
		next = 0, prev = 0, number = 0, current = 0, loaded, active, clicked, position, direction, imageParent, 
		pauseTimeout, playInterval, userPaused = 0, locked = 0;
		
		//garyescudero if the div is hidden show it for a second so we can get actually height and width - only a problem with older jquery
		if (height == 0 && width == 0) {
			childH = parseInt(control.children().css('height'))
			+ parseInt(control.children().css('padding-top'))
			+ parseInt(control.children().css('padding-bottom'));
			//+ parseInt(control.children().css('border-top-width')) // Doesn't work in ie8??'
			//+ parseInt(control.children().css('border-bottom-width'));
			childW = parseInt(control.children().css('width'))
			+ parseInt(control.children().css('padding-left'))
			+ parseInt(control.children().css('padding-right'));
			//+ parseInt(control.children().css('border-left-width'))
			//+ parseInt(control.children().css('border-right-width'));
			
			width = childW;
			height = childH;
		}

			
		// if the data has not already been initialized
		if ( !slidesObj ) {
	
			// is there only one slide?
			if (total < 2) {
				// Fade in .slides_container
				$('.' + option.container, target).fadeIn(option.fadeSpeed, //option.fadeEasing, 
					function(){
						// let the script know everything is loaded
						loaded = true;
						// call the loaded funciton
						option.slidesLoaded();
					});
				// Hide the next/previous buttons
				$('.' + option.next + ', .' + option.prev).fadeOut(0);
			//return false;
			}
				
			// error corection for start slide
			if (start < 0) {
				start = 0;
			}
			
			if (start > total) {
				start = total - 1;
			}
					
			// change current based on start option number
			if (option.start) {
				current = start;
			}
			
			// randomizes slide order
			if (option.randomize) {
				control.randomize();
			}
			
			// make sure overflow is hidden, width is set
			$('.' + option.container, elem).css({
				overflow: 'hidden',
				// fix for ie
				position: 'relative'
			});
			
			// set css for slides
			control.children().css({
				position: 'absolute',
				top: 0, 
				left: width,
				zIndex: 0,
				display: 'none'
			});
			
			// set css for control div
			control.css({
				position: 'relative',
				// size of control 3 x slide width
				width: (width * 3),
				// set height to slide height
				height: height,
				// center control to slide
				left: -width
			});
			
			// show slides
			$('.' + option.container, elem).css({
				display: 'block'
			});

			// if autoHeight true, get and set height of first slide
			if (option.autoHeight) {
				control.children().css({
					height: 'auto'
				});
				control.animate({
					height: control.children(':eq('+ start +')').outerHeight()
				},option.autoHeightSpeed);
			}
			

			
			slidesObj = {
				target : elem,
				elem : elem,
				option : option,
				control : control,
				total : total,
				width : width,
				height : height,
				start : start,
				effect : effect,
				paginationEffect : paginationEffect,
				next : next, 
				prev : prev, 
				number : number, 
				current : current, 
				loaded : loaded, 
				active : active, 
				clicked : clicked, 
				position : position, 
				direction : direction, 
				imageParent: imageParent,
				pauseTimeout : pauseTimeout, 
				playInterval : playInterval,
				userPaused: userPaused,
				locked : locked
			};
			
			
			
			// checks if image is loaded
			if (slidesObj.option.preload && slidesObj.control.find('img:eq(' + slidesObj.start + ')').length) {
				// adds preload image
				$('.' + slidesObj.option.container, slidesObj.elem).css({
					background: 'url(' + slidesObj.option.preloadImage + ') no-repeat 50% 50%'
				});
				
				// gets image src, with cache buster
				var img = slidesObj.control.find('img:eq(' + slidesObj.start + ')').attr('src') + '?' + (new Date()).getTime();
				
				// check if the image has a parent
				if ($('img', slidesObj.elem).parent().attr('class') != 'slides_control') {
					// If image has parent, get tag name
					imageParent = slidesObj.control.children(':eq(0)')[0].tagName.toLowerCase();
				} else {
					// Image doesn't have parent, use image tag name
					imageParent = slidesObj.control.find('img:eq(' + slidesObj.start + ')');
				}

				// checks if image is loaded
				slidesObj.control.find('img:eq(' + slidesObj.start + ')').attr('src', img).load(function() {
					// once image is fully loaded, fade in
					slidesObj.control.find(imageParent + ':eq(' + slidesObj.start + ')').fadeIn(slidesObj.option.fadeSpeed, //slidesObj.option.fadeEasing, 
						function(){
							$(target).css({
								zIndex: 5
							});
							// removes preload image
							$('.' + slidesObj.option.container, slidesObj.elem).css({
								background: ''
							});
							// let the script know everything is loaded
							slidesObj.loaded = true;
							// call the loaded funciton
							slidesObj.option.slidesLoaded();
						});
				});
			} else {
				// if no preloader fade in start slide
				control.children(':eq(' + start + ')').fadeIn(option.fadeSpeed, //option.fadeEasing, 
					function(){
						// let the script know everything is loaded
						slidesObj.loaded = true;
						// call the loaded funciton
						slidesObj.option.slidesLoaded();
					});
			}
			
			// click slide for next
			if (slidesObj.option.bigTarget) {
				// set cursor to pointer
				slidesObj.control.children().css({
					cursor: 'pointer'
				});
				// click handler
				slidesObj.control.children().click(function(){
					next(slideObj);
					return false;
				});									
			}
			
			// pause on mouseover
			if (slidesObj.option.hoverPause && slidesObj.option.play && !slidesObj.userPaused) {
				slidesObj.control.bind('mouseover',function(){
					// on mouse over stop
					stop(slidesObj);
				});
				slidesObj.control.bind('mouseleave',function(){
					// on mouse leave start pause timeout
					pause(slidesObj, slidesObj.option.pause);
				});
			}
			
			if (slidesObj.option.hoverLock) {
				slidesObj.control.bind('mouseover',function(){
					// on mouse over lock the slideshow so next doesn't work
					slidesObj.locked=1;
				});
				slidesObj.control.bind('mouseleave',function(){
					slidesObj.locked=0;
				});
			}
			
			// generate next/prev buttons
			if (slidesObj.option.generateNextPrev) {
				$('.' + slidesObj.option.container, slidesObj.elem).after('<a href="#" class="'+ slidesObj.option.prev +'">Prev</a>');
				$('.' + slidesObj.option.prev, slidesObj.elem).after('<a href="#" class="'+ slidesObj.option.next +'">Next</a>');
			}
			
			// next button
			$('.' + slidesObj.option.next ,slidesObj.elem).click(function(e){
				e.preventDefault();
				next(slidesObj);
			});
			
			// previous button
			$('.' + slidesObj.option.prev, slidesObj.elem).click(function(e){
				e.preventDefault();
				prev(slidesObj);
				
			});
			
			// generate pagination
			if (slidesObj.option.generatePagination) {
				// create unordered list
				if (slidesObj.option.prependPagination) {
					$(slidesObj.elem).prepend('<ul class='+ slidesObj.option.paginationClass +'></ul>');
				} else {
					$(slidesObj.elem).append('<ul class='+ slidesObj.option.paginationClass +'></ul>');
				}
				// for each slide create a list item and link
				slidesObj.control.children().each(function(){
					$('.' + slidesObj.option.paginationClass, slidesObj.elem).append('<li><a href="#'+ number +'">'+ (number+1) +'</a></li>');
					number++;
				});
			} else {
				// if pagination exists, add href w/ value of item number to links
				$('.' + slidesObj.option.paginationClass + '  a', slidesObj.elem).each(function(){
					$(this).attr('href', '#' + number);
					number++;
				});
			}
			
			// add current class to start slide pagination
			$('.' + slidesObj.option.paginationClass + ' :eq('+ slidesObj.start +')', slidesObj.elem).addClass(slidesObj.option.currentClass);
			
			// click handling 
			$('.' + slidesObj.option.paginationClass + '  a', slidesObj.elem ).click(function(){
				// pause slideshow
				if (slidesObj.option.play  && !slidesObj.userPaused) {
					pause(slidesObj, slidesObj.option.pause);
				}
				// get clicked, pass to animate function					
				slidesObj.clicked = $(this).attr('href').match('[^#/]+$');
				// if current slide equals clicked, don't do anything
				if (slidesObj.current != slidesObj.clicked) {
					animate(slidesObj, 'pagination', slidesObj.paginationEffect, slidesObj.clicked);
				}
				return false;
			});
			
			// click handling 
			$('a.link', slidesObj.elem).click(function(){
				// pause slideshow
				if (slidesObj.option.play  && !slidesObj.userPaused) {
					pause(slidesObj, slidesObj.option.pause );
				}
				// get clicked, pass to animate function					
				slidesObj.clicked = $(this).attr('href').match('[^#/]+$') - 1;
				// if current slide equals clicked, don't do anything
				if (slidesObj.current != slidesObj.clicked) {
					animate(slidesObj, 'pagination', slidesObj.paginationEffect, slidesObj.clicked);
				}
				return false;
			});
		
			// start playing the slides 
			if (slidesObj.option.play) {
				play(slidesObj);
			}
			
			// gary - add play/pause button option
			if (slidesObj.option.playPauseToggle) {
				$('.' + slidesObj.option.playPauseToggleClass , slidesObj.elem ).click(function(){
					// pause slideshow
					if (!slidesObj.userPaused) {
						pause(slidesObj, slidesObj.option.playPauseToggle, function() {
							$('.' + slidesObj.option.playPauseToggleClass , slidesObj.elem ).removeClass(slidesObj.option.pausedClass);
							slidesObj.userPaused = 0;
						});
						$(this).addClass(slidesObj.option.pausedClass);
						slidesObj.userPaused = 1;
					} else {
						play(slidesObj);
						$(this).removeClass(slidesObj.option.pausedClass);
						slidesObj.userPaused = 0;
					}
					return false;
				});
			}
				
			$(elem).data('slides', slidesObj);
		}
	}
	
	// animate slides
	function animate(slidesObj, direction, effect, clicked) {
		if (!slidesObj.active && slidesObj.loaded) {
			slidesObj.active = true;
			// start of animation
			slidesObj.option.animationStart(slidesObj.current + 1);
			switch(direction) {
				case 'next':
					// change current slide to previous
					slidesObj.prev = slidesObj.current;
					// get next from current + 1
					slidesObj.next = slidesObj.current + 1;
					// if last slide, set next to first slide
					if (slidesObj.total === slidesObj.next && slidesObj.option.loop) {
						slidesObj.next = 0;
						slidesObj.option.onFinish();
					} else if (slidesObj.total === slidesObj.next) {
						stop(slidesObj);
						slidesObj.option.onFinish();
					} // else use next
					
					// set position of next slide to right of previous
					slidesObj.position = slidesObj.width*2;
					// distance to slide based on width of slides
					direction = -slidesObj.width*2;
					// store new current slide
					slidesObj.current = slidesObj.next;
					break;
				case 'prev':
					// change current slide to previous
					slidesObj.prev = slidesObj.current;
					// get next from current - 1
					slidesObj.next = slidesObj.current - 1;
					// if first slide, set next to last slide
					slidesObj.next = slidesObj.next === -1 ? slidesObj.total-1 : slidesObj.next;								
					// set position of next slide to left of previous
					slidesObj.position = 0;								
					// distance to slide based on width of slides
					direction = 0;		
					// store new current slide
					slidesObj.current = slidesObj.next;
					break;
				case 'pagination':
					// get next from pagination item clicked, convert to number
					slidesObj.next = parseInt(clicked,10);
					// get previous from pagination item with class of current
					slidesObj.prev = $('.' + slidesObj.option.paginationClass + ' li.'+ slidesObj.option.currentClass +' a', slidesObj.elem).attr('href').match('[^#/]+$');
					// if next is greater then previous set position of next slide to right of previous
					if (slidesObj.next > slidesObj.prev) {
						slidesObj.position = slidesObj.width*2;
						direction = -slidesObj.width*2;
					} else {
						// if next is less then previous set position of next slide to left of previous
						slidesObj.position = 0;
						direction = 0;
					}
					// store new current slide
					slidesObj.current = slidesObj.next;
					break;
			}

			// fade animation
			if (effect === 'fade') {
				// fade animation with crossfade
				if (slidesObj.option.crossfade) {
					// put hidden next above current
					slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).css({
						zIndex: 10
					// fade in next
					}).fadeIn(slidesObj.option.fadeSpeed, //slidesObj.option.fadeEasing,  commented out jquery doesn't have this param until 1.4.3'
						function(){
							if (slidesObj.option.autoHeight) {
								// animate container to height of next
								slidesObj.control.animate({
									height: slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).outerHeight()
								}, slidesObj.option.autoHeightSpeed, function(){
									// hide previous
									slidesObj.control.children(':eq('+ slidesObj.prev +')', slidesObj.elem).css({
										display: 'none',
										zIndex: 0
									});								
									// reset z index
									slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).css({
										zIndex: 0
									});									
									// end of animation
									slidesObj.option.animationComplete(slidesObj.next + 1);
									slidesObj.active = false;
								});
							} else {
								// hide previous
								slidesObj.control.children(':eq('+ slidesObj.prev +')', slidesObj.elem).css({
									display: 'none',
									zIndex: 0
								});									
								// reset zindex
								slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).css({
									zIndex: 0
								});									
								// end of animation
								slidesObj.option.animationComplete(slidesObj.next + 1);
								slidesObj.active = false;
							}
						});
				} else {
					// fade animation with no crossfade
					slidesObj.control.children(':eq('+ slidesObj.prev +')', slidesObj.elem).fadeOut(slidesObj.option.fadeSpeed,  //slidesObj.option.fadeEasing, 
						function(){
							// animate to new height
							if (slidesObj.option.autoHeight) {
								slidesObj.control.animate({
									// animate container to height of next
									height: slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).outerHeight()
								}, slidesObj.option.autoHeightSpeed,
								// fade in next slide
								function(){
									slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).fadeIn(slidesObj.option.fadeSpeed//, slidesObj.option.fadeEasing
										);
								});
							} else {
								// if fixed height
								slidesObj.control.children(':eq('+ slidesObj.next +')', slidesObj.elem).fadeIn(slidesObj.option.fadeSpeed, //slidesObj.option.fadeEasing, 
									function(){
										// fix font rendering in ie, lame
										if($.browser.msie) {
											$(this).get(0).style.removeAttribute('filter');
										}
									});
							}									
							// end of animation
							slidesObj.option.animationComplete(slidesObj.next + 1);
							slidesObj.active = false;
						});
				}
			// slide animation
			} else {
				// move next slide to right of previous
				slidesObj.control.children(':eq('+ slidesObj.next +')').css({
					left: slidesObj.position,
					display: 'block'
				});
				// animate to new height
				if (slidesObj.option.autoHeight) {
					slidesObj.control.animate({
						left: direction,
						height: slidesObj.control.children(':eq('+ slidesObj.next +')').outerHeight()
					},slidesObj.option.slideSpeed, slidesObj.option.slideEasing, function(){
						slidesObj.control.css({
							left: -slidesObj.width
						});
						slidesObj.control.children(':eq('+ slidesObj.next +')').css({
							left: slidesObj.width,
							zIndex: 5
						});
						// reset previous slide
						slidesObj.control.children(':eq('+ slidesObj.prev +')').css({
							left: slidesObj.width,
							display: 'none',
							zIndex: 0
						});
						// end of animation
						slidesObj.option.animationComplete(slidesObj.next + 1);
						slidesObj.active = false;
					});
				// if fixed height
				} else {
					// animate control
					slidesObj.control.animate({
						left: direction
					},slidesObj.option.slideSpeed, slidesObj.option.slideEasing, function(){
						// after animation reset control position
						slidesObj.control.css({
							left: -slidesObj.width
						});
						// reset and show next
						slidesObj.control.children(':eq('+ slidesObj.next +')').css({
							left: slidesObj.width,
							zIndex: 5
						});
						// reset previous slide
						slidesObj.control.children(':eq('+ slidesObj.prev +')').css({
							left: slidesObj.width,
							display: 'none',
							zIndex: 0
						});
						// end of animation
						slidesObj.option.animationComplete(slidesObj.next + 1);
						slidesObj.active = false;
					});
				}
			}
			// set current state for pagination
			if (slidesObj.option.pagination) {
				// remove current class from all
				$('.'+ slidesObj.option.paginationClass +' li.' + slidesObj.option.currentClass, slidesObj.elem).removeClass(slidesObj.option.currentClass);
				// add current class to next
				$('.' + slidesObj.option.paginationClass + ' li:eq('+ slidesObj.next +')', slidesObj.elem).addClass(slidesObj.option.currentClass);
			}
		}
	} // end animate function
	
	function stop(slidesObj) {
		// clear interval from stored id
		clearInterval($(slidesObj.elem).data('interval'));
		return true;
	}

	function pause(slidesObj , timeout, onResume) {
		if (!slidesObj.locked) {
			if (timeout) {
				// clear timeout and interval
				clearTimeout($(slidesObj.elem).data('pause'));
				clearInterval($(slidesObj.elem).data('interval'));
				// pause slide show for option.pause amount
				slidesObj.pauseTimeout = setTimeout(function() {
					play(slidesObj);
					if (onResume)
						onResume()
				},timeout);
				// store pause interval
				$(slidesObj.elem).data('pause',slidesObj.pauseTimeout);
			} else {
				// if no pause, just stop
				stop(slidesObj);
			}
		}
		return true;
	}
	
	function play(slidesObj) {
		if (!slidesObj.locked) {
			// clear timeout and interval
			clearTimeout($(slidesObj.elem).data('pause'));
			clearInterval($(slidesObj.elem).data('interval'));

			// start play interval
			slidesObj.playInterval = setInterval(	function(){
				animate(slidesObj, "next", slidesObj.effect);
			},slidesObj.option.play);
			// store play interval
			$(slidesObj.elem).data('interval',slidesObj.playInterval);
		}
		return true;
	}
	
	function next(slidesObj) {
		
		if (!slidesObj.locked) {
			if (slidesObj.option.play   && !slidesObj.userPaused) {
				pause(slidesObj, slidesObj.option.pause);
			}
			animate(slidesObj, 'next', slidesObj.effect);
		}
		return true;
	}
		
	function prev(slidesObj) {
		
		if (!slidesObj.locked) {
			if (slidesObj.option.play   && !slidesObj.userPaused) {
				pause(slidesObj, slidesObj.option.pause);
			}
			animate(slidesObj, 'prev', slidesObj.effect);
		}
		return true;
	}
		
	// default options
	$.fn.slides.option = {
		preload: false, // boolean, Set true to preload images in an image based slideshow
		preloadImage: '/img/loading.gif', // string, Name and location of loading image for preloader. Default is "/img/loading.gif"
		container: 'slides_container', // string, Class name for slides container. Default is "slides_container"
		generateNextPrev: false, // boolean, Auto generate next/prev buttons
		next: 'next', // string, Class name for next button
		prev: 'prev', // string, Class name for previous button
		pagination: true, // boolean, If you're not using pagination you can set to false, but don't have to
		generatePagination: true, // boolean, Auto generate pagination
		prependPagination: false, // boolean, prepend pagination
		paginationClass: 'pagination', // string, Class name for pagination
		currentClass: 'current', // string, Class name for current class
		fadeSpeed: 350, // number, Set the speed of the fading animation in milliseconds
		fadeEasing: '', // string, must load jQuery's easing plugin before http://gsgd.co.uk/sandbox/jquery/easing/
		slideSpeed: 350, // number, Set the speed of the sliding animation in milliseconds
		slideEasing: '', // string, must load jQuery's easing plugin before http://gsgd.co.uk/sandbox/jquery/easing/
		start: 1, // number, Set the speed of the sliding animation in milliseconds
		effect: 'slide', // string, '[next/prev], [pagination]', e.g. 'slide, fade' or simply 'fade' for both
		crossfade: false, // boolean, Crossfade images in a image based slideshow
		randomize: false, // boolean, Set to true to randomize slides
		play: 0, // number, Autoplay slideshow, a positive number will set to true and be the time between slide animation in milliseconds
		pause: 0, // number, Pause slideshow on click of next/prev or pagination. A positive number will set to true and be the time of pause in milliseconds
		hoverPause: false, // boolean, Set to true and hovering over slideshow will pause it
		autoHeight: false, // boolean, Set to true to auto adjust height
		autoHeightSpeed: 350, // number, Set auto height animation time in milliseconds
		bigTarget: false, // boolean, Set to true and the whole slide will link to next slide on click
		animationStart: function(){}, // Function called at the start of animation
		animationComplete: function(){}, // Function called at the completion of animation
		slidesLoaded: function() {}, // Function is called when slides is fully loaded
		playPauseToggle: 0,
		playPauseToggleClass: 'playToggle',
		pausedClass: 'paused',
		onFinish:  function() {},
		loop: 1,
		hoverLock : 0
	};
	
	// Randomize slide order on load
	$.fn.randomize = function(callback) {
		function randomizeOrder() {
			return(Math.round(Math.random())-0.5);
		}
		return($(this).each(function() {
			var $this = $(this);
			var $children = $this.children();
			var childCount = $children.length;
			if (childCount > 1) {
				$children.hide();
				var indices = [];
				for (i=0;i<childCount;i++) {
					indices[indices.length] = i;
				}
				indices = indices.sort(randomizeOrder);
				$.each(indices,function(j,k) { 
					var $child = $children.eq(k);
					var $clone = $child.clone(true);
					$clone.show().appendTo($this);
					if (callback !== undefined) {
						callback($child, $clone);
					}
					$child.remove();
				});
			}
		}));
	};
})(jQuery);
