/* * * This file provides the javascript to perform image rotation using a fade in/out * technique obtained and modified from http://www.brainerror.net/scripts_js_blendtrans.php * */ // // arrays of photos and captions // var photo_array = new Array(); var photo_caption_array = new Array(); photo_array[0] = "images/2006-04-02-05-WhatsThatPlease-450x337.jpg"; photo_array[1] = "images/2006-04-02-09-Whoo-450x337.jpg"; photo_array[2] = "images/2006-04-02-10-HikerTrash-450x337.jpg"; photo_array[3] = "images/2006-06-18-08-AfternoonOnTundra-450x337.jpg"; photo_array[4] = "images/2006-06-18-02-DaveLaughs-450x337.jpg"; photo_array[5] = "images/2006-06-10-07-NahumStyleKing-450x337.jpg"; photo_array[6] = "images/2006-06-10-02-MostOfTheCrew-450x337.jpg"; photo_array[7] = "images/2006-03-25-02-Tracks-450x337.jpg"; photo_array[8] = "images/2006-01-01-ViewFromFirstFlatiron-450x337.jpg"; photo_array[9] = "images/20060624D1-45-RomAndJeniaAscendingUNotch-Sierras.JPG"; photo_array[10] = "images/20060626D2-08-Palisades-Sierras.JPG"; photo_array[11] = "images/20060626D2-43-AJOnSillSummit-Sierras.JPG"; photo_array[12] = "images/20060729D1-58-AJCanyoneering-LowerWolfCreek.JPG"; photo_array[13] = "images/20060811D2-03-Sunset-ZirkelWilderness.JPG"; photo_array[14] = "images/20060825D2-14-GrandCanyonOfTuolumneViews.JPG"; photo_array[15] = "images/20060903D3-49-MikeAndSteveRiverHikingInDinosaurNM-crop.jpg"; photo_array[16] = "images/20060909D1-45-GroupAtDiamondLake.JPG"; photo_array[17] = "images/20060928D2-18-DaveCanyoneering-ZionNP.JPG"; photo_array[18] = "images/20061001D1-47-TedCanyoneering-KolobCreekZionNP-crop.jpg"; photo_array[19] = "images/20061021D1-24-GroupCanyoneeringRoostArea-Utah.JPG"; photo_array[20] = "images/20061022D2-40-GroupCanyoneering-Utah.JPG"; photo_array[21] = "images/20061123D2-58-JonasandChuckCanyoneeringWestPasture-Utah-crop.jpg"; photo_array[22] = "images/IMG_0372.JPG"; photo_array[23] = "images/IMG_0458.JPG"; photo_array[24] = "images/Marmots.jpg"; photo_array[25] = "images/aai.jpg"; photo_array[26] = "images/aba.jpg"; photo_array[27] = "images/abk.jpg"; photo_array[28] = "images/ace_approaching_glass_lake.jpg"; photo_array[29] = "images/acn_sunrise_from_tremont.jpg"; photo_array[30] = "images/acv.jpg"; photo_array[31] = "images/adiBRAINARD_CABIN_MAR6&7.jpg"; photo_array[32] = "images/aek_Valleicto_Valley_in_San_Juans.jpg"; photo_array[33] = "images/afa.jpg"; photo_array[34] = "images/afi.jpg"; photo_array[35] = "images/ahgSTVRAINMTN0718.jpg"; photo_array[36] = "images/ahr_isabelle_glacier.jpg"; photo_array[37] = "images/aik.jpg"; photo_array[38] = "images/aim.jpg"; photo_array[39] = "images/ajc_butterly_on_aster.jpg"; photo_array[40] = "images/ajf_moose_and_two_calves.jpg"; photo_array[41] = "images/akg_Mandy_top_of_Buchanan_Pass.jpg"; photo_array[42] = "images/akn.jpg"; photo_array[43] = "images/amfMONARCH_LAKE_AUG7.jpg"; photo_array[44] = "images/anj.JPG"; photo_array[45] = "images/arf.JPG"; photo_caption_array[0] = "What's that please? - Boulder Grand Slam, 4/2/2006"; photo_caption_array[1] = "Whoo! - Boulder Grand Slam, 4/2/2006"; photo_caption_array[2] = "17 miles and 8,500 vertical feet later. - Boulder Grand Slam, 4/2/2006"; photo_caption_array[3] = "Bard Peak Trek - 6/18/2006"; photo_caption_array[4] = "Dave Becker Laughs - 6/18/2006"; photo_caption_array[5] = "Crock Master - Lost Creek Trek - 6/10/2006"; photo_caption_array[6] = "Lost Creek Crew - 6/10/2006"; photo_caption_array[7] = "Cross Country Skiing - 3/25/2006"; photo_caption_array[8] = "New Years Day Trek - 2006"; photo_caption_array[9] = "Rom and Jenia Ascending U Notch - Sierras - 6/24/2006"; photo_caption_array[10] = "Palisades - Sierras - 6/26/2006"; photo_caption_array[11] = "AJ On Sill Summit - Sierras - 6/26/2006"; photo_caption_array[12] = "AJ Canyoneering - Lower Wolf Creek - 7/29/2006"; photo_caption_array[13] = "Sunset - ZirkelWilderness - 8/11/2006"; photo_caption_array[14] = "Grand Canyon Of Tuolumne Views - 8/25/2006"; photo_caption_array[15] = "Mike and Steve River Hiking in Dinosaur NM - 9/3/2006"; photo_caption_array[16] = "Group at Diamond Lake - 9/9/2006"; photo_caption_array[17] = "Dave Canyoneering - Zion NP - 9/28/2006"; photo_caption_array[18] = "Ted Canyoneering - Kolob Creek Zion NP - 10/1/2006"; photo_caption_array[19] = "Group Canyoneering Roost Area - Utah - 10/21/2006"; photo_caption_array[20] = "Group Canyoneering -Utah - 10/22/2006"; photo_caption_array[21] = "Jonas and Chuck Canyoneering West Pasture - Utah - 11/23/2006"; photo_caption_array[22] = "Ben and Nahum - Zirkel Wilderness - 2006"; photo_caption_array[23] = "Yosemite Sunset - Yosemite NP - 2006"; photo_caption_array[24] = "Chaos Marmots"; photo_caption_array[25] = "Lots of food!"; photo_caption_array[26] = "Post-hike beer at Southern Sun"; photo_caption_array[27] = "Loch Lake, RMNP"; photo_caption_array[28] = "Hiking up to Glass Lake"; photo_caption_array[29] = "Sunrise on Tremont"; photo_caption_array[30] = "Lost Creek Wilderness"; photo_caption_array[31] = "Brainard Cabin"; photo_caption_array[32] = "Vellecito Valley in the San Juans"; photo_caption_array[33] = "Mountain goats in the San Juans"; photo_caption_array[34] = "Lawn Lake, RMNP"; photo_caption_array[35] = "Approaching St. Vrain Peak"; photo_caption_array[36] = "Isabelle Glacier"; photo_caption_array[37] = "Down the snow covered trail"; photo_caption_array[38] = "Nahum and Dave moving down into Paradise Park"; photo_caption_array[39] = "Butterfly on aster"; photo_caption_array[40] = "Moose and two calves"; photo_caption_array[41] = "Mandy at top of Buchannan Pass"; photo_caption_array[42] = "Lots of gorgeous wildflowers!"; photo_caption_array[43] = "Monarch Lake"; photo_caption_array[44] = "Taking the trails less traveled"; photo_caption_array[45] = "Jack O' Lanterns over Boulder!"; // // configuration variables // var numImgs = photo_array.length; var delayMs = 5000; // variables used to try not to repeat the same images too often. var prevImgArray = new Array(); var prevImgArrayLen = 10; // initialize to -1 for (var i = 0; i < prevImgArrayLen; i++) { prevImgArray[i] = -1; } // Save previous imgId to prevImgArray. We set each array entry to // the previous one, and then set the first one to the new imgId. function updatePrevImgArray(imgId) { for (var i = prevImgArrayLen - 1; i > 0; i--) { prevImgArray[i] = prevImgArray[i - 1]; } prevImgArray[0] = imgId; } // iterate thru the prevImgArray[] and ensure that the imgId we are // about to display is not one of the previous 10 images displayed. function notPrevImg(imgId) { var bRetVal = false; for (var i = 0; i < prevImgArrayLen; i++) { if (prevImgArray[i] != imgId) { bRetVal = true; } else { // if we have found a previous image that is the same as that // which we are about to display, we break out of this loop to // avoid resetting our return value if the next image is different // from this one! bRetVal = false; break; } } return bRetVal; } // // functions // function slideShow(imgId) { // get the currently loaded image file, note that the src will be the // fully qualified URL of the image, not just "image/*.jpg", so we extract // just the "image/*.jpg" from the URL for comparison here. var randomImgSrcStr = document.getElementById('randomImg').src; var randomImgSrcArray = randomImgSrcStr.split("/"); var randomImgSrc = randomImgSrcArray[randomImgSrcArray.length - 2] + "/" + randomImgSrcArray[randomImgSrcArray.length - 1]; if (imgId == -1) { // get a new random number first, ensuring it is not the same as the currently loaded photo do { imgId = parseInt(Math.random() * photo_array.length); imgId = (isNaN(imgId)) ? 0 : imgId; if (imgId == photo_array.length) { imgId = imgId - 1; } } while (notPrevImg(imgId) == false); } // end called in body onload event with -1 as the imgId updatePrevImgArray(imgId); // We fade out and photo and then fade a new one in with a brief interval of // only the background. So blendImage() is not used any more. // setTimeout("blendImage(" + imgId + ")", delayMs); setTimeout("fadeOutImage(" + imgId + ")", delayMs); // calculate new random image, ensuring it is not the same as the currrently loaded photo var newImgId; do { newImgId = parseInt(Math.random() * photo_array.length); newImgId = (isNaN(imgId)) ? 0 : newImgId; if (newImgId == photo_array.length) { newImgId = newImgId - 1; } } while (notPrevImg(newImgId) == false); setTimeout("slideShow(" + newImgId + ")", delayMs * 3); } // end slideShow() function fadeOutImage(imgId) { var speed = 10; var timer = 0; // fade out the image for (i = 99; i >= 0; i--) { setTimeout("changeOpac(" + i + ",'randomImg')", (timer * speed)); timer++; } // fade in the new image in the next interval setTimeout("fadeInImage(" + imgId + ")", delayMs / 5); // clear caption document.getElementById('pImgCaption').innerHTML = "
"; } function fadeInImage(imgId) { var speed = 10; var timer = 0; //make image transparent changeOpac(0, 'randomImg'); //make new image document.getElementById('randomImg').src = photo_array[imgId]; for (i = 0; i < 100; i++) { setTimeout("changeOpac(" + i + ",'randomImg')", (timer * speed)); timer++; } // set new caption document.getElementById('pImgCaption').innerHTML = photo_caption_array[imgId]; } // end fadeInImage() // MDD - NOTE - Due to difficulties with achieving the fade in/out I choose // to fade out and then fade in, in two separate steps, rather than fade from // one photo to another. In FireFox there was usually a nasty flicker and in // IE7 on some systems there was no fade at all, although that still happens. // Basically I think it is nicer to avoid the flickering images on FireFox. function blendImage(imgId) { var speed = 10; var timer = 0; //set the current image as background document.getElementById('imgDiv').style.backgroundImage = "url(" + document.getElementById('randomImg').src + ")"; //make image transparent changeOpac(0, 'randomImg'); //make new image document.getElementById('randomImg').src = photo_array[imgId]; // // fade in image - note to mostly avoid the flickering seen in mozilla, which // according the author of these scripts is due to: // // "The first bug is rather obvious, when fading in there is a flickering // just before the transition finishes. This is because the semi-transparant // image is converted to a fully visible one. You can prevent this from // happening by making the image only 99% visible (-moz-opacity: 0.99)." // // So below we iterate to less than 100. But this doesn't work all the // time but it works most of the time. // for (i = 0; i < 100; i++) { setTimeout("changeOpac(" + i + ",'randomImg')", (timer * speed)); timer++; } // set new caption document.getElementById('pImgCaption').innerHTML = photo_caption_array[imgId]; } // end blendImage() function changeOpac(opacity, id) { //change the opacity for different browsers var object = document.getElementById(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; } // end changeOpac() // // Write link content a-CommentLink // function writeCommentLink() { var aCommentLink1 = document.getElementById("a-CommentLink1"); var aCommentLink2 = document.getElementById("a-CommentLink2"); aCommentLink1.href = "mailto:emailgnome@boulderchaos.org"; aCommentLink1.innerHTML = "emailgnome@boulderchaos.org"; aCommentLink2.href = "mailto:emailgnome@boulderchaos.org"; aCommentLink2.innerHTML = "emailgnome@boulderchaos.org"; } // end writeCommentLink()