﻿// JScript File

var loginName;
var tabMain;
var checklogin = true;
var titleLogin = 'Login';
var SumPrice;
var tbar;
var ThemeID;
function validateResponse(xhttp)
{
	if(xhttp.status != 200)
	{
		throw "Some error occured while receiving data from server. Please try again";
	}
}
var treeProductAndService = new Ext.tree.TreePanel({
    xtype: 'treepanel',				
    split:true,
    autoHeight:true,
    viewConfig: {
        forceFit: true
    }
});
var treeSemina = new Ext.tree.TreePanel({
    xtype: 'treepanel',				
    split:true,
    autoHeight:true,
    viewConfig: {
        forceFit: true
    }
});
  var tools = [{
        id:'gear',
        handler: function(){
            Ext.Msg.alert('Message', 'The Settings tool was clicked.');
        }
    },{
        id:'close',
        handler: function(e, target, panel){
            panel.ownerCt.remove(panel, true);
        }
    }];
 var Tabsouth = new Ext.TabPanel({
              border:true,
              activeTab:0,  //set focut to tab 0 is Business
              tabPosition:'top',
              items:[{
                    title: 'Business',
                    contentEl: 'Business',
                    //xtype: 'registeredAddressesPanel',
                    height: 128
              }/*,{
                    title: 'Timeline',
                    contentEl: 'Timeline',
                    autoScroll:true
                    //xtype:'myinformation'
              }*/]
});
this.southTool=[Tabsouth];

function LoadEXT(){
       
       Ext.QuickTips.init();
       switchTheme(ThemeID);
       
       // turn on validation errors beside the field globally
       Ext.form.Field.prototype.msgTarget = 'side';
       Ext.state.Manager.setProvider(new Ext.state.CookieProvider());       
       //CreateProductAndService("../ConnectServer/Server.aspx?Command=ProductAndService");
       //CreateSemina("../ConnectServer/Server.aspx?Command=Semina");
       CreateTBar();
      
       var viewport = new Ext.Viewport({
            layout:'border',
            items:[
                {
                    region:'north', 
                    id:'north-panel',                   
                    //title:'News',
                    //iconCls: 'iapps',
                    split:true,
                    height : 60,
                    minSize: 60,
                    maxSize: 60,
                    html: '<iframe id="test" src="../Header/Header.aspx" width="100%" height="100%" scrolling="no" frameborder="0"></iframe>',
                    collapsible: true,
                    margins:'0 0 0 0',
                    layoutConfig:{
                        animate:true
                    },
                    layout:'accordion'
                 },
                 {
                    region:'east',
                    id:'east-panel',                     
                    title:'Shoping Cart', 
                    iconCls: 'shoppingcar2',                  
                    split:true,
                    width : 400,
                    minSize: 150,
                    maxSize: 400,
                    collapsible: true,
                    margins:'0 0 0 0',
                    layoutConfig:{
                        animate:true
                    },                    
                    layout:'fit',
                    items:
                        new Ext.TabPanel({
                            border:false,     
                            activeTab:0,  
                            deferredRender:false,
                            autoTabs:true,                            
                            tabPosition:'bottom',
                            
                            items:[{
                                    html: '<iframe id="test" src="../catalog/ShoppingCart.aspx" width="100%" height="100%" scrolling="no" frameborder="0"></iframe>',
                                    title: 'Product',
                                    autoScroll:true,
                                    tbar: [                       
                                       {                   // <-- Add the action directly to a toolbar
                                            text: 'Apply',
                                            iconCls: 'apply'                                                
                                       }]
                            },
                            {
                                html:'<p>A TabPanel component can be a region.</p>',
                                title: 'Service',                              
                                autoScroll:true
                            }]
                        })  
                 },
                   {
                    region:'south',
                    id:'south-panel',                   
                    title:'Status',
                    collapsible: true,
                    //iconCls: 'iapps',
                    split:true,
                    height : 150,
                    minSize: 150,
                    maxSize: 300,
                    collapsible: true,
                    margins:'0 0 0 0',
                    layoutConfig:{
                        animate:true
                    },
                    items: this.southTool,
                    layout:'accordion'
                 },
                {
                    region:'west',                   
                    id:'west-panel',
                    title: 'Nextw@ver.net',
                    iconCls:'iapps',
                    collapsible: true,
                    split:true,
                    width: 225,
                    minSize: 175,
                    maxSize: 400,
                    layout:'fit',
                    margins:'0 0 0 0', 
                    items:[
                    tabMain =  new Ext.TabPanel({
                            border:false,
                            activeTab:0,  
                            deferredRender:false,
                            autoTabs:true,                                           
                            tabPosition:'bottom',                            
                            items:[
                            {                               
                                title: 'Main Menu',
                                autoScroll:true,
                                layout:'accordion',
                                items:this.menuTool
                            }
                            ,{                               
                                title: 'Management Menu',
                                autoScroll:true,
                                collapsible: true, 
                                layout:'accordion',
                                items:this.westTool
                            }
                            ]
                        })]
                 },
                 {
                    region:'center', 
                    id:'center-panel',
                    tbar: tbar,
                    split:true,
                    height : 60,
                    minSize: 60,
                    maxSize: 60,                 
                    margins:'0 0 0 0',                    
                    layout:'fit',
                    items:[  new Ext.TabPanel({
                                region:'center',
                                id:'tabinfomation',
                                deferredRender:false,
                                enableTabScroll:true, 
                                plugins: new Ext.ux.TabCloseMenu(),
                                activeTab:0,                   
                                autoTabs:true,                           
                                items:
                                [{
                                    contentEl:'centermain',
                                    title: '&nbsp;&nbsp;&nbsp;ข่าวประชาสัมพันธ์',
                                    iconCls:'news',
                                    html: '<iframe id="test" src="../news/showNews.aspx" width="100%" height="100%"  frameborder="0"></iframe>',
                                    autoScroll:true
                                }]
                            })]
                 }
             ]
        }); 

        //var w = Ext.getCmp('west-panel'); w.expand()        
        //var n = Ext.getCmp('north-panel'); n.collapse()
        var e = Ext.getCmp('east-panel'); e.collapse()
        var s = Ext.getCmp('south-panel'); s.collapse()                 
        
}
