function getInternetExplorerVersion() { var rv = -1; if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; } function fadeInImage() { if (getInternetExplorerVersion() > -2) return; for (i = 0; i <= 100; i++) { setTimeout("setOpacity(document.getElementById('map_surv'), "+i+")", 600+i*5); } } function fadeOutImage() { if (getInternetExplorerVersion() > -2) return; for (i = 0; i <= 100; i++) { setTimeout("setOpacity(document.getElementById('map_surv'), "+(100-i)+")", i*5); } } var images = new Array( 'http://www.bugwoodcloud.org/images/384x256/0949056.jpg', 'http://www.bugwoodcloud.org/images/384x256/5140026.jpg', 'http://www.bugwoodcloud.org/images/384x256/1442029.jpg', 'http://www.bugwoodcloud.org/images/384x256/0454075.jpg', 'http://www.bugwoodcloud.org/images/384x256/5371055.jpg', 'http://www.bugwoodcloud.org/images/384x256/1277089.jpg', 'http://www.bugwoodcloud.org/images/384x256/1265128.jpg', 'http://www.bugwoodcloud.org/images/384x256/5143071.jpg', 'http://www.bugwoodcloud.org/images/384x256/1231178.jpg', 'http://www.bugwoodcloud.org/images/384x256/9000019.jpg', 'http://www.bugwoodcloud.org/images/384x256/2105040.jpg' ); var names = new Array( 'Asian Longhorned Beetle - Anoplophora glabripennis', 'Egyptian Cottonworm - Spodoptera littoralis', 'Japanese Pine Sawyer Beetle - Monochamus alternatus', 'Old World Bollworm - Helicoverpa armigera', 'Oak Splendour Beetle - Agrilus biguttatus', 'Rosy Moth - Lymantria mathura', 'Silver Y Moth - Autographa gamma', 'Summer Fruit Tortrix Moth - Adoxophes orana', 'Large Pine Weevil - Hylobius abietis', 'Emerald Ash Borer - Agrilus planipennis', 'Pine Shoot Beetle - Tomicus piniperda' ); var pestcodes = new Array( 'INALQCA', 'ITBCFPA', 'INALQQA', 'ITBCFBA', 'INAHRPA', 'ITAXQIA', 'ITBCFCA', 'ITBUETA', 'INASHZA', 'INAHQJA', 'INBQCNA' ); var imageWidth = 288; var imageHeight = 192; var imageTimeout = 5000; function shuffle(o) { for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); } var positions = []; for (var i = 0, n = images.length; i < n; i++) { positions[i] = i; } shuffle(positions); var cur = 1; var nextImage = positions[1]; function pageLoad() { var el = document.getElementById('fading_image_container'); var el2 = document.getElementById('fading_citation_container'); while (el.firstChild) { el.removeChild(el.firstChild); } el.style.width = imageWidth + 'px'; el.style.height = imageHeight + 'px'; for(var i=0; i'; window.setTimeout(startFading, imageTimeout); } function goPest(code) { window.location = "pest.php?code="+code; } function startFading() { if (showPaused) { window.setTimeout(startFading, 1000); return; } var el = document.getElementById('fading_image_container').childNodes[cur]; var el2 = document.getElementById('fading_citation_container'); var map_surv = document.getElementById('map_surv'); el.style.visibility = 'visible'; el.style.zIndex = 2; el2.innerHTML = '' + names[nextImage] + '' var el_pest = document.getElementById("linkpest"); var el_map = document.getElementById("linkmap"); el_pest.href = "pest.php?code="+pestcodes[nextImage]; el_map.href = "map.php?code="+pestcodes[nextImage]; var pc = pestcodes[nextImage]; document.getElementById("fading_image_container").onclick = function() { goPest(pc); }; document.getElementById('map_surv').src = '/images/surveys/'+pc+'.png'; fadeOutImage(); setOpacity(el, 0); fadeImage(el,0); // nextImage = (nextImage < images.length-1) ? nextImage + 1 : 0; cur = (cur < images.length-1) ? cur + 1 : 0; nextImage = positions[cur]; } function fadeImage(el, currentOpacity) { currentOpacity += 5; if (currentOpacity > 100) { setOpacity(el, 100); var prevEl = el.previousSibling ? el.previousSibling : el.parentNode.lastChild; prevEl.style.visibility = 'hidden'; el.style.zIndex = 1; window.setTimeout(startFading, imageTimeout); } else { setOpacity(el, currentOpacity); window.setTimeout(function() { fadeImage(el, currentOpacity); }, 50); } } function setOpacity(el, opacity) { opacity /= 100; el.style.opacity = opacity; el.style.MozOpacity = opacity; el.style.filter = "alpha(opacity=" + (opacity*100) + ")"; }