﻿Ext.onReady(function() {
	Ext.BLANK_IMAGE_URL = '../js/ext-2.2/resources/images/default/s.gif';
Ext.util.CSS.swapStyleSheet("theme","../js/ext-2.2/resources/css/xtheme-midnight.css");
	Ext.QuickTips.init();// 
	Ext.form.Field.prototype.msgTarget = 'side';// 
	var viewport = new Ext.Viewport({
		layout : 'border',
		items : [{
			region : 'north',
			contentEl : 'north-div',
			border : false,
			collapsible : true,
			height : 43
		}, {
			region : 'south',
			contentEl : 'south-div',
			border : false,
			collapsible : true,
			height : 25
		}, {
			region : 'center',
			contentEl : 'center-div',
			border : false,
			collapsible : true
		}]
	});

	var simple = new Ext.form.FormPanel({
		labelAlign : 'right',
		method : 'POST',
		region : 'center',// 
		frame : true,
		// iconCls : 'icon_users',
		title : '<div align=center>SYSTEM LOGIN<div>',
		width : 350,
		items : [{
			xtype : 'fieldset',
			title : 'Login Infomation',
			autoHeight : true,
			width : 338,
			items : [{
				layout : 'column',
				border : false,
				defaults : {
					border : false
				},
				items : [{
					columnWidth : 1.0,
					layout : 'form',
					items : [{
						fieldLabel : 'Login ID',
						id : 'loginid',
						allowBlank : false,
						width : 80,
						xtype : 'textfield',
						anchor : '90%'
					}]
				}, {
					columnWidth : 1.0,
					layout : 'form',
					items : [{
						fieldLabel : 'Password',
						allowBlank : false,
						width : 80,
						xtype : 'textfield',
						anchor : '90%',
						id : 'loginpassword',
						inputType : 'password'
					}]
				}, {
					columnWidth : 1.0,
					layout : 'form',
					defaultType : 'textfield',
					defaults : {
						width : 80
					},
					items : [{
						xtype : 'combo',
						store : new Ext.data.SimpleStore({
							fields : ["retrunValue", "displayText"],
							data : [['en', 'English'], ['sa', 'Arabic']]
						}),
						valueField : "retrunValue",
						displayField : "displayText",
						mode : 'local',
						forceSelection : true,
						blankText : 'Please select the language.',
						emptyText : 'Please select the language.',
						id : 'languageid_1',
						hiddenName : 'language_1',
						editable : false,
						triggerAction : 'all',
						allowBlank : false,
						fieldLabel : 'Language',
						name : 'language_1',
						anchor : '90%'
					}, {
						xtype : 'hidden',
						id : 'source',
						value : 'en'
					}]
				}]
			}]
		}, {
			xtype : 'fieldset',
			title : 'Contact US',
			autoHeight : true,
			width : 338,
			items : [{
				layout : 'column',
				border : false,
				defaults : {
					border : false
				},
				items : [{
					columnWidth : 1.0,
					layout : 'form',
					defaultType : 'label',
					items : [{
						id : 'fname',
						html : '<b>Tel :</b> +966 (01) 2915648<br> +966 (01) 2069547<br><b>Fax: </b> +966 (01) 2916303 EXT 108<br><b>Unified No :</b> 920022256<br><b>MSN :</b> Tkamulgps@hotmail.com'
					
					}]
				}]
			}]
		}],
		buttons : [{
			text : 'Login',
			type : 'button',
			id : 'login',
			handler : function() {
				simple.form.doAction('submit', {
					url : serverContextPath + '/lgnsvr.servlet?action=login',
					method : 'post',
					success : function(form, action) {
						// Ext.Msg.alert('Success', action.result.data);
						window.location = action.result.data;
					},
					failure : function() {

						Ext.Msg
								.alert('Error',
										'Login failed.Please check your login Infomation');
						// this.disabled=false;
					}
				});
			}
		}, {
			text : 'Reset',
			type : 'reset',
			id : 'clear',
			handler : function() {
				simple.form.reset();
			}
		},{
			text : 'Help',
			type : 'button',
			id : 'help',
			handler : function() {
				window.location = '../tk_help/help_en_090531.htm';
			}
		}]
	});

	simple.render("logindiv");

});