﻿/* <![CDATA[ */

(function () { var ie = !!(window.attachEvent && !window.opera); var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525); var fn = []; var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); }; var d = document; d.ready = function (f) { if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false); if (fn.push(f) > 1) return; if (ie) (function () { try { d.documentElement.doScroll('left'); run(); } catch (err) { setTimeout(arguments.callee, 0); } })(); else if (wk) var t = setInterval(function () { if (/^(loaded|complete)$/.test(d.readyState)) clearInterval(t), run(); }, 0); }; })();
//去除字符串两边的空格 
String.prototype.trim = function () {
    return this.replace(/(^\s+)|(\s+$)/g, "");
}
//检测字符串是否为空 
String.prototype.isEmpty = function () {
    return !(/.?[^\s　]+/.test(this));
}
//检测值是否介于某两个指定的值之间 
String.prototype.isBetween = function (val, min, max) {
    return isNaN(val) == false && val >= min && val <= max;
}
//获取最大值或最小值 
String.prototype.getBetweenVal = function (what) {
    var val = this.split(',');
    var min = val[0];
    var max = val[1] == null ? val[0] : val[1];
    if (parseInt(min) > parseInt(max)) {
        min = max;
        max = val[0];
    }
    return what == 'min' ? (isNaN(min) ? null : min) : (isNaN(max) ? null : max);
}
String.prototype.isChinese = function () {
    if (this == " ")
        return true;
    var pattern = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi;
    return (pattern.test(this));
}
String.prototype.ReplaceN = function () {
    var result = '';
    for (var i = 0; i < this.length; i++) {
        result += '*';
    }
    return result;
}

function $(element) {
    return document.getElementById(element);
}
var OSam = {
    isIE: (!!(window.attachEvent && !window.opera)),
    addFavorite: function () {  /* 将当前页面地址加入收藏夹 */
        var sUrl = document.location;
        var sTitle = document.title;
        try {
            window.external.addFavorite(sUrl, sTitle);
        } catch (e) {
            try {
                window.sidebar.addPanel(sTitle, sUrl, "");
            } catch (e) {
                alert('加入收藏夹失败，请使用 Ctrl+D 进行添加。');
            }
        }
    },
    showTime: function (obj) {  /* 显示日期时间 */
        var obj = $(obj);
        window.setInterval(function () { obj.innerHTML = '今天是：' + new Date().toLocaleString() + '&nbsp;&nbsp;星期' + '日一二三四五六'.charAt(new Date().getDay()); }, 1000);
    },
    after: function (obj) {
        var hour = (new Date()).getHours();
        var msg;
        if (hour < 6) { msg = "早些休息!"; }
        else if (hour < 8) { msg = "全新的一天!"; }
        else if (hour < 12) { msg = "早安!"; }
        else if (hour < 14) { msg = "中午好!"; }
        else if (hour < 18) { msg = "下午好!"; }
        else if (hour < 22) { msg = "晚上好!"; }
        else if (hour < 24) { msg = "该休息了，"; }
        $(obj).innerHTML = msg;
    },
    doClick: function (obj) {
        $(obj).style.display = ($(obj).style.display == '') ? 'none' : '';
    },
    setInputCss: function () {
        var list = document.getElementsByTagName('input');
        for (var i = 0; i < list.length; i++) {
            if (list[i].className != '') {
                continue;
            }
            var t = list[i].type;
            if (t == 'text' || t == 'textarea' || t == 'password') {
                list[i].className = 'Text';
                list[i].onfocus = function () { this.className = 'focus'; }
                list[i].onblur = function () { this.className = 'Text'; }
            }
            else if (t == 'submit' || t == 'button' || t == 'reset') {
                list[i].className = "Button";
                list[i].onmouseover = function () { this.className = 'ButtonOver'; }
                list[i].onmouseout = function () { this.className = 'Button'; }
            }
        }
        var areas = document.getElementsByTagName('textarea');
        for (var i = 0; i < areas.length; i++) {
            areas[i].className = 'Text';
            areas[i].onfocus = function () { this.className = 'focus'; }
            areas[i].onblur = function () { this.className = 'Text'; }
        }
    },
    Limit: function (obj, maxLength, tip) {
        $(tip).innerHTML = maxLength;
        var str = obj.value;
        for (var i = 0; i < str.length; i++) {
            var writeCount = (str[i].isChinese()) ? 1 : 2;
            if (i >= maxLength) {
                obj.value = str.substring(0, maxLength);
                break;
            }
            $(tip).innerHTML = maxLength - (i + 1);
        }
    },
    Filter: function (obj) {
        var str = obj.value;
        var re = phrase.keyWords.split('|');
        for (var i = 0; i < re.length; i++) {
            str = str.replace(re[i], re[i].ReplaceN());
        }
        obj.value = str;
    },
    setUserType: function (type) {
        document.write(phrase.userType[type]);
    },
    QueryString: function (item) {
        var sValue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
        var s = sValue ? sValue[1] : sValue;
        if (s != null) {
            return decodeURIComponent(s); ;
        }
        else {
            return s;
        }
    }
}

