// javascript document $(document).ready(function() { //set default state of each portfolio piece $(".picshow_paging").show(); $(".picshow_paging span:first").addclass("active"); //get size of images, how many there are, then determin the size of the image reel. var imagewidth = $(".picshow_window").width(); var imagesum = $(".picshow_reel li").size(); var imagereelwidth = imagewidth * imagesum; //adjust the image reel to its new size $(".picshow_reel").css({'width' : imagereelwidth}); //paging + slider function picrotate = function(){ var triggerid = $active.attr("picpage") - 1; //get number of times to slide var image_reelposition = triggerid * imagewidth; //determines the distance the image reel needs to slide $(".picshow_paging span").removeclass('active'); //remove all active class $active.addclass('active'); //add active class (the $active is declared in the rotateswitch function) //slider animation $(".picshow_reel").animate({ left: -image_reelposition }, 600 ); }; //rotation + timing event picrotateswitch = function(){ picplay = setinterval(function(){ //set timer - this will repeat itself every 3 seconds $active = $('.picshow_paging span.active').next(); if ( $active.length === 0) { //if paging reaches the end... $active = $('.picshow_paging span:first'); //go back to first } picrotate(); //trigger the paging and slider function }, 4000); //timer speed in milliseconds (3 seconds) }; picrotateswitch(); //run function on launch //on hover $(".picshow_reel li").hover(function() { clearinterval(picplay); //stop the rotation }, function() { picrotateswitch(); //resume rotation }); //on click $(".picshow_paging span").click(function() { $active = $(this); //activate the clicked paging //reset timer clearinterval(picplay); //stop the rotation picrotate(); //trigger rotation immediately picrotateswitch(); // resume rotation return false; //prevent browser jump to link anchor }); });