<?php 

extract( shortcode_atts( array( 
	'effect'  => 'fade',
	'buttons' => 'true',
	'speed'   => '0',
	'classes' => ''
 ), $atts ) );

// Unique Name
STATIC $i = 0;
$i++;
$name = 'testimonial_slider_' . $i;

ob_start(); ?>

<div id="<?php echo sanitize_html_class( $name ); ?>" class="testimonial-slider gp-slider <?php echo sanitize_html_class( $classes ); ?>">
	<ul class="slides">
		<?php echo do_shortcode( $content ); ?>
	</ul>
</div>

<?php

$output_string = ob_get_contents();
ob_end_clean(); 
echo wp_kses_post( $output_string );

if ( ! is_admin() ) { ?> 
	<script>
	jQuery( document ).ready( function( $ ) {
		'use strict';
		$( '#<?php echo sanitize_html_class( $name ); ?>.gp-slider' ).flexslider( { 
			animation: '<?php echo esc_attr( $effect ); ?>',
			slideshowSpeed: <?php if ( $speed == 0 ) { echo '9999999'; } else { echo absint( $speed ) * 1000; } ?>,
			animationSpeed: 600,
			smoothHeight: true,   
			directionNav: false,			
			controlNav: <?php if ( $buttons == 'true' ) { ?>true<?php } else { ?>false<?php } ?>,				
			pauseOnAction: true, 
			pauseOnHover: false
		});
	});
	</script>
<?php }

?>