function spanBar(titleId, bodyId, over, topTag, bomTag) {
    this.f = 0;
    this.event = over || 'mouseover';
    this.titleid = titleId;
    this.bodyid = bodyId;
    this.topTag = topTag || 'a';
    this.bomTag = bomTag || 'div';
    var Tags, TagsCnt, flag, BClassName;

    this.load = function () {
        if (!$(this.titleid) || !$(this.bodyid)) {
            return false;
        }
        flag = this.f;
        BClassName = ['', 'Hidden', '', 'Selected'];
        Tags = $(this.titleid).getElementsByTagName(this.topTag);
        TagsCnt = $(this.bodyid).getElementsByTagName(this.bomTag);
        for (var i = 0; i < Tags.length; i++) {
            Tags[i].value = i;
            if (this.event != 'click') {
                Tags[i].onmouseover = function () { changeNav(this.value) };
            } else {
                Tags[i].onclick = function () { changeNav(this.value) };
            }
            TagsCnt[i].className = BClassName[1];
        }
        Tags[flag].className = BClassName[3];
        TagsCnt[flag].className = BClassName[0];
    }
    function changeNav(v) {
        Tags[flag].className = BClassName[2];
        TagsCnt[flag].className = BClassName[1];
        flag = v;
        Tags[v].className = BClassName[3];
        TagsCnt[v].className = BClassName[0];
    }
}

function progWindow(element, title, width, height, callBack) {
    var msg = $(element);
    var w = width || 400;
    var h = height || 280;
    var t = title || phrase.alertTitle;
    var pannel = document.createElement('DIV');
    document.body.appendChild(pannel);
    pannel.id = "progWindow";
    pannel.style.cssText = 'position:absolute;left:0px;top:0px;width:100%;height:' + Math.max(document.body.clientHeight, document.documentElement.clientHeight) + 'px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;';
    msg.style.cssText = 'display:;position:absolute;z-index:102;left:' + (document.documentElement.clientWidth - 400) / 2 + 'px;top:' + (document.documentElement.clientHeight - 300) / 2 + 'px;width:' + w + 'px;height:' + h + 'px;';
    var h2 = document.createElement('h2');
    msg.insertBefore(h2, msg.firstChild);
    h2.innerHTML = t;
    var a = document.createElement('a');
    a.title = 'Close';
    a.onclick = function () { progClose(); };
    h2.insertBefore(a, h2.firstChild);
    function progClose() {
        h2.removeChild(a);
        msg.removeChild(h2);
        document.body.removeChild(pannel);
        msg.style.display = 'none';
        if (callBack != null && typeof (callBack) == 'function') {
            callBack();
        }
    }
    h2.onmousedown = function () {
        var ev = window.event || arguments.callee.caller.arguments[0];
        var x = ev.layerX ? ev.layerX : ev.offsetX + 3;
        var y = ev.layerY ? ev.layerY : ev.offsetY + 3;
        if (!ev.pageX) { ev.pageX = ev.clientX; }
        if (!ev.pageY) { ev.pageY = ev.clientY; }
        var tx = ev.pageX - x;
        var ty = OSam.isIE ? (ev.pageY - y + document.documentElement.scrollTop) : (ev.pageY - y);
        OpointX = tx;
        OpointY = ty;
        if (h2.setCapture) {
            h2.setCapture();
        } else if (window.captureEvents) {
            window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
        }
        h2.onmousemove = function () {
            var a = window.event || arguments.callee.caller.arguments[0];
            if (!a.pageX) a.pageX = a.clientX;
            if (!a.pageY) a.pageY = a.clientY;
            var tx = a.pageX - x;
            var ty = OSam.isIE ? (a.pageY - y + document.documentElement.scrollTop) : (a.pageY - y);
            MoveX = OpointX - tx;
            MoveY = OpointY - ty;
            msg.style.left = parseInt(msg.style.left.substring(0, msg.style.left.length - 2)) - MoveX + 'px';
            msg.style.top = parseInt(msg.style.top.substring(0, msg.style.top.length - 2)) - MoveY + 'px';
            OpointX = tx;
            OpointY = ty;
            msg.style.filter = 'alpha(opacity=90)';

        };
        h2.onmouseup = function () {
            msg.style.filter = 'alpha(opacity=100)';
            if (this.releaseCapture) {
                h2.onmousemove = null;
                h2.onmouseup = null;
                this.releaseCapture();
            }
            else if (window.captureEvents) {
                window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
            }
        }
    }
}

