var PopularPhotoLoader = Class.create({ albums: [{"id":"8156","name":"Syria: Tortured by war","url":"\/photo\/album\/8156\/","imgTag":"\"Syria:","photoCount":"7"},{"id":"8159","name":"Italy: Left to the mercy of nature","url":"\/photo\/album\/8159\/","imgTag":"\"Italy:","photoCount":"8"},{"id":"8154","name":"French authorities dismantle Calais refugee camp","url":"\/photo\/album\/8154\/","imgTag":"\"French","photoCount":"9"},{"id":"8155","name":"How many national holidays do you have a year?","url":"\/photo\/album\/8155\/","imgTag":"\"How","photoCount":"8"},{"id":"8150","name":"Storm of Mosul, Iraq","url":"\/photo\/album\/8150\/","imgTag":"\"Storm","photoCount":"6"},{"id":"8158","name":"Ten things you'd never think were named after people","url":"\/photo\/album\/8158\/","imgTag":"\"Ten","photoCount":"10"},{"id":"8151","name":"AH-64 Apache: Prime attack chopper of US Army","url":"\/photo\/album\/8151\/","imgTag":"\"AH-64","photoCount":"7"},{"id":"8147","name":"Russia deploys Iskanders in Kaliningrad","url":"\/photo\/album\/8147\/","imgTag":"\"Russia","photoCount":"6"},{"id":"8148","name":"Largest whirlpools in the world","url":"\/photo\/album\/8148\/","imgTag":"\"Largest","photoCount":"8"},{"id":"8149","name":"Evolution of Rolls-Royce","url":"\/photo\/album\/8149\/","imgTag":"\"Evolution","photoCount":"10"}], 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); } });