function PhotoGrid(Q){var B=jQuery("#"+Q.elementId),N=null,C=null,I=this,O=0,H=0,F=0,S=null,L=null;
for(var U in PhotoGrid.DEFAULTS){if(typeof (Q[U])=="undefined"){Q[U]=PhotoGrid.DEFAULTS[U]
}}N=jQuery("<div>");
B.css("position","relative");
B.append(N);
if(Q.selectBoxId!==null){J()
}if(Q.throbberId!==null){S=jQuery("#"+Q.throbberId)
}if(Q.popupElementId!==null){L=jQuery("#"+Q.popupElementId).html()
}else{L=Q.popupHtml
}P();
function J(){C=jQuery("#"+Q.selectId);
C.change(function(){I.reload()
})
}function P(){var V="";
if(C!==null){V="/"+C.selectedValues()[0]
}F=0;
E();
VTServicesManager.get("latestphotos",V,R)
}function E(){if(S!==null){S.fadeIn()
}}function A(){if(S!==null){S.hide()
}}function R(X){images=X;
var Y=0,W=0;
for(var V=0;
V<images.length;
V++){T(images[V],Y,W);
W++;
if(W>=Q.columnCount){W=0;
Y++
}}}function T(W,d,X){var c=jQuery("<div class='bg-black'><a><img></a></div>"),b=jQuery("a",c),Z=jQuery("img",c),V=jQuery(L),Y=Q.paddingLeft+X*(Q.imageWidth+Q.marginX),a=Q.paddingTop+d*(Q.imageHeight+Q.marginY);
c.addClass("abs").hide();
c.css({top:a+"px",left:Y+"px"});
Z.css({width:Q.imageWidth,height:Q.imageHeight,opacity:0.8,cursor:"pointer"});
Z.hover(function(){M(Z)
},function(){D(Z)
});
Z.load(function(){c.fadeIn();
F++;
if(F==images.length){A()
}});
V.addClass("abs").hide();
V.css({top:a+"px",left:(Y+Q.imageWidth)+"px",opacity:0,zIndex:1000});
jQuery(".title",V).html(W.title);
jQuery(".usertext",V).html(W.userText);
jQuery(".userimage",V).attr("src",W.userImageUrl);
if(typeof (W.userRelevancy)=="undefined"){jQuery(".usersimilarity",V).hide()
}else{jQuery(".usersimilarity",V).show();
jQuery(".usersimilarity span",V).html(W.userRelevancy)
}b.attr("href",W.link);
N.append(c);
N.append(V);
Z.attr({src:W.imgMedium});
return Z
}function M(V){V.stop(true,true).animate({opacity:1});
V.closest("div").next(".extra").stop(true,true).show();
V.closest("div").next(".extra").animate({opacity:1})
}function D(V){V.stop(true,true).animate({opacity:0.8});
V.closest("div").next(".extra").stop(true,true).animate({opacity:0},function(){jQuery(this).hide()
})
}function G(V){reloadCount++;
if(reloadCount==H&&V!==undefined&&V!==null){V.call()
}}function K(V){N.children().fadeOut(function(){jQuery(this).remove();
G(V)
})
}this.reload=function(V){reloadCount=0;
H=N.children().length-1;
K(P())
}
}PhotoGrid.DEFAULTS={paddingLeft:2,paddingTop:2,marginX:2,marginY:2,imageWidth:93,imageHeight:62,columnCount:6,rowCount:6,popupHtml:"<div class='extra bg-white'><strong class='title'></strong><div class='usertext'></div></div>"};
