<?php
	
	if (is_array($slider_data)):
	
	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) {
				
				
				preapare_the_slider();
				jQuery(window).bind("resize",function(){preapare_the_slider();});
				
				$("#slider").show();
				
				jQuery("#slides-slider").slides({
					'._isso((
						_isOnOff($slider_options["autorotation"]) && $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"].', autoHeightSpeed: '.$slider_options["effect_speed"].',',
						NULL).'
					preload: '._isso(_isOnOff($slider_options["preload"]),'true','false').',
					crossfade: true,
					effect: "'._isso(empty($slider_options["effect"]),'slide',$slider_options["effect"]).'",
					generateNextPrev: '._isso(($slider_options["next_prev"] !== 'FALSE'),'true','false').',
					autoHeight: '._isso(($slider_options["autoheight"] !== 'FALSE'),'true','false').',
					generatePagination: false,
					header: true
				});	
				
				default_slides_control_left = $(".slider-scroll .slides_control").css("left");
				
				nav_element = $("#slides-slider").find(".slider-nextprev");
				
				if (nav_element){
					nav_element.animate({"bottom": 50});
					
					$("#slider").hoverIntent({
						sensitivity: 1,
						interval: 200,
						over: function(){
							if ($("#slides-slider").hasClass(\'hide-when-loading\')) return false;
							nav_element.stop(true).animate({"bottom": 130},200);
						},
						timeout: 1000,
						out: function() {
							nav_element.stop(true).animate({"bottom": 50},200);
					}});
				}// nav_element

			}
			
		});

	</script>
	
	';
	
	
	echo '
	
	<div id="slides-slider" class="'._isso(($slider_options["effect"] == 'slide'),'slider-scroll', NULL).'" style="margin:auto;'.
		cloudfw_skin_engine_make_attribute(NULL,'background-color',$slider_options["bg_color"]).
		cloudfw_skin_engine_make_attribute(NULL,'background-image',$slider_options["bg_image"]).
		cloudfw_skin_engine_make_attribute(NULL,'background-repeat',$slider_options["bg_repeat"])
	.' background-position: 50% 0;">
		
		<div class="slides_container">';
	
	foreach ($slider_data as $slider_id => $slider){
	
	if (empty($slider["slider_bg_color"]) && empty($slider["slider_bg_image"]))	$classes = ' no-bg';
		
	
	echo '	
		<div class="slides-slider-item layout-right'.$classes.'" style="height:'.$slider["slider_height"].'px;">';

	if (!empty($slider["slider_bg_color"]) || !empty($slider["slider_bg_image"])) {
	echo '
		<div class="slider-background" style="height:'.$slider["slider_height"].'px; '.
		
		cloudfw_skin_engine_make_attribute(NULL,'background-color',$slider["slider_bg_color"]).
		cloudfw_skin_engine_make_attribute(NULL,'background-image',$slider["slider_bg_image"]).
		cloudfw_skin_engine_make_attribute(NULL,'background-repeat',$slider["slider_bg_repeat"])
		
		.' background-position: 50% 50%;"></div>
	';
	}


	echo '<div class="slider-content-container" style="height:'.$slider["slider_height"].'px;">';
	
	
	
	if (!empty($slider["slider_url"]) || $slider["slider_image"]):
	if (empty($slider["slider_image"])) $slider["slider_image"] = TMP_URL.'/lib/imgs/blank.gif';
	echo '
		<div class="slider-image" style="'.
		cloudfw_skin_engine_make_attribute(NULL,'width',$slider["slider_image_width"]).
		cloudfw_skin_engine_make_attribute(NULL,'height',$slider["slider_image_height"]).
		cloudfw_skin_engine_make_attribute(NULL,$slider["slider_image_align"],$slider["slider_image_margin_side"]).
		cloudfw_skin_engine_make_attribute(NULL,'bottom',$slider["slider_image_margin_bottom"]).
		'">';
					
	echo $slider["slider_url"] ? '<a href="'.cloudfw_get_page_link($slider["slider_url"]).'"><img src="'.$slider["slider_image"].'" alt=""/></a>': '<img src="'.$slider["slider_image"].'" alt=""/><span></span>' ;

	
	echo '</div>';
	endif;
	
	if (!empty($slider["slider_text"])) {
	echo '
	
		<div class="slider-text-container" style="'.
		cloudfw_skin_engine_make_attribute(NULL,'text-align',$slider["slider_content_text_align"]).
		cloudfw_skin_engine_make_attribute(NULL,'width',$slider["slider_content_width"]).
		cloudfw_skin_engine_make_attribute(NULL,$slider["slider_content_align"],$slider["slider_content_margin_side"]).
		cloudfw_skin_engine_make_attribute(NULL,'top',$slider["slider_content_margin_top"]).
		'">'.do_shortcode($slider["slider_text"]).'</div>
	
	';
	}
	
	
	echo			'		
					
			</div>
			
		</div>
		
		';
	
	}
	
	echo '</div>

	</div>';

	endif;


?>