Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = "side";

    var bd = Ext.getBody();

    /*
     * ================  Simple form  =======================
     */
    //bd.createChild({tag: "h2", html: "Form 1 - Very Simple"});


    var simple = new Ext.FormPanel({
        labelWidth: 75, // label settings here cascade unless overridden
        style:"text-align:center",
        url:"",
        frame:true,
        title: "TMElearning企业在线培训系统",
        bodyStyle:"padding:5px 5px 0",
        width: 350,
		timeout : '9000000',
        defaults: {width: 230},
        defaultType: "textfield",
		
        items: [{
                fieldLabel: "用户名",
                name: "loginName",
                id: "loginName",
                value:"",
                allowBlank:false
            },{
                fieldLabel: "密&nbsp;&nbsp;&nbsp;码",                
                name: "password",
                id: "password",
                value:"",
                inputType:"password",
                allowBlank:false
            }
        ],

        buttons: [{
            text: "登陆",
            name:'submit',
            id:'submit',
            handler: function(){
            	setCookie();
            	if(!simple.form.isValid()){
            		return;
            	}
            	
    			if(Ext.get("password").dom.value.length < 1){
    				Ext.MessageBox.alert("提示信息","密码不能小于5个字符");
    			}else{
    				simple.form.doAction('submit',{
			            url:'/login.do?act=login',
			            params:'loginName='+Ext.get("loginName").dom.value+'&password='+Ext.get("password").dom.value,
			            method:'post',
			            waitTitle:'提示信息',
			            waitMsg:'登陆系统中',
			            success: function(form,action){
						
			           
				            if(action.result === true || action.result.success){
				            	location.href='/index.jsp';
				            	return;
				            }else{
				            	Ext.Msg.alert('提示信息',action.result.info);
				            }
				            
			            }			        
			            ,
			            failure:function(form,action){
			            	//Ext.Msg.alert('提示信息','用户名或密码错误！');
			            	Ext.Msg.alert(action.result.info);
			            }});
    			}
    			
            }
        },{
            text: "取消",
            name:'cancel',
            handler: function(){
            	
            	Ext.get("loginName").dom.value="";
    			Ext.get("password").dom.value="";
    			
    			
            }
        }]
    });

    simple.render("ext-form");
  
    
    
    
    });
    
    
   
    
/**
 * 退出
 */
    
/*
Ext.onReady(function(){
    
        Ext.BLANK_IMAGE_URL='../Libs/Js/resources/images/default/s.gif';
    
        setTimeout(function(){
        Ext.get('loading').remove();
        Ext.get('loading-mask').fadeOut({remove:true});
    }, 250);
    
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget='side';

    var lfm = new Ext.FormPanel({
        labelAlign:'left',
        labelWidth:80,
        frame:true,
        buttonAlign:'left',
        title: '润际科技CRM管理系统',
        bodyStyle:'padding:5px;',
        width:400,
        items: [{
            layout:'form',
            border:false,
            labelSeparator:'：',
            items:[{
                xtype:'textfield',
                fieldLabel:'帐号',
                name: 'username',
                allowBlank:false,
                anchor:'70%'
                }]
            },{
            layout:'form',
            border:false,
            labelSeparator:'：',
            items:[{
                xtype:'textfield',
                fieldLabel:'密码',
                name: 'password',
                inputType:'password',
                anchor:'70%',
                allowBlank:false
                }]
            },{
            layout:'column',
            border:false,
            items:[{
                layout:'form',
                columnWidth:.8,
                border:false,
                labelSeparator:'：',
                items:[{
                xtype:'textfield',
                fieldLabel:'验证码',
                name: 'code',
                anchor:'88%',
                allowBlank:false,
                maxLength:4
                }]
                },{
                layout:'form',
                columnWidth:.2,
                border:false,
                items:[{
                xtype:'panel',
                hideLabel:true,
                name: 'codepanel',
                html:'<img src="?action=code" />'
                }]
                }]
            }],
        buttons: [{
            text:'登陆',
            name:'submit',
            style:'margin-left:42px;',
            handler: function(){
            if(lfm.form.isValid()){
            lfm.form.doAction('submit',{
            url:'?action=login',
            params:'',
            method:'post',
            waitTitle:'提示信息',
            waitMsg:'登陆系统中',
            success:function(form,action){
            if(action.result.data=='登陆成功'){
            window.location='?action=main';
            }else{
            Ext.Msg.alert('提示信息',action.result.data);
            }
            },
            failure:function(){
            Ext.Msg.alert('提示信息','操作失败，请联系系统管理员！');
            }
            });
            }
        }
        }]
    });

    lfm.render('inner');
});*/

//弹出公告详细
function showNotice(id) {
	var tId = "hid_"+id;
	//alert(Ext.get(tId).dom.value);
	var reflushFrame = Ext.get("divNotice");
	var win = new Ext.Window({
		width:"95%",
		height:"500px",
		title:"公告详细", 
		closeAction:"close", 
		plain:true, 
		layout:"fit", 
		closable:true, 
		maximizable:true, 
		collapsible:true, 
		resizable:false, 
		modal:true,
		autoHeight:true,
		items:[{html:Ext.get(tId).dom.value }]});
	win.show(reflushFrame);
	win.maximize();
}
