<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GigaTech.CMS.Web.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="refresh" content="600" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title></title>
   
        <style type="text/css">
            
            html {
background: url(/Common/DMZ/Images/Other/bg2.jpg) no-repeat center center fixed; 

-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

}

            
        .loginForm
        {
            width: 300px;
            border: 0px solid #444;
            box-shadow: 15px 20px 20px #666;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-top: -100px;
            margin-left: -150px;
        }
        
        .div_right_bottom {
            float:right;
            position:fixed;
            right:5px;
            bottom:5px;
            z-index:20;
            _position:absolute; /* position fixed for IE6 */
        }
        </style>
</head>
        <script language="javascript">


            function fnLogin() {
                var frmLogin = Ext.getCmp('login_form').getForm();
                if (frmLogin.isValid()) {
                    frmLogin.submit({
                        url: '/Common/DMZ/Login.ashx',
                        waitMsg: '<%=GetGlobalResourceObject("CMSResource", "IdentCheck")%>',
                        success: function (form, action) {
                            location.href = action.result.redirect.url;
                        },
                        failure: function (form, action) {
                            if (action.failureType === Ext.form.action.Action.CONNECT_FAILURE) {
                                Ext.Msg.alert('<%=GetGlobalResourceObject("CMSResource", "Error")%>',
                                    'Status:' + action.response.status + ': ' +
                                        action.response.statusText);
                            }
                            if (action.failureType === Ext.form.action.Action.SERVER_INVALID) {
                                Ext.Msg.alert('<%=GetGlobalResourceObject("CMSResource", "Error")%>', action.result.errors.reason);
                            }
                        }
                    });
                }
            }

            Ext.onReady(function() {
                Ext.QuickTips.init();

                Ext.create('Ext.form.Panel', {
                    id: 'login_form',
                    renderTo: 'login',
                    standardSubmit: false,
                    title: '<%=SystemTitle %>',
                    bodyStyle: 'padding:5px 5px 0',
                    padding: '0 0 0 0',
                    fieldDefaults: {
                        labelAlign: 'left',
                        msgTarget: 'side'
                    },
                    defaults: {
                        border: false,
                        xtype: 'panel',
                        flex: 1,
                        layout: 'anchor'
                    },
                    layout: 'anchor',
                    items: [{
                        xtype: 'textfield',
                        name: 'loginUserID',
                        id: 'loginUserID',
                        fieldLabel: '<%= GetGlobalResourceObject("CMSResource", "ID")%>', 
                        labelWidth:40,
                        anchor: '100%',
                        allowBlank: false,
                        vtype: 'alphanum'
                    }, {
                        xtype: 'textfield',
                        name: 'loginPassword',
                        id: 'loginPassword',
                        fieldLabel: '<%= GetGlobalResourceObject("CMSResource", "PWD")%>',  
                        labelWidth:40,
                        inputType: 'password',
                        anchor: '100%',
                        value: '',
                        allowBlank: false,
                        vtype: 'alphanum'
                    }, {
                        xtype: 'hiddenfield',
                        name: 'checkCode',
                        value: '<%=(EnableCaptch?"1":"0") %>'
                    }, {
                        xtype: 'textfield',
                        fieldLabel: '<%=GetGlobalResourceObject("CMSResource", "Captcha")%>',                                             
                        name: 'captcha',
                        anchor: '100%',
                        hidden: !<%=EnableCaptch.ToString().ToLower() %>,
                        allowBlank: !<%=EnableCaptch.ToString().ToLower() %>
                    }, {
                        xtype: 'fieldcontainer',
                        fieldLabel: '&nbsp;',
                        labelSeparator: '',
                        anchor: '100%',
                        hidden: !<%=EnableCaptch.ToString().ToLower() %>,
                        layout: {
                            type: 'hbox',
                            align: 'right'
                        },
                        items: [
                            {
                                xtype: 'image',
                                height: 32,
                                width: 90,
                                id: 'captcha',
                                src: '/Common/DMZ/Captcha.ashx?id=' + Math.random()
                            }, {
                                xtype: 'displayfield',
                                value: '&nbsp;'
                            }, {
                                xtype: 'button',
                                icon: '/Common/DMZ/Images/24x24/reload.png',
                                scale: 'medium',
                                tooltip: '<%=GetGlobalResourceObject("CMSResource", "ReGenCheckCode")%>',
                                handler: function() {
                                    Ext.getCmp("captcha").setSrc('/Common/DMZ/Captcha.ashx?id=' + Math.random());
                                }
                            }
                        ]
                    }
                    ,
                        Ext.create('Ext.form.ComboBox', {
                            fieldLabel: '<%=GetGlobalResourceObject("CMSResource", "Language")%>',
                            hidden:true,
                            name: 'language',
                            editable: false,
                            anchor: '100%',
                            store: Ext.create('Ext.data.Store', {
                                fields: ['abbr', 'name'],
                                data: [
                                    { "abbr": "zh_tw", "name": "繁體" },
                                    { "abbr": "zh_cn", "name": "简体" },
                                    { "abbr": "en", "name": "English" }
                                ]
                            }),
                            queryMode: 'local',
                            displayField: 'name',
                            valueField: 'abbr',
                            value: 'zh_tw'
                        })
                    ],
                    listeners: {
                        afterRender: function(thisForm, options) {
                            this.keyNav = Ext.create('Ext.util.KeyNav', this.el, {
                                enter: fnLogin,
                                scope: this
                            });
                        }
                    },
                    buttons: [{
                        text: '<%=GetGlobalResourceObject("CMSResource", "ForgotPWD")%>',
                        icon: '/Common/DMZ/Images/16x16/question.png',
                        hidden:true,
                        handler: function() {
                            var w = Ext.create('Ext.window.Window', {
                                title: '<%=GetGlobalResourceObject("CMSResource", "ForgotPWD")%>',
                                layout: 'fit',
                                modal: true,
                                constrain: true,
                                 shadow: true,
            shadowOffset: 50,
                                resizable: false,
                                width: 260,
                                items: {
                                    xtype: 'form',
                                    border: false,
                                    url: '/Common/DMZ/PWDProcess.ashx?action=GetPWD',
                                    bodyPadding: 5,
                                    layout: 'anchor',
                                    defaults: {
                                        anchor: '100%',
                                        labelWidth: 70
                                    },
                                    defaultType: 'textfield',
                                    items: [{
                                        fieldLabel: '<%=GetGlobalResourceObject("CMSResource", "ResidentNo")%>',
                                        name: 'Idno',
                                        allowBlank: false
                                    }, {
                                        xtype: 'displayfield',
                                        fieldLabel: '',
                                        value: '<font color=red>※ <%=GetGlobalResourceObject("CMSResource", "SystemSendPWD2Device")%> ※</font>'
                                    }],
                                    buttons: [
                                        {
                                            text: '<%=GetGlobalResourceObject("CMSResource", "OK")%>',
                                            formBind: true,
                                            handler: function() {
                                                var form = this.up('form').getForm();
                                                if (form.isValid()) {
                                                    form.submit({
                                                        success: function(f, action) {
                                                            w.close();
                                                            alert("<%=GetGlobalResourceObject("CMSResource", "PWDSent2Device")%>");
                                                        },
                                                        failure: function(f, action) {
                                                            alert("<%=GetGlobalResourceObject("CMSResource", "IDNotCorrect")%>");
                                                        }
                                                    });
                                                }
                                            }
                                        },
                                        {
                                            text: '<%=GetGlobalResourceObject("CMSResource", "Cancel")%>',
                                            handler: function() {
                                                this.up("window").close();
                                            }
                                        }
                                    ]
                                }
                            }).show();

                        }
                    }, '->', {
                        text: '<%=GetGlobalResourceObject("CMSResource", "Login")%>',
                        icon: '/Common/DMZ/Images/16x16/login.png',
                        formBind: true,
                        id: 'login_submit',
                        handler: function() {
                            fnLogin();
                        }
                    }
                    ]
                });
                
                Ext.getCmp('loginUserID').focus(false, 200);    
            });
        </script>
<body onload="if (parent.frames.length != 0) top.location = '/';" >
    <form id="form1" runat="server">
    <div id="login" class="loginForm"></div>
    <div id="Div1" class="div_right_bottom"><%=GetGlobalResourceObject("CMSResource", "BestView")%></div>
    </form>
</body>
</html>
