
/**
* Utilities for opening conventional pop-up windows
*/
Popup = {
    /**
    * The default width of a pop-up
    */
    DEFAULT_WIDTH : 550,
    
    /**
    * The default height of a pop-up
    */
    DEFAULT_HEIGHT : 300,

    /**
    * Opens a new pop-up window. This method is meant to be used in the onclick
    * attribute of an HTML link. For convenience, it always returns false.
    *
    * Example:
    * 
    * <a href="http://www.yahoo.com" onclick="return Popup.open(this)" />
    *
    * @param Object  link      a URL or a link element with an href atttibute
    * @param String  name      the window name (for scripting purposes and for use in the target attribute)
    * @param Integer width     the width of the window (optional)
    * @param Integer height    the height of the window (optional)
    * @param Boolean resizable whether the window will be resizable (defaults to false)
    * @param String  scroll    whether the window is scrollable (same format as 'scroll=...' in window.open())
    *
    * @return Boolean
    */
    open : function(link, name, width, height, resizable, scroll) {
        if (!width) {
            width = Popup.DEFAULT_WIDTH;
        }
        
        if (!height) {
            height = Popup.DEFAULT_HEIGHT;
        }
        if (!name) {
            name = 'popup';
        }
        
        if (typeof(resizable) == typeof(undefined)) {
            resizable = false;
        } 

        if (typeof(scroll) == typeof(undefined)) {
            scroll = false;
        }
        
        var href;
        
        if (link.href) {
            href = link.href;
        } else {
            href = link;
        }
        
        iw_open_window(
            href, 
            name, 
            width, 
            height, 
            resizable ? 'yes' : 'no', 
            scroll);
                        
        return false;
    }
}
