	//Ext.BLANK_IMAGE_URL='../images/pic/blank.gif';這個改變了預設的圖片,造成下拉圖片不能出來
	var login = function(){
		Ext.QuickTips.init();
		Ext.lib.Ajax.defaultPostHeader += ";charset=utf-8";
		Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	};

	
	Ext.onReady(function(){
		Ext.QuickTips.init();
        var usernoField = new Ext.form.TextField({
			fieldLabel:'帳號',
			name:'userno',
			id:'userno'
		});


		var login_form=new Ext.form.FormPanel({
			defaultType:'textfield',
			layout:'form',
			labelAlign:'right',
			labelWidth:55,			
			region:'center',
			waitMsgTarget:true,
			defaults:{border:false,allowBlank:false,blankText:'該字段不允許為空白',msgTarget:'qtip',autoScroll:true,selectOnFocus:true},
			style:'background:transparent;padding:95px 125px 85px 60px;', //留白上右下左
			items:[
			usernoField,
	//		{fieldLabel:'帳號',name:'userno',id:'userno',selectOnFocus:true},
	//		 regex:/^[a-zA-z]{2,20}$/,regexText:'只能為2~20位的大小寫字母'},
			{fieldLabel:'密碼',inputType:'password',name:'pwd',id:'pwd',
			 regex:/^.{3,}$/,regexText:'長度不能少於3位'}
			],
			buttonAlign:'center',
                        keys: [
				{ key: [Ext.EventObject.ENTER], handler: function() {
					Ext.getCmp('sendLogin').handler.call(Ext.getCmp('sendLogin').scope);
				}
				}],
			buttons:[{text:'登錄',	 id:'sendLogin',name:'sendLogin',
						handler: function(){
							login_form.getForm().submit({
								waitMsg:'資料處理中,請稍候!!',	
								url: 'login.php',
								delay:5000,
								success: function(f,a){
									if (window.location.hostname == 'localhost') {
										window.location.href = window.location.protocol + "//" + window.location.hostname + "/" + "exercise/abs4111.html";
									}
									else {
										window.location.href = window.location.protocol + "//" + window.location.hostname + "/" + "efashion/menu/index.html";
									}
									},
								failure: function(f, a){
										Ext.MessageBox.show({
								           title:'登入失敗!!',
								           msg: a.result.error_msg,
								           buttons: Ext.MessageBox.OK,
								           icon: Ext.MessageBox.ERROR
								       	});
										login_form.findById(a.result.id).focus();//目前本句無效,想指回欄位,但目前指不回去						
								}
								});}
								
								},
					{text:'取消',
						handler: function(){
							login_form.getForm().reset();
						}}]
			});					
		var panel=new Ext.Panel({
			renderTo:'loginpanel',
			layout:'border',
			width:553,
			height:340,
			defaults:{border:false},
			items:[
			{region:'north',height:16},
			{region:'south',height:16},			
			{region:'west',width:100},
			{region:'center',html:'<img src="../images/pic/login.png"/>'},	
			login_form
			]
			});

		Ext.get('loginpanel').setStyle('position', 'absolute').center(Ext.getBody());
		usernoField.focus.defer(100, usernoField);
	});

