<?php

/*------------------------------------------------------------------------
# "Hot Spinner" Joomla module
# Copyright (C) 2011 ArhiNet d.o.o. All Rights Reserved.
# License: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
# Author: HotJoomlaTemplates.com
# Website: http://www.hotjoomlatemplates.com
-------------------------------------------------------------------------*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// get the document object
$doc =& JFactory::getDocument();

// add your stylesheet
$doc->addStyleSheet( 'modules/mod_hot_spinner/tmpl/css/ui-lightness/jquery-ui-1.8.11.custom.css' );
$doc->addStyleSheet( 'modules/mod_hot_spinner/tmpl/css/jquery.holest.carousel.css' );

$marginPosition = "left";
if($staticImagePosition=="right") { $marginPosition = "left"; }else{ $marginPosition = "right"; }

// style declaration
$doc->addStyleDeclaration( '

.holest-carousel {
	width:'.$moduleWidth.'px;
	height:'.$moduleHeight.'px;
	/* background:'.$bgColor.'; */
}

.holest-carousel-info-panel {
	width:'.$infoBoxWidth.'px; 
	height:'.$infoBoxVerticalPosition.'%;  
}

.holest-carousel-info-panel-content {
	height:'.$infoBoxHeight.'px;
}

.holest-carousel-info-panel-content img {
	width:'.$staticImageWidth.'px;
	float:'.$staticImagePosition.';
	margin-'.$marginPosition.':15px;
}

.holest-carousel-info-panel-content h2 a,
.holest-carousel-info-panel-content h2 {
	text-decoration:none;	
	color:'.$headingFontColor.';
	font-size:'.$headingFontSize.'px;
	font-family:'.$headingFont.';
	font-weight:'.$headingFontWeight.';
	padding-bottom:10px;
}

.holest-carousel-info-panel-content h2 a:link,
.holest-carousel-info-panel-content h2 a:visited {
	color:'.$headingFontColor.';
}

.holest-carousel-info-panel-content {
	color:'.$infoFontColor.';
	font-size:'.$infoFontSize.'px;
	font-family:'.$infoFont.';
	font-weight:'.$infoFontWeight.';
}

' );

?>

<?php if ($enablejQuery!=0) { ?>
<script type="text/javascript" src="<?php echo $mosConfig_live_site; ?>/modules/mod_hot_spinner/js/jquery.min.js"></script>
<?php } ?>

<?php if ($noConflict!=0) { ?>
<script type="text/javascript">
jQuery.noConflict();
</script>
<?php } ?>

<?php 
$rotationCenterX = ($moduleWidth / 2) - ($rotatingImageWidth / 4);
$rotationCenterY = ($moduleHeight / 2) - ($rotatingImageHeight / 4);
?>

<script src="<?php echo $mosConfig_live_site; ?>/modules/mod_hot_spinner/js/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
<script src="<?php echo $mosConfig_live_site; ?>/modules/mod_hot_spinner/js/jquery.holest.carousel.min.js" type="text/javascript"></script>

<div id="container" >
<?php for ($loop = 1; $loop <= 10; $loop += 1) { ?>
	<?php if($slot[$loop]) { ?>
		<?php 
        if($UseImageB64==1)
        { 
                $imgfile = $rotatingImage[$loop];
                $mime = pathinfo($imgfile, PATHINFO_EXTENSION);
                $handle = fopen($imgfile, "r");
                $imgbinary = fread($handle, filesize($imgfile));
                fclose($handle); 
                if(strtolower($mime) === 'jpg') $mime = 'jpeg';
        ?>
        <img id="irot_<?php echo $loop; ?>" src="<?php echo "data:image/".$mime.";base64,".base64_encode($imgbinary);?>" alt="" />
        <?php }else{ ?>
        <img src="<?php echo $mosConfig_live_site.DIRECTORY_SEPARATOR.$rotatingImage[$loop]; ?>" alt="" />
        <?php } ?>
	<?php } ?>
<?php } ?>
</div>
<span id="lblOp"></span>

<script type="text/javascript" >
        
    jQuery(document).ready(function() {
        jQuery('#container').holest_carousel(
        {
            contentdiv:'#carousel_content',								// jQuery object that contains DIVs for info-panel content
            info_animation:'<?php echo $infoAnimation; ?>',				// Amination to use with info-panel. Can be: fade,updown,slide
            animation_speed:<?php echo $animSpeed; ?>,					// Animation speed
            movment: 1/<?php echo $rotationSpeed; ?>,					// Movement in radians per each refresh interval
            refresh_interval:30,										// refresh interval = 1/fps (ms)
            reflection:<?php if ($reflection==1) {echo "true";}else{echo "false";} ?>,		// Value indicating that image mirrors should be created
            reflection_height: <?php echo $reflectionHeight; ?>,		// Height of mirror image
            reflection_opacity: 1/<?php echo $reflectionOpacity; ?>,	// Opacity of mirrored image
            InitialDirection:<?php echo $rotationDirection; ?>,			// Initial direction; -1 is clockwise, 1 is counterclockwise
            radius:<?php echo $rotationRadius; ?>,						// Radius of rotation
            radius_effect:0.25,											// Ratio or radis that will be added when fast spin is triggered 
            center:[<?php echo $rotationCenterX; ?>,<?php echo $rotationCenterY; ?>],			// Center of rotation
            horisontal_aspect:<?php echo $perspective; ?>,				// Perspective angle
            speedup_acc:30,												// How manu times rotation accelerates on fast spin
            speeddown_acc:1/10,											// How many times rotation deaccelerates on click
            speedup_acc_rate:-1/10,										// Rate of fast spin deacceleration
            speeddown_acc_rate:1/5000,									// Rate of acceleration after stop
            speedup_trigger_time:300,									// Maximum time that can pass for user to drag mouse to trigger fast spin
            speedup_path_length_ratio:1/3,								// Minimal length in width ratio of control which user must drag mouse to trigger fast spin
            item_width:<?php echo $rotatingImageWidth; ?>,				// Overide default item width = 120
            item_height:<?php echo $rotatingImageHeight; ?>,			// Overide default item height = 120
            doubleclickstop:<?php if ($stopRotation==1) {echo "true";}else{echo "false";} ?>	// If true the rotation stops on doubleclick
        }
        );
    });
	
	//    FULL CAROUSEL EVENTS:
	//----------------------------------------
	//    onInfoClick: function(Index){...}
    //    onClick: function(Index){...}
    //    onInfoDblClick: function(Index){...}
    //    onDblClick: function(Index){...}
	//----------------------------------------
</script>

<div style="display:none" id="carousel_content">
	<?php for ($loop = 1; $loop <= 10; $loop += 1) { ?>
    	<?php if($slot[$loop]) { ?>
        <div>
            <h2><?php if ($slotLink[$loop]) { ?><a href="<?php echo $slotLink[$loop]; ?>"><?php } echo $slotHeading[$loop]; if ($slotLink[$loop]) { ?></a><?php } ?></h2>
            <?php if ($slotLink[$loop]) { ?><a href="<?php echo $slotLink[$loop]; ?>"><?php } ?><img src="<?php echo $mosConfig_live_site.DIRECTORY_SEPARATOR.$staticImage[$loop]; ?>" alt="" /><?php if ($slotLink[$loop]) { ?></a><?php } ?>
            <p><?php echo $slotText[$loop]; ?></p> 
        </div>
    	<?php } ?>
    <?php } ?>
</div> 