var PopularPhotoLoader = Class.create({ albums: [{"id":"8309","name":"Chinese kid army: Serving in strappy pants","url":"http:\/\/www.pravdareport.com\/photo\/album\/8309\/","imgTag":"\"Chinese","photoCount":"6"},{"id":"8311","name":"Siara, a skydiving dog","url":"http:\/\/www.pravdareport.com\/photo\/album\/8311\/","imgTag":"\"Siara,","photoCount":"7"},{"id":"8304","name":"Provincial Russia: Ostashkov","url":"http:\/\/www.pravdareport.com\/photo\/album\/8304\/","imgTag":"\"Provincial","photoCount":"9"},{"id":"8310","name":"Iskander-M: Superpower on wheels","url":"http:\/\/www.pravdareport.com\/photo\/album\/8310\/","imgTag":"\"Iskander-M:","photoCount":"10"},{"id":"8307","name":"Greenland, Land of color","url":"http:\/\/www.pravdareport.com\/photo\/album\/8307\/","imgTag":"\"Greenland,","photoCount":"9"},{"id":"8308","name":"F-22 Raptor in the sky","url":"http:\/\/www.pravdareport.com\/photo\/album\/8308\/","imgTag":"\"F-22","photoCount":"8"},{"id":"8305","name":"Gems of Russia: Astrakhan Kremlin","url":"http:\/\/www.pravdareport.com\/photo\/album\/8305\/","imgTag":"\"Gems","photoCount":"14"},{"id":"8302","name":"\u0412-52\u041d: Subsonic Stratofortress","url":"http:\/\/www.pravdareport.com\/photo\/album\/8302\/","imgTag":"\"\u0412-52\u041d:","photoCount":"7"},{"id":"8306","name":"AH-64 Apache: Flying tank killer","url":"http:\/\/www.pravdareport.com\/photo\/album\/8306\/","imgTag":"\"AH-64","photoCount":"7"}], 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); } });