<?
/*
 * \SentraDesigner\fills\ContentSlider\slider.class.php
 */
class SliderHandler {

	var $setting = array();
	var $SliderData= array();
	
	function __construct ($P) {
	  global $wb;
		$wb->JQUERY_ONSITE = true;
		$wb->LiquidSlider = true;
		$wb->ContentSlider = true;
		$this->settings = $P;
	}
	
	function AddData ($data) {
			$tmp['content'] = $data;
			array_push($this->SliderData, $tmp);
		}
	
	function CloseSlider($p) {
		global $wb;
		$hash = GetHashCode($this->settings['id']);
		$setup = $this->settings['plugid'];
		$setup = explode('|',$setup);
		$modes = array("easeSentraExpo","easeSentraBack","easeSentraSine");		
		if (count($setup) < 5) {
			$setup = "True|True|True|True|1000|5000|0|||||||";
			$setup = explode('|',$setup);
		}
		
		$options = "";
		// if ($this->settings['htmltitle'] != "") {
			// $o = quote2entities($this->settings['htmltitle'],"slash");
			// $o = str_replace("&amp;","&",$o);
			// $options .= "mobileNavDefaultText:'".$o."',";
		// }
		if ($setup[8] == '')
			$setup[8] = 'False';
			
		if ($setup[9] == '')
			$setup[9] = 'False';
			
		if ($setup[10] == '')
			$setup[10] = 'False';	
			
		$assets = file (DESIGNREGCSS.'contentslider.assets.dat');	
			
		
		if ($setup[0] != "True") {
			$options .= "autoHeight:false,";
		}
		
		if ($setup[1] == "True") {
			$options .= "showDynamicTabs:true,";					
			$options .= "buttonOn: '".trim($assets[4])."',";
			$options .= "buttonOff: '".trim($assets[3])."',";			
			RegisterButton(trim($assets[3]));
			RegisterButton(trim($assets[4]));
		}
		
		if ($setup[7] == "True") {
			$options .= "showDynamicArrows:true,";
			$options .= "dynamicArrowLeftText:'".trim($assets[2])."',";
		}
		
		
		
		if ($setup[8] != "True") {
			$options .= "showThumbNavi:false,";
		} else {
			$options .= "thumbNaviOff:'".trim($assets[1])."',";
			$options .= "thumbNaviOn:'".trim($assets[0])."',";
		}
		
		if ($setup[9] != "True") {
			$options .= "hideContentH2:true,";
		}	else {
			$options .= "hideContentH2:false,";
		}
		
		if ($setup[2] != "True") {
			$options .= "autoSlide: false,";
			$options .= "forceAutoSlide: false,";
		}
		
		if ($setup[10] == "True") {
			$options .= "swipe: true,";
			$options .= "hideArrowsWhenMobile:true,";
		} else {
			$options .= "hideArrowsWhenMobile:false,";
		}
		
		if ($setup[3] != "True")
			$options .= "pauseOnHover: false,";
			
		if ($setup[4] != "1000")
			$options .= "slideEaseDuration: ".$setup[4].",";
			
		if ($setup[5] != "5000")
			$options .= "autoSlideInterval: ".$setup[5].",";
	
		if ($setup[6] != "0")	{
			$options .= "slideEaseFunction: '".$modes[($setup[6]-1)]."',";
		}	
	
		
	if ($options != "")
		$options = "{".rtrim($options,",")."}";			
	ob_start();
?>
<div>
<div class="liquid-slider-wrapper" style="visibility:hidden;">
  <div class="liquid-slider" id="main-slider<?=$hash;?>">
	<?
	for ($x=0;$x < count($this->SliderData);$x++)
	{
	?>
  <div>
    <?= '<?php '.trim($this->SliderData[$x]['content'])." ?>";?>
	</div>
	<? } ?>
 </div>
</div>
</div>
<script>
$(document).ready(function() {
	$('#main-slider<?=$hash;?>').liquidSlider(<?=$options;?>);
	$('.liquid-slider-wrapper').css({'visibility':'visible'}) ;
});
</script>
<?	
	$c = ob_get_clean();
	$space = 0;
	if (isset($p['PreSpace']) && $p['PreSpace'] == "True") {    
		$space = $wb->SPACE_VALS[$p['PreSpaceVal']];	  
		$c .= VTDPARA::GapGen($space);
		$fp = fopen(PARAGRAPH_OUTPUT.$this->settings['id'].'.php',"w+");
		fwrite($fp,$wb->SECURE_HEADER.$c);
		fclose($fp);
		return $this->settings['id'];
  }
}
}
?>
