licensedefender.addLicense = function(x,y) 
{

    licensedefender.addLicenseWindow = new Ext.Window({
            layout:       'form',
            width:        350,
            modal:        true,
            x: x + 40,
            y: y - 70,
            bodyStyle:    'padding:8px 15px 8px',
            autoHeight:   true,
            closeAction:  'close',
            shadow:       false,
            plain:        true,
            closable:     true,
            labelAlign:  'top',
            buttonAlign:  'right',
            items:        [{
                xtype: 'textarea',
                id : 'ta_licenses',
                fieldLabel: 'License domain(s)',
                allowBlank: false,
                anchor: '100%',
                name: 'msg',
                flex: 1  // Take up all *remaining* vertical space
            },new Ext.form.ComboBox({
               triggerAction: 'all',
               id : 'ta_licensetype',
               fieldLabel: 'Type Of License',
               lazyRender:true,
               editable:false,
               value: '0',
               width: 150,
               store: [[0,lang('Unlimited')],[1,lang('25 User License')]],
               mode:  'local'
            })
            ] ,
            buttons: [{
                text: 'Submit',
                handler: function() {

                if (trim(Ext.getCmp('ta_licenses').getValue()) == "") {
                            Ext.MessageBox.alert("Error Validating","You must enter licenses in the license field");
                            return false;
                        }

                    Ext.Ajax.request({
                        url: 'index.php?fuse=home&action=DoSnapinPluginAction',
                        success: function(xhr) {
                            ce.parseAjaxResponse(xhr);
                            licensedefender.addLicenseWindow.close();
                            licensedefender.gridstore.load({params:{start:0,limit:10}});
                        },
                        params: {
                            plugin: 'licensedefender',
                            pluginAction : 'addLicense',
                            licenses: Ext.getCmp('ta_licenses').getValue(),
                            type: Ext.getCmp('ta_licensetype').getValue(),
                            loginas: licensedefender.loggedinas
                        }
                    });

                }
            },{
                text: 'Cancel',
                handler : function() {
                    licensedefender.addLicenseWindow.close();
                }
            }]

    });
    licensedefender.addLicenseWindow.show();
    licensedefender.addLicenseWindow.setTitle(Ext.getCmp('gridadddomainbtn').getText())

}

licensedefender.viewEditLicense = function(license,type,resellerid,x,y)
{
    licensedefender.oldDomain = license;
    licensedefender.editresellerid = resellerid;
    licensedefender.editLicenseWindow = new Ext.Window({
            layout:       'form',
            width:        350,
            modal:        true,
            x: x,
            y: y - 70,
            bodyStyle:    'padding:8px 15px 8px',
            autoHeight:   true,
            closeAction:  'close',
            shadow:       false,
            plain:        true,
            title:        'Edit license for: '+ license,
            closable:     true,
            labelAlign:  'top',
            buttonAlign:  'right',
            items:        [{
                xtype: 'textfield',
                id : 'ta_editlicense',
                allowBlank: false,
                fieldLabel: 'License',
                anchor: '100%',
                value: license,
                name: 'msg',
                flex: 1  // Take up all *remaining* vertical space
            },new Ext.form.ComboBox({
               triggerAction: 'all',
               id : 'ta_editlicensetype',
               fieldLabel: 'Type Of License',
               lazyRender:true,
               editable:false,
               value: type,
               width: 150,
               store: [[0,lang('Unlimited')],[1,lang('25 User License')]],
               mode:  'local'
            })
            ] ,
            buttons: [{
                text: 'Update',
                handler: function() {

                    if (trim(Ext.getCmp('ta_editlicense').getValue()) == "") {
                            Ext.MessageBox.alert("Error Validating","You must enter licenses in the license field");
                            return false;
                        }

                    Ext.Ajax.request({
                        url: 'index.php?fuse=home&action=DoSnapinPluginAction',
                        success: function(xhr) {
                            ce.parseAjaxResponse(xhr);
                            licensedefender.editLicenseWindow.close();
                            licensedefender.gridstore.load({params:{start:0,limit:10}});
                        },
                        params: {
                            plugin: 'licensedefender',
                            pluginAction : 'updateLicense',
                            newdomain: Ext.getCmp('ta_editlicense').getValue(),
                            olddomain: licensedefender.oldDomain,
                            type: Ext.getCmp('ta_editlicensetype').getValue(),
                            loginas: licensedefender.loggedinas,
                            resellerid: licensedefender.editresellerid
                        }
                    });
                }
            },{
                text: 'Cancel',
                handler : function() {
                    licensedefender.editLicenseWindow.close();
                }
            }]

    });
    licensedefender.editLicenseWindow.show();

}