function handlerAlert(content, url, title, height, width) {
    var h = height || 200;
    var w = width || 400;
    var t = title || phrase.alertTitle;
    var pannel = document.createElement('DIV');
    document.body.appendChild(pannel);
    pannel.style.cssText = 'position:absolute;left:0px;top:0px;width:100%;height:' + Math.max(document.body.clientHeight, document.documentElement.clientHeight) + 'px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:98;';

    var msg = document.createElement('DIV');
    msg.style.cssText = 'display:;position:absolute;z-index:99;left:' + (document.documentElement.clientWidth - w) / 2 + 'px;top:' + (document.documentElement.clientHeight - h) / 2 + 'px;width:' + w + 'px;height:' + h + 'px;';
    msg.className = 'FPannel';
    document.body.appendChild(msg);
    msg.innerHTML = '<h2 style="cursor:default;"><a title="关闭"></a>' + t + '</h2><div class="msgContent"><h3 class="Red">' + content + '</h3><div class="Gray">3秒钟后自动转向......</div></div>';
    var a = msg.getElementsByTagName('a')[0];
    a.onclick = function () { alertClose(); };
    if (url != null && url != 'undefined' && url != '') {
        setTimeout(function () { location.href = url; }, 3000);
    }
    function alertClose() {
        document.body.removeChild(pannel);
        document.body.removeChild(msg);
        if (url != null && url != 'undefined' && url != '') {
            location.href = url;
        }   
    }
}

var bannerAnimate = function (element, images) {
    var adNum = 0;
    this.element = element || null;
    this.images = images || null;
    this.setTransition = function () {
        if (document.all) {
            this.element.style.cssText = 'FILTER: revealTrans(duration=2,transition=20)';
            this.element.filters.revealTrans.Transition = Math.floor(Math.random() * 23); //设置图片切换
            this.element.filters.revealTrans.apply(); //应用图片切换
        }
    }
    this.playTransition = function () {
        if (document.all)
            this.element.filters.revealTrans.play() //播放图片
    }
    this.play = function () {
        if (adNum < this.images.length - 1) {
            adNum++;
        } else {
            adNum = 0;
        }
        

        var browser = navigator.appName
        var b_version = navigator.appVersion
        var version = b_version.split(";");
        var trim_Version = version[1].replace(/[ ]/g, "");
        if (browser == "Microsoft Internet Explorer" && trim_Version != "MSIE6.0") {
            this.setTransition();
            this.playTransition();
        }

        this.element.src = this.images[adNum];
        var self = this;
        setTimeout(function () { self.play(); }, 5000);
    }
}


var phrase = {
    "keyWords": "法轮功|大鸡巴|鸡巴|操你妈|操您妈",
    "alertTitle": "温馨提示：",
    "changePasswordSucceed": "密码修改成功!",
    "checkUserName": ["可以使用", "用户名已经存在!"],
    "verifyCodeError": ["验证码错误", ""],
    "registerCode": ["提交失败！", "恭喜您，注册成功！"],
    "loginCode": ["用户名或密码错误！", "登录成功！3秒钟后自动转向......"],
    "editData": "用户资料修改成功！",
    "deleteAlert": "确认要删除吗？",
    "noEmpty": "请输入内容！",
    "userType": ['<span class="Red">管理员</span>', '<span class="Gray">普通会员</span>', '<span class="Green">高级会员</span>']
};

/* ]]> */
