var myImages = ['Pictures/180/089ph_01289.jpg','Pictures/180/089ph_01290.jpg','Pictures/180/089ph_01291.jpg','Pictures/180/089ph_01292.jpg','Pictures/180/089ph_01293.jpg','Pictures/180/089ph_01294.jpg','Pictures/180/089ph_01321.jpg','Pictures/180/089ph_01322.jpg','Pictures/180/089ph_01323.jpg','Pictures/180/089ph_01324.jpg','Pictures/180/089ph_01325.jpg','Pictures/180/089ph_01326.jpg','Pictures/180/089ph_01327.jpg','Pictures/180/089ph_01328.jpg','Pictures/180/089ph_01337.jpg','Pictures/180/089ph_01338.jpg','Pictures/180/089ph_01339.jpg','Pictures/180/089ph_01340.jpg','Pictures/180/089ph_01341.jpg','Pictures/180/089ph_01342.jpg','Pictures/180/089ph_01343.jpg','Pictures/180/089ph_01344.jpg','Pictures/180/089ph_01345.jpg','Pictures/180/089ph_01346.jpg','Pictures/180/089ph_01347.jpg','Pictures/180/089ph_01348.jpg','Pictures/180/089ph_01612.jpg','Pictures/180/089ph_01613.jpg','Pictures/180/089ph_01614.jpg','Pictures/180/089ph_01615.jpg','Pictures/180/089ph_01616.jpg','Pictures/180/089ph_01617.jpg','Pictures/180/089ph_01618.jpg','Pictures/180/089ph_01619.jpg','Pictures/180/089ph_01620.jpg','Pictures/180/089ph_01621.jpg','Pictures/180/089ph_01622.jpg','Pictures/180/089ph_01623.jpg','Pictures/180/089ph_01624.jpg','Pictures/180/089ph_01625.jpg','Pictures/180/089ph_01626.jpg','Pictures/180/089ph_01627.jpg','Pictures/180/089ph_01628.jpg','Pictures/180/089ph_01629.jpg','Pictures/180/089ph_01630.jpg','Pictures/180/089ph_01631.jpg','Pictures/180/089ph_01632.jpg','Pictures/180/089ph_01633.jpg','Pictures/180/089ph_01634.jpg','Pictures/180/089ph_01635.jpg','Pictures/180/089ph_01636.jpg','Pictures/180/089ph_01637.jpg','Pictures/180/089ph_01638.jpg','Pictures/180/089ph_01639.jpg']; var maxChanges = myImages.length * 10; var do_shuffle = true; var do_randomly = false; var seconds_between_photos = 8; var div_name = "loader"; var changes = 0; var timer; var thisImg = myImages.length - 1; shuffle = function(o) { for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; }; if (do_shuffle) { myImages = shuffle(myImages); } function nextImage () { var low = 0; var high = myImages.length - 1; var rand_no = Math.floor((high-(low - 1))*Math.random()) + low; thisImg++; changes++; if (thisImg==myImages.length) { thisImg = 0; } if (changes==maxChanges) { clearInterval(timer); } if (do_randomly) { thisImg = rand_no; return myImages[rand_no]; } else { return myImages[thisImg]; } } function changeImage () { var t = myImages[thisImg]; var n = nextImage(); if (t != n) { $("#"+div_name).addClass("loading"); showImage(n); } else { changeImage(); } } function showImage(src) { $("#"+div_name+" img").fadeOut("normal").remove(); var largeImage = new Image(); $(largeImage).load(function() { $(this).hide(); $("#"+div_name).append(this).removeClass("loading"); $(this).fadeIn("slow"); }); $(largeImage).attr("src", src); } function checkForLoaded () { if (document.getElementById(div_name) != null) { //alert("loaded"); clearInterval(timer); changeImage(); timer = setInterval(changeImage, (seconds_between_photos * 1000)); } } timer = setInterval(checkForLoaded, 500);