var PopularPhotoLoader = Class.create({ albums: [{"id":"8096","name":"Maurizio Cattelan: Art scene\u2019s joker","url":"\/photo\/album\/8096\/","imgTag":"\"Maurizio","photoCount":"7"},{"id":"8090","name":"Immortal Regiment march in Russia","url":"\/photo\/album\/8090\/","imgTag":"\"Immortal","photoCount":"8"},{"id":"8095","name":"Russia's military force in the Far East","url":"\/photo\/album\/8095\/","imgTag":"\"Russia","photoCount":"10"},{"id":"8094","name":"EgyptAir crash: No explosion detected","url":"\/photo\/album\/8094\/","imgTag":"\"EgyptAir","photoCount":"6"},{"id":"8086","name":"Russia gets ready for Victory Day","url":"\/photo\/album\/8086\/","imgTag":"\"Russia","photoCount":"8"},{"id":"8087","name":"Canada on fire","url":"\/photo\/album\/8087\/","imgTag":"\"Canada","photoCount":"8"},{"id":"8092","name":"Women on banknotes","url":"\/photo\/album\/8092\/","imgTag":"\"Women","photoCount":"10"},{"id":"8093","name":"Russia and China to hold more military drills in 2016","url":"\/photo\/album\/8093\/","imgTag":"\"Russia","photoCount":"9"},{"id":"8091","name":"Eight wonders of the world in architecture","url":"\/photo\/album\/8091\/","imgTag":"\"Eight","photoCount":"8"},{"id":"8097","name":"Women of the Mursi tribe and their taste for beauty","url":"\/photo\/album\/8097\/","imgTag":"\"Women","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); } });