function slideshow_load() { var slideshow = { showwin : null, showimg : null, list : null, current : 0, baseURL : wgServer + wgArticlePath.replace( "$1" , "File:"), nextImage : function() { with(slideshow) { if( showwin != null && showwin.document != null ) { showimg.src = 'http://toolserver.org/tsthumb/tsthumb?w=800&h=800&domain=commons.wikimedia.org&f='+encodeURIComponent(slideshow.list[slideshow.current]); current++; if( current >= list.length ) current = 0; window.setTimeout(slideshow.nextImage,3000); } } }, showButton : function() { this.startButton.style.visibility = 'visible'; }, hideButton : function() { this.startButton.style.visibility = 'hidden'; }, // cross-browser event attachment (John Resig) // http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html addEvent : function ( obj, type, fn ) { if (obj.addEventListener) obj.addEventListener( type, fn, false ); else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent( "on"+type, obj[type+fn] ); } }, start : function( e ) { slideshow.list = new Array(); slideshow.current = 0; var links; if( typeof(this.gallery) != 'undefined' ) { slideshow.showwin = window.open('', 'showwin', 'left=0,top=0,width=' + screen.width + ',height=' + screen.height + ',toolbar=0,resizable=0,fullscreen=1'); var divs = this.gallery.getElementsByTagName('div'); for( var key=0; key< divs.length; key++ ) { if( divs[key].className == 'thumb' ) { links = divs[key].getElementsByTagName('a'); if( links.length > 0 && links[0].href.substr( 0, slideshow.baseURL.length ) == slideshow.baseURL ) slideshow.list.push( links[0].href.substr( slideshow.baseURL.length ) ); } } slideshow.showwin.document.open('text/html'); slideshow.showwin.document.write('
'); slideshow.showwin.document.close(); slideshow.showimg = slideshow.showwin.document.getElementById('showimg'); slideshow.nextImage(); } }, install : function() { var galleries = document.getElementsByTagName('table'); var cells; var button; for( var key=0; key < galleries.length; key++ ) { if( galleries[key].className == 'gallery' ) { cells = galleries[key].getElementsByTagName('div'); if( cells.length > 0 ) { button = document.createElement('div'); button.style.border = '1px solid gray'; button.style.position = 'absolute'; button.style.padding = '0.5em'; button.style.backgroundColor = '#ddffdd'; button.style.top = '0.5em'; button.style.left = '0.5em'; button.style.cursor = 'pointer'; button.style.visibility = 'hidden'; button.gallery = galleries[key]; button.appendChild( document.createTextNode( 'Slideshow' ) ); slideshow.addEvent( button, 'click', slideshow.start ); galleries[key].startButton = button; slideshow.addEvent( galleries[key], 'mouseover', slideshow.showButton ); slideshow.addEvent( galleries[key], 'mouseout', slideshow.hideButton ); cells[0].style.position = 'relative'; cells[0].insertBefore( button, cells[0].childNodes[0] ); } } } } } addOnloadHook(slideshow.install); } if (window.addEventListener) window.addEventListener('load', slideshow_load, false); // W3C DOM else window.attachEvent('onload', slideshow_load); // MSIE