/* - Description jQuery Dynamic Slideshow Plugin - Author Yusuf Najmuddin (ynzi.com) - Licence GNU Lesser General Public License - Usage $("#slideshow").dynamicSlideshow(); OR $("#slideshow").dynamicSlideshow({duration: 5000}); - Date 6/30/2009 - Version 1.0 */ jQuery.fn.dynamicSlideshow = function(attr) { attr = attr || {}; attr.duration = attr.duration || 3000; function initSlider(container, img) { var curr = 1; setInterval( function(){ if (curr == img.length) { curr = 0; } var i = new Image(); $(i).load(function(){ $(container).append(this); $(container).find('img:first').css({'z-index': 1}); $(this).css({opacity: 0.0, 'z-index': 2}).animate({opacity: 1.0}, 1000, function() { $(container).find('img:first').remove(); }) }).attr('src', img[curr++]).css({position:'absolute',top:0,left:0,'z-index':8}); }, attr.duration ); }; $(this).each(function(){ var img = []; img[0] = '/files/image/slideshow/34-cch.jpg'; img[1] = '/files/image/slideshow/14-madre.jpg'; img[2] = '/files/image/slideshow/33-twp.jpg'; img[3] = '/files/image/slideshow/13-ijm.jpg'; img[4] = '/files/image/slideshow/04-cfk.jpg'; img[5] = '/files/image/slideshow/24-seva.jpg'; img[6] = '/files/image/slideshow/11-pxp.jpg'; img[7] = '/files/image/slideshow/18-oi.jpg'; img[8] = '/files/image/slideshow/16-map.jpg'; img[9] = '/files/image/slideshow/23-mano-a-mano.jpg'; img[10] = '/files/image/slideshow/15-wintek-lmo.jpg'; img[11] = '/files/image/slideshow/37-agi-hnc.jpg'; img[12] = '/files/image/slideshow/03-anera.jpg'; img[13] = '/files/image/slideshow/26-chinaconnection.jpg'; img[14] = '/files/image/slideshow/12-mujerespi-ip.jpg'; img[15] = '/files/image/slideshow/31-quest-for-peace.jpg'; img[16] = '/files/image/slideshow/21-pci.jpg'; img[17] = '/files/image/slideshow/01-shi.jpg'; img[18] = '/files/image/slideshow/07-standproud.jpg'; img[19] = '/files/image/slideshow/10-hands.jpg'; img[20] = '/files/image/slideshow/36-pid.jpg'; img[21] = '/files/image/slideshow/28-floresta.jpg'; img[22] = '/files/image/slideshow/29-ahead.jpg'; img[23] = '/files/image/slideshow/39-agi.jpg'; img[24] = '/files/image/slideshow/22-hhp.jpg'; img[25] = '/files/image/slideshow/25-mcc.jpg'; img[26] = '/files/image/slideshow/32-peer.jpg'; img[27] = '/files/image/slideshow/08-eo-and-ncef.jpg'; img[28] = '/files/image/slideshow/35-beyond-borders.jpg'; img[29] = '/files/image/slideshow/19-pearl-buck-inc.jpg'; img[30] = '/files/image/slideshow/06-agi.jpg'; img[31] = '/files/image/slideshow/09-empower-nepal.jpg'; img[32] = '/files/image/slideshow/27-itdp-and-b4h.jpg'; img[33] = '/files/image/slideshow/30-tnc.jpg'; img[34] = '/files/image/slideshow/17-dfgfi.jpg'; img[35] = '/files/image/slideshow/05-lwr.jpg'; img[36] = '/files/image/slideshow/02-cc-caritas.jpg'; img[37] = '/files/image/slideshow/38-agi.jpg'; img[38] = '/files/image/slideshow/20-ima.jpg'; img.sort(function() {return 0.5 - Math.random()}); var j = new Image(); var container = this; $(this).empty(); $(j).attr('src', img[0]).css({position:'absolute',top:0,left:0,'z-index':0}).load(function(){ $(container).append(this); initSlider(container, img); }); }); }