﻿/*
广告联盟-首页
*/
indexPage = WEBClass.create();
indexPage.prototype = {
    initialize: function() {
        this.btn = $('#btnlogin');
    },
    //初始化绑定事件
    init_event: function(page_obj) {
        page_obj.btn.click(function() {
            return page_obj.infoCheck();
        });
    },
    //验证表单
    infoCheck: function() {

        //        //暂不开通会员功能***************************************************************
                //this.showMsg("系统正在升级，请稍后再试!", $('#username'));
               //return false;
        //        //暂不开通会员功能***************************************************************

        var result = this.checkuserid($.trim($('#username').val()));
        if (result != true) { this.showMsg(result, $('#username')); return false; }

        result = this.checkPsw($.trim($('#pwd').val()));
        if (result != true) { this.showMsg(result, $('#pwd')); return false; }

        result = this.checkCode($.trim($('#checkcode').val()));
        if (result != true) { this.showMsg(result, $('#checkcode')); return false; }

        result = this.checkType($('#usertype').val());
        if (result != true) { this.showMsg(result, $('#usertype')); return false; }

        return true;
    },
    //验证用户名
    checkuserid: function(userid) {
        if (userid.length == 0) {
            return ("用户名不能为空！");
        }
        if (validate.isBadChar(userid)) {
            return ("您输入的用户名中含有非法字符!");
        }
        return true;
    },
    //验证密码
    checkPsw: function(Psw) {
        if (Psw.length == 0) {
            return ("密码不能为空！");
        }
        if (validate.isBadChar(Psw)) {
            return ("您输入的密码中含有非法字符!");
        }
        return true;
    },
    //验证用户类型
    checkType: function(type) {
        if ($('#lts1 input:checked[type="radio"][name^="type"]').length == 0) {
            return ("请选择用户类型");
        }
        return true;
    },
    //验证验证码
    checkCode: function(code) {
        if (code.length == 0) {
            return ("验证码不能为空！");
        }
        if (code.length < 5) {
            return ("验证码不规范！");
        }
        if (validate.isBadChar(code)) {
            return ("您输入的验证码中含有非法字符!");
        }
        return true;
    },
    //退出登录
    LoginOut: function() {
        if (!confirm("您确定退出?"))
            return;
        $.ajax({
            type: "post",
            url: "LogOutAjax.aspx",
            cache: false,
            async: true,
            data: { "action": "loginout" },
            success: function(msg) {
                if (msg.length == 0) {
                    parent.window.location.href = "index.aspx";
                }
                else {
                    alert(msg);
                }
            },
            error: function() {
                alert("请求超时！");
            }
        });
    },
    //显示错误信息
    showMsg: function(Msg, control) {
        $(control).focus();
        alert(Msg)
    }
}





window.onload = function() {
    var st = new SlideTrans("bannerBox", "slider", 3, { Vertical: false });

    var nums = [];
    //插入数字
    for (var i = 0, n = st._count - 1; i <= n; ) {
        (nums[i] = $$("idNum").appendChild(document.createElement("i"))).innerHTML = ++i;
    }

    forEach(nums, function(o, i) {
        o.onmouseover = function() { o.className = "on"; st.Auto = false; st.Run(i); }
        o.onmouseout = function() { o.className = ""; st.Auto = true; st.Run(); }
    })
    //设置按钮样式
    st.onStart = function() {
        forEach(nums, function(o, i) { o.className = st.Index == i ? "on" : ""; })
    }
    st.Run();
}
