var setupWinCnt = 0;
var setupWin = '';
function iceCapSetup(scn) {
  Ext.Ajax.request({
    url: '/icemnu/iceCapSet.aspx?tabid=scn.tabid&panelToken=' + scn.panelToken + '&configXML=' + iceCap.session.configXML + '&emulatorXML=' + iceCap.session.emulatorXML
    ,method: 'POST'
    ,success: function(result) {
      eval("var scn = "+result.responseText); // materialize the JSON object;
      
      var iCnt=0;
      var items=new Array();
      
      if (scn.fields) {
        // build fields (advanced (form) layout)
        for(fx in scn.fields) {
          var fld=scn.fields[fx];
          switch(fld.type)
          {
            case 'undefined':
              break;
            case 'input':
              //items[iCnt++] = iceCapSetupInputField(fld);
              break;
            case 'output':
              //items[iCnt++] = iceCapSetupOutputField(fld);
              break;
            case 'label':
              //items[iCnt++] = iceCapSetupLabelField(fld);
              break;
            case 'grid':
              items[iCnt++] = iceCapSetupGrid(fld);
              break;
            default:
              break;
          }
        }
      }      
      
      var frm = new Ext.form.FormPanel({
        hideLabels:true
        ,autoWidth:true
        ,autoHeight:true
        ,border:false
        ,layout:'form'
        ,items:items
      });
      
      var windowID = 'setup-window-' + setupWinCnt++;
      if (!setupWin) {      
        setupWin = new Ext.Window({
          id: windowID
          ,title: 'Setup'
          ,width:600
          ,height:550
          ,layout: 'form'
          ,plain:true
          ,autoScroll : true
          ,items: frm
          ,buttons: [
            {
              text:'Save'
              ,handler: function() {
              }
            },{
              text:'Close window'
              ,handler: function() {
                setupWin.hide();
              }
            }
          ]
        });
      }
      setupWin.show(); 
    }
  })
}

/** -----------------------------------------------------------------
* iceCap Setup inputfield
*/

function iceCapSetupInputField(fld) {
}
function iceCapSetupOutputField(fld) {
}
function iceCapSetupLabelField(fld) {
}
function iceCapSetupGrid(fld) {
}