<?php
/**
* @title		JoomShaper Image slider module
* @version		1.0
* @website		http://www.joomshaper.com
* @copyright	Copyright (C) 2010 JoomShaper.com. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$uri 					= JURI::getInstance();
$uniqid					= $params->get('uniqid', "1");
$width					= $params->get('width', "320");
$height					= $params->get('height', "200");
$autoPlay 				= ($params->get("autoPlay", 1)  == 0) ? "false" : "true";
$interval 				= $params->get("interval", 5000);
$speed 					= $params->get("speed", 1000);
$transition 			= $params->get("transition", "Expo.easeOut");
$path					= $params->get('path', "images/stories/fruit");
$items					= count(glob("$path/{*.jpg,*.gif,*.png}", GLOB_BRACE));
$document 				= JFactory::getDocument();
$livePath				= JURI::base() . 'modules/mod_joom_rotator_v1';
$document->addScript($livePath . '/script/_class.noobSlide.js')
?>
<script type="text/javascript">
window.addEvent('domready',function(){
	var hs<?php echo $uniqid; ?> = new noobSlide({
		box: $('joomscontbox<?php echo $uniqid; ?>'),
		items:[<?php for($i = 1; $i <= $items-1; $i++){$slideamount= $i.',' ; echo $slideamount;  }  echo $items;?>],
		size: <?php echo $width; ?>,
		autoPlay: <?php echo $autoPlay; ?>,
		interval: <?php echo $interval; ?>,
		fxOptions: {
			duration: <?php echo $speed; ?>,
			transition: Fx.Transitions.<?php echo $transition; ?>,
			wait: false
		},
		buttons: {
			previous: $('prev<?php echo $uniqid; ?>'),
			next: $('next<?php echo $uniqid; ?>')
		}
	});

});
</script>

<div id="joomscontbg<?php echo $uniqid; ?>">
	<div class="joomscontmask<?php echo $uniqid; ?>">
		<div id="joomscontbox<?php echo $uniqid; ?>">
			<?php foreach(glob("$path/{*.jpg,*.gif,*.png}", GLOB_BRACE) as $file) { ?>
				<div class="inner">
					<img src="<?php echo $file ?>" alt="<?php echo $file ?>" />
				</div>
			<?php } ?>	
		</div>
	</div>
	<div id="prev<?php echo $uniqid;?>" class="prev<?php echo $uniqid;?>"></div>
	<div id="next<?php echo $uniqid;?>" class="next<?php echo $uniqid;?>"></div>
</div>
<?php 
$style = '#joomscontbg'.$uniqid.'{width:'.$width.'px;padding: 0;background:#fff; position: relative;}#joomscontbox'.$uniqid.' {position:absolute;}#joomscontbox'.$uniqid.' .inner{width:'.$width.'px;height:'.$height.'px;display:block;float:left;padding:0;margin:0;}
.joomscontmask'.$uniqid.'{width:'.$width.'px;height:'.$height.'px;position:relative;overflow:hidden;}
.prev' . $uniqid . ', .next' . $uniqid . '{width: 33px; height: 50px; margin-top:-25px;position: absolute; top:50%; z-index: 1;cursor:pointer; }
.prev' . $uniqid . '{left:0; background: url(' . $livePath . '/images/prev.png) no-repeat center;}
.next' . $uniqid . '{right:0; background: url(' . $livePath . '/images/next.png) no-repeat center;}'; 
$document->addStyleDeclaration( $style );
?>								
					
