/*
 * Ext JS Library 1.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

// create the HelloWorld application (single instance)
var kpDialog = function(){
    // everything in this space is private and only accessible in the HelloWorld block
    
    // define some private variables
    var dialog;
    
    // return a public interface
    return {
        init : function(){
             //showBtn = Ext.get('portfolio_everest_tn_1');
             // attach to click event
             //showBtn.on('click', this.showDialog, this);
        },
        
        setSize : function(obj_img){
            if (dialog){
                dialog.resizeTo(obj_img.width + 35, obj_img.height + 111);
            }
        }, 
        
        showDialog : function(obj_button, obj_img, title){
            if(!dialog){ // lazy initialize the dialog and only create it once
                dialog = new Ext.BasicDialog("dialogShowImage", { 
                        autoTabs:true,
                        shadow:true,
                        minWidth:300,
                        minHeight:250,
                        proxyDrag: true,
                        animateTarget: true,
                        syncHeightBeforeShow: true
                });
                dialog.addKeyListener(27, dialog.hide, dialog);
                //dialog.addButton('Submit', dialog.hide, dialog).disable();
                dialog.addButton('Close', dialog.hide, dialog);
            }
            this.setSize(obj_img);
            dialog.center();
            //dialog.body.insertHTML("beforeBegin", title + "here", false);
            dialog.setTitle("Gallery Browser: " + title);
            dialog.show(obj_button.dom);
        }
    };
}();

// using onDocumentReady instead of window.onload initializes the application
// when the DOM is ready, without waiting for images and other resources to load
Ext.onReady(kpDialog.init, kpDialog, true);