function C_popup_open(page_url){
    if(_calcCenter){
        _pos_l = Math.floor( (screen.width   - _dim_w) /2);
        _pos_t = Math.floor( (screen.height  - _dim_h) /2);
    }
    if(_calcStyle == true){
        _style = '';
        if(_pos_t > 0)              _style += 'top='        + _pos_t        + ', ';
        if(_pos_l > 0)              _style += 'left='       + _pos_l        + ', ';
        if(_dim_w > 0)              _style += 'width='      + _dim_w        + ', ';
        if(_dim_h > 0)              _style += 'height='     + _dim_h        + ', ';
        
        if(_resizable != -1)        _style += 'resizable='      + _resizable    + ', ';
        if(_scrollbars != -1)       _style += 'scrollbars='     + _scrollbars   + ', ';
        if(_toolbar != -1)          _style += 'toolbar='        + _toolbar      + ', ';
        if(_menubar != -1)          _style += 'menubar='        + _menubar      + ', ';
        if(_location != -1)         _style += 'location='       + _location     + ', ';
        if(_status != -1)           _style += 'status='         + _status       + ', ';
        if(_directories != -1)      _style += 'directories='    + _directories  + ', ';

        if(_style != "") _style = _style.substring (0 ,_style.length-2) + ''; 
    }
    
    if(page_url != undefined) this.page_url = page_url;
    
    this.win_ref = window.open( this.page_url , this.name , _style );
}

function C_popup_center_pos(center){
    if(center==true)    _calcCenter = true; else _calcCenter = false;
}

function C_popup_set_pos(t,l){
    _pos_t = t; 
    _pos_l = l; 
    _calcStyle = true;
}

function C_popup_set_dim(w,h){
    _dim_w = w; 
    _dim_h = h; 
    _calcStyle = true;
}


function C_popup_resizable(resizable)       {   if(resizable==true)     _resizable      = 1;    else _resizable     = 0;    _calcStyle = true;  }
function C_popup_scrollbars(scrollbars)     {   if(scrollbars==true)    _scrollbars     = 1;    else _scrollbars    = 0;    _calcStyle = true;  }
function C_popup_toolbar(toolbar)           {   if(toolbar==true)       _toolbar        = 1;    else _toolbar       = 0;    _calcStyle = true;  }    
function C_popup_menubar(menubar)           {   if(menubar==true)       _menubar        = 1;    else _menubar       = 0;    _calcStyle = true;  }
function C_popup_location(location)         {   if(location==true)      _location       = 1;    else _location      = 0;    _calcStyle = true;  }
function C_popup_status(status)             {   if(status==true)        _status         = 1;    else _status        = 0;    _calcStyle = true;  }
function C_popup_directories(directories)   {   if(directories==true)   _directories    = 1;    else _directories   = 0;    _calcStyle = true;  }



function C_popup_set(name,page_url){
    this.name           = name;
    this.page_url       = page_url;
}

function C_popup_set_style(resizable,scrollbars,toolbar,menubar,location,status,directories){
    if(resizable==true)     _resizable      = 1;    else _resizable     = 0;
    if(scrollbars==true)    _scrollbars     = 1;    else _scrollbars    = 0;
    if(toolbar==true)       _toolbar        = 1;    else _toolbar       = 0;    
    if(menubar==true)       _menubar        = 1;    else _menubar       = 0;
    if(location==true)      _location       = 1;    else _location      = 0;
    if(status==true)        _status         = 1;    else _status        = 0;
    if(directories==true)   _directories    = 1;    else _directories   = 0;
    _calcStyle = true;
}

function C_popup(){
    this.win_ref        = false;
    this.name           = "";
    this.page_url       = "";
    _calcStyle          = false;
    _calcCenter         = false;
    _style              = "";
    _pos_t              = 1;            // top=pixels     Specifies the Y coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)
    _pos_l              = 1;            // left=pixels     Specifies the X coordinate of the top left corner of the new window. (Not supported in version 3 browsers.)
    _dim_w              = 10;           // width=pixels     Specifies the width of the new window.
    _dim_h              = 10;           // height=pixels     Specifies the height of the new window.
    
    _resizable          = -1;           //=0|1     Specifies whether the new window is resizable.
    _scrollbars         = -1;           //=0|1     Specifies whether the new window should have scrollbars.
    _toolbar            = -1;           //=0|1     Specifies whether to display the toolbar in the new window.
    _menubar            = -1;           //=0|1     Specifies whether to display the browser menu bar.
    _location           = -1;           //=0|1     Specifies whether to display the address line in the new window.
    _status             = -1;           //=0|1     Specifies whether to display the browser status bar.
    _directories        = -1;           //=0|1     Specifies whether to display the Netscape directory buttons.
    
    // FUNZIONI
    this.open           = C_popup_open;
    this.set_pos        = C_popup_set_pos;
    this.set_dim        = C_popup_set_dim;
    this.center_pos     = C_popup_center_pos;
    
    this.resizable      = C_popup_resizable;
    this.scrollbars     = C_popup_scrollbars;
    this.toolbar        = C_popup_toolbar;
    this.menubar        = C_popup_menubar;
    this.location       = C_popup_location;
    this.status         = C_popup_status;
    this.directories    = C_popup_directories;

    this.set            = C_popup_set;
    this.set_style      = C_popup_set_style;
}
