<?php
	
function get_inpage_slider_results($atts) {
	
	extract(cloudfw_make_var(array(
		'id'				=> NULL,
	), $atts));	
	
		
	$slider_options = cloudfw_get_slider_options($id);
	$slider_data = cloudfw_get_slider($id);
	
	
	ob_start();	

	if (is_array($slider_data)):
	

	
	$unique_id = 'slider-'.cloudfw_randomizer(4);
	
	if (is_numeric($slider_options["autorotation_speed"]))
		$slider_options["autorotation_speed"] = ($slider_options["autorotation_speed"] * 1000);
	else
		$slider_options["autorotation_speed"] = 10000;

	
	if ($slider_options["autorotation_speed"] < $slider_options["effect_speed"]) $slider_options["autorotation_speed"] = $slider_options["effect_speed"];

	echo '
	
	<script type="text/javascript">
                    
		jQuery(document).ready(function() {
				
			if (jQuery().slides) {
				
				jQuery("#'.$unique_id.'").slides({
					'._isso((
						$slider_options["autorotation"] !== "FALSE" && $slider_options["autorotation_speed"] > 0 ) ? TRUE:FALSE,
						'play: '.$slider_options["autorotation_speed"].',',
						NULL).'
					'._isso(($slider_options["effect_speed"] > 0 ),
						'fadeSpeed: '.$slider_options["effect_speed"].', slideSpeed: '.$slider_options["effect_speed"].',',
						NULL).'
					crossfade: true,
					effect: "'._isso(empty($slider_options["effect"]),'slide',$slider_options["effect"]).'",
					generateNextPrev: '._isso(($slider_options["next_prev"] !== 'FALSE'),'true','false').',
					generatePagination: '._isso(($slider_options["pagination"] !== 'FALSE'),'true, paginationWidth: true','false').',
					preload: true,
					autoHeight: false
				});	
				
			}
			
		});

	</script>
	
	';
	
	
	$width_height = cloudfw_skin_engine_make_attribute(NULL,'width',$slider_options["width"]). cloudfw_skin_engine_make_attribute(NULL,'height',$slider_options["height"]);
	$slider_padding = _isso(($slider_options["pagination"] !== 'FALSE'), 'margin-bottom:20px;');
	$wp_embed = new WP_Embed();

	echo '
	<div class="full-width">
	<div id="'.$unique_id.'" class="inline-slider" style="'.$width_height.$slider_padding.'">
		
		<div class="slides_container">';
	
	foreach ($slider_data as $slider_id => $slider){
		
	//if (empty($slider["slider_image"])) continue;
	$slider_img = cloudfw_thumbnail(array('src' => $slider["slider_image"], 'w' => $slider_options["width"], 'h' => $slider_options["height"], 'cache' =>0));
	
	
	echo '	
		<div class="inline-slider-container" style="'.cloudfw_skin_engine_make_attribute(NULL,'height',$slider_options["height"]).'">		
	';
		
	if (empty($slider["slider_video"])):
		
		echo '<div class="inline-slider-image">';
		echo $slider["slider_url"] ? '<a href="'.cloudfw_get_page_link($slider["slider_url"]).'"><img src="'.$slider_img.'" style="'.$width_height.'" alt=""/></a>': '<img src="'.$slider_img.'" style="'.$width_height.'" alt=""/>' ;
		echo '</div>';
		
	else:
		
		echo '<div class="inline-slider-image">';
		echo $post_embed = $wp_embed->run_shortcode('[embed width="'.$slider_options["width"].'" height="'.$slider_options["height"].'" force="1"]'.$slider['slider_video'].'[/embed]');
		echo '</div>';
		
	endif;
		
	
	echo '</div>';
		
	}
	
	echo '</div>

	</div>
	</div>';

	endif;


	
	ob_end_flush;
	$out = ob_get_contents();
	ob_end_clean();
	
	return $out;
			
}
	
?>