var PopularPhotoLoader = Class.create({ albums: [{"id":"8108","name":"Istanbul airport blasts: Death toll climbs","url":"\/photo\/album\/8108\/","imgTag":"\"Istanbul","photoCount":"5"},{"id":"8112","name":"Most amazing bridges in the world","url":"\/photo\/album\/8112\/","imgTag":"\"Most","photoCount":"10"},{"id":"8111","name":"National parks of the world","url":"\/photo\/album\/8111\/","imgTag":"\"National","photoCount":"10"},{"id":"8109","name":"A look into deep black space","url":"\/photo\/album\/8109\/","imgTag":"\"A","photoCount":"6"},{"id":"8103","name":"Planet of volcanoes","url":"\/photo\/album\/8103\/","imgTag":"\"Planet","photoCount":"7"},{"id":"8110","name":"Meteorites terrorizing Earth","url":"\/photo\/album\/8110\/","imgTag":"\"Meteorites","photoCount":"9"},{"id":"8105","name":"USA, India and Japan in joint Malabar drills","url":"\/photo\/album\/8105\/","imgTag":"\"USA,","photoCount":"8"},{"id":"8107","name":"Ten most beautiful mosques in the world","url":"\/photo\/album\/8107\/","imgTag":"\"Ten","photoCount":"10"},{"id":"8104","name":"Euro-2016: International mess in France","url":"\/photo\/album\/8104\/","imgTag":"\"Euro-2016:","photoCount":"10"},{"id":"8106","name":"United States Sixth Fleet: The show of power","url":"\/photo\/album\/8106\/","imgTag":"\"United","photoCount":"12"}], 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); } });