var PopularPhotoLoader = Class.create({ albums: [{"id":"7882","name":"Sikorsky MH-53: Super Jolly Green Giant","url":"\/photo\/album\/7882\/","imgTag":"\"Sikorsky","photoCount":"6"},{"id":"7891","name":"Living in a Skylodge","url":"\/photo\/album\/7891\/","imgTag":"\"Living","photoCount":"7"},{"id":"7878","name":"F-22 Raptor jets ready to fly to Europe","url":"\/photo\/album\/7878\/","imgTag":"\"F-22","photoCount":"7"},{"id":"7893","name":"Trains crash, fires and heat rage","url":"\/photo\/album\/7893\/","imgTag":"\"Trains","photoCount":"7"},{"id":"7883","name":"Le Bourget 2015: Not too much to show","url":"\/photo\/album\/7883\/","imgTag":"\"Le","photoCount":"10"},{"id":"7884","name":"Beautiful, stinky and rare","url":"\/photo\/album\/7884\/","imgTag":"\"Beautiful,","photoCount":"6"},{"id":"7890","name":"San Fermin Festival: Running of the bulls","url":"\/photo\/album\/7890\/","imgTag":"\"San","photoCount":"7"},{"id":"7889","name":"Biologist puts 50 sharks in a trance","url":"\/photo\/album\/7889\/","imgTag":"\"Biologist","photoCount":"6"},{"id":"7888","name":"This week has claimed too many lives","url":"\/photo\/album\/7888\/","imgTag":"\"This","photoCount":"9"},{"id":"7877","name":"Crazy ideas about fountains","url":"\/photo\/album\/7877\/","imgTag":"\"Crazy","photoCount":"8"},{"id":"7887","name":"Zaha Hadid: Evoking chaos of modern life","url":"\/photo\/album\/7887\/","imgTag":"\"Zaha","photoCount":"9"},{"id":"7886","name":"Beauty of foggy mornings","url":"\/photo\/album\/7886\/","imgTag":"\"Beauty","photoCount":"7"},{"id":"7881","name":"Russia marks Day of Memory and Grief","url":"\/photo\/album\/7881\/","imgTag":"\"Russia","photoCount":"10"},{"id":"7880","name":"Summer season starts claiming tourists' lives","url":"\/photo\/album\/7880\/","imgTag":"\"Summer","photoCount":"7"},{"id":"7879","name":"Valentina Tereshkova: First lady of generations","url":"\/photo\/album\/7879\/","imgTag":"\"Valentina","photoCount":"8"},{"id":"7689","name":"Irina Shayk, Stephen James and shoes","url":"\/photo\/album\/7689\/","imgTag":"\"Irina","photoCount":"9"}], count: 5, horizontal: true, nodeId: 'gallery-id', newWindow: false, target: '_self', url: null, initialize: function(count, horizontal, nodeId, newWindow, url) { this.count = count; this.horizontal = horizontal; if (nodeId) this.nodeId = nodeId; if (newWindow) this.newWindow = newWindow; this.target = newWindow ? '_blank' : '_self'; if (url) this.url = url; this.render(); }, render: function() { var table = new Element('table', {'class' : 'frame', 'style' : 'width:100%;font-size:12px;'}); if (this.horizontal) var row = table.insertRow(-1); var limit = this.albums.length > this.count ? this.count : this.albums.length; this.albums.shuffle(); for (var i=0; i < limit; i++) { if (!this.horizontal) var row = table.insertRow(-1); var cell = row.insertCell(-1); cell.setAttribute('valign', 'top'); if (limit == 2) cell.setAttribute('style', 'width:50%'); if (this.albums[i].imgTag) { var a = new Element('a', {'href' : ((this.url ? this.url : '')+this.albums[i].url), 'target' : this.target}); a.innerHTML = this.albums[i].imgTag; cell.appendChild(a); } var a = new Element('a', {'href' : ((this.url ? this.url : '')+this.albums[i].url), 'target' : this.target}); a.appendChild(document.createTextNode(this.albums[i].name)); cell.appendChild(a); cell.appendChild(new Element('br')); var a = new Element('a', {'href' : ((this.url ? this.url : '')+this.albums[i].url), 'class' : 'hot', 'target' : this.target}); a.appendChild(document.createTextNode('('+this.albums[i].photoCount+' photos)')); cell.appendChild(a); } $(this.nodeId).innerHTML = ''; $(this.nodeId).appendChild(table); } });