//dispatch sets up setting panel for panel type of domaininfo
var certinfo_dispatch = function(){
    if ( canaddeditpackages == true ) {
        // (re)assign certificate id
        if ( $('#textfield_certid').length > 0 ) {
            btn = $('<div style="float:right;padding-left:2px;" id="divassigncertid"></div>')
            $('#textfield_certid').append(btn);
            new Ext.Button({
                id: 'reassigncertid',
                renderTo : 'divassigncertid',
                width: 20,
                cls: 'x-box-text-small',
                text: lang('Reassign'),
                listeners: {
                    click : function (btn,event) {
                        Ext.MessageBox.prompt('Assign Certificate Id', 'Please enter the certificate id:', certinfoAssignCertId);
                    }
                }
            });
        }
        
        
        if ( $('#textarea_csr').length > 0 ) {
            var appendee = '#textarea_csr';
        } else {
            var appendee = '#textfield_status';
        }
        
        btn = $('<div style="float:right;padding-left:2px;" id="divviewcsrdetails"></div>')
        $(appendee).append(btn);
        new Ext.Button({
            id: 'viewcsrdetails',
            renderTo : 'divviewcsrdetails',
            width: 20,
            cls: 'x-box-text-small',
            text: lang('View Details'),
            listeners: {
                click : function (btn,event) {
                    viewDetailsWindow = new RichHTML.window({
                        height: 'auto',
                        width: 'auto',
                        url: 'index.php?fuse=clients&view=ViewCSRDetails&packageId=' + packageemanager.package_id,
                        title: lang('CSR Details')
                    });
                    viewDetailsWindow.show();
                }
            }
        });
        
    }
}

function certinfoAssignCertId(btn, text){
    if (btn == "cancel") return;

    //add hidden field for new orderid
    $('#productsettingsform').append("<input type='hidden' name='certid' value='"+text+"'></input>");
    Ext.getCmp('certid').setValue(text);
    //now submit as a save
    $('#btnUpdateProduct').click();

    if (text == "") {
        Ext.getCmp('certid').setValue(lang("Unknown"));
    }
}