var PopularPhotoLoader = Class.create({ albums: [{"id":"7846","name":"New military equipment to adorn Victory Parade","url":"\/photo\/album\/7846\/","imgTag":"\"New","photoCount":"9"},{"id":"7847","name":"Space through the eyes of Hubble Telescope","url":"\/photo\/album\/7847\/","imgTag":"\"Space","photoCount":"10"},{"id":"7849","name":"Animals on the brink of extinction","url":"\/photo\/album\/7849\/","imgTag":"\"Animals","photoCount":"12"},{"id":"7845","name":"Accidents of the week","url":"\/photo\/album\/7845\/","imgTag":"\"Accidents","photoCount":"7"},{"id":"7689","name":"Irina Shayk, Stephen James and shoes","url":"\/photo\/album\/7689\/","imgTag":"\"Irina","photoCount":"9"},{"id":"7726","name":"Giant Brazilian Amazon dwarfs men for money","url":"\/photo\/album\/7726\/","imgTag":"\"Giant","photoCount":"6"},{"id":"7801","name":"Polar bears roaming in London","url":"\/photo\/album\/7801\/","imgTag":"\"Polar","photoCount":"6"},{"id":"7810","name":"Rafale flying to Egypt?","url":"\/photo\/album\/7810\/","imgTag":"\"Rafale","photoCount":"7"},{"id":"7841","name":"Ghost cats that no one can see","url":"\/photo\/album\/7841\/","imgTag":"\"Ghost","photoCount":"16"}], 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); } });