var PopularPhotoLoader = Class.create({ albums: [{"id":"8064","name":"FlyDubai Boeing crash: Human factor to blame?","url":"\/photo\/album\/8064\/","imgTag":"\"FlyDubai","photoCount":"6"},{"id":"8068","name":"Nagorno Karabakh. War and death again","url":"\/photo\/album\/8068\/","imgTag":"\"Nagorno","photoCount":"6"},{"id":"8031","name":"Terror in Brussels","url":"\/photo\/album\/8031\/","imgTag":"\"Terror","photoCount":"8"},{"id":"8022","name":"Turkey: Fifth attack","url":"\/photo\/album\/8022\/","imgTag":"\"Turkey:","photoCount":"7"},{"id":"8066","name":"Pavlof volcano erupts in Alaska","url":"\/photo\/album\/8066\/","imgTag":"\"Pavlof","photoCount":"7"},{"id":"8070","name":"Nagorno Karabakh: Time bomb","url":"\/photo\/album\/8070\/","imgTag":"\"Nagorno","photoCount":"10"},{"id":"8065","name":"Syria's Palmyra will revive","url":"\/photo\/album\/8065\/","imgTag":"\"Syria","photoCount":"9"},{"id":"8030","name":"Boeing 737 crashes in Russia: 62 killed","url":"\/photo\/album\/8030\/","imgTag":"\"Boeing","photoCount":"6"},{"id":"8069","name":"Svalbard: Arctic beauty untouched","url":"\/photo\/album\/8069\/","imgTag":"\"Svalbard:","photoCount":"10"},{"id":"8023","name":"Russian troops leave Syria","url":"\/photo\/album\/8023\/","imgTag":"\"Russian","photoCount":"8"}], 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); } });