var ViewFriend=function(){
	var dialog;
	return {
        init : function(){
			Ext.select("img.g-tn",true,pics).on('click', this.showDialog, this);
        },
        showDialog : function(e) {
			if(!dialog){
                dialog = new Ext.BasicDialog(Ext.DomHelper.append(document.body, {tag: "div"}), {
                        autoTabs:false,
                        modal:true,
                        shadow:false,
                        proxyDrag: false,
                        draggable: false,
                        resizable: false,
                        collapsible:false,
                        buttonAlign:'center',
                        autoScroll:false
                });
                dialog.addKeyListener(27, dialog.hide, dialog);
                dialog.addButton('Close', dialog.hide, dialog);
            }
            var args = e.target.id.split('-');
            var w=parseInt(args[2]);
            var h=parseInt(args[3]);
            var factor = 1.0;
			if(w > 600 || h > 600) {
				if(w > h) factor = 600/w;
				else factor = 600/h;
				w=Math.round(w*factor);
				h=Math.round(h*factor);
			}
            dialog.setContentSize(w,h);
            dialog.setTitle("Click to view full size (" + args[2] + "x" + args[3] + "), Hit ESC to close dialog");
            dialog.center();
            dialog.show(e.target);
            dialog.body.update("<a title='Click to view full size (" + + args[2] + "x" + args[3] + ")' target='_blank' href='/image/upic.aspx?id=" + args[1] + "'><img border='0' width='" + w + "' height='" + h + "' src='/image/upic.aspx?id=" + args[1] + "&resize=600'></a>");
          
        }
};}();
Ext.onReady(ViewFriend.init,ViewFriend,true);
