This slider is working fine when actively using/clicking/hovering but will not autoplay.
Any ideas?
Code Below:
CSS
/*image slider*/
.rotator
{
position:absolute;
background-color:#FFF;
top: 165px;
left:0px;
margin:0px;
padding:0px;
z-index:2;
width:1002px;
height: 280px;
border:none;
}
/*--Main Container--*/
.main_view {
float: left;
position: relative;
height: 280px;
}
/*--Window/Masking Styles--*/
.window {
height:280px;
width: 1002px;
overflow: hidden; /*--Hides anything outside of the set width/height--*/
position: relative;
}
.image_reel {
position: absolute;
left: 0px;
top:0px;
}
.image_reel img {float: left;}
/*--Paging Styles--*/
.pagemenu
{
position:relative;
width:1002;
height:60px;
bottom:50px;
background:url(images/SLIDER/pg_float.png);
background-repeat:repeat-x;
z-index:99;
}
.paging {
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
position: relative;
width:1002px;
bottom: 0px;
text-align:center;
color:#FFF;
border:none;
z-index: 100; /*--Assures the paging stays on the top layer--*/
line-height: 60px;
/*--Hidden by default, will be later shown with jQuery--*/
display:none;
}
.paging a
{
text-align:center;
bottom:0px;
height:60px;
color:#666;
}
.paging a.active
{
font-weight: bold;
text-decoration:none;
text-align:center;
color:#FFF;
width:200px;
height:60px;
bottom:0px;
background-image:url(images/SLIDER/pg_on.png);
background-repeat:repeat-x;
display:inline-block;
z-index:101;
}
.paging a:hover
{
font-weight: bold;
text-decoration:none;
text-align:center;
color:#FFF;
width:200px;
height:60px;
font-weight: bold;
background-image:url(images/SLIDER/pg_hov.png);
background-repeat:repeat-x;
display:inline-block;
z-index:102;
}
Html
<div class="rotator">
<div class="main_view">
<div class="window">
<div class="image_reel">
<a href="softwareeng.html"><img src="images/SLIDER/reel_1.png" alt="Software Engineering" width="1002" height="280" border="0" /></a>
<a href="itinfrastructure.html"><img src="images/SLIDER/reel_2.png" alt="IT Infrastructure" width="1002" height="280" border="0"/></a>
<a href="infoassurance.html"><img src="images/SLIDER/reel_3.png" alt="Information Assurance"width="1002" height="280" border="0" /></a>
<a href="healthcareit.html"><img src="images/SLIDER/reel_4.png" alt="Healthcare IT" width="1002" height="280" border="0" /></a>
<a href="adminpersonnel.html"><img src="images/SLIDER/reel_5.png" alt="Administrative Services" width="1002" height="280" border="0" /></a>
</div>
</div>
<div class="pagemenu">
<div class="paging">
<table width="1002" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%"><a href="index.html" rel="1">Software Engineering</a></td>
<td width="20%"> <a href="index.html" rel="2">IT Infrastructure</a></td>
<td width="20%"> <a href="index.html" rel="3">Information Assurance</a></td>
<td width="20%"> <a href="index.html" rel="4">Healthcare IT</a></td>
<td width="20%"> <a href="index.html" rel="5">Administrative Services</a></td>
</tr>
</table>
</div>
</div>
</div>
</div>
jquery
<script type="text/javascript" src="images/SLIDER/jquery-1.5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");
//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});
//Paging and Slider Function
rotate = function(){
var triggerID = $active.attr("rel") - 1; //Get number of times to slide
var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
$(".paging a").removeClass('active'); //Remove all active class
$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
//Slider Animation
$(".image_reel").animate({
left: -image_reelPosition
}, 100 );
};
//Rotation and Timing Event
rotateSwitch = function(){
play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
$active = $('.paging a.active').next(); //Move to the next paging
if ( $active.length === 0) { //If paging reaches the end...
$active = $('.paging a:first'); //go back to first
}
rotate(); //Trigger the paging and slider function
}, 7000); //Timer speed in milliseconds (7 seconds)
};
rotateSwitch(); //Run function on launch
//On Hover
$(".image_reel a").hover(function() {
clearInterval(play); //Stop the rotation
}, function() {
rotateSwitch(); //Resume rotation timer
});
//On Click
$(".paging a").click(function() {
$active = $(this); //Activate the clicked paging
//Reset Timer
clearInterval(play); //Stop the rotation
rotate(); //Trigger rotation immediately
rotateSwitch(); // Resume rotation timer
return false; //Prevent browser jump to link anchor
});
});