﻿//获取页面内容
function getReturn(Url)  //提交为aspx,aspx页面路径, 返回页面的值
{
    var xmlhttp;
    try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E) {
            //alert("请安装Microsofts XML parsers")
        }
    }

    if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
        xmlhttp = new XMLHttpRequest()
    }

    try {
        xmlhttp.open('GET', Url, false);
        xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
        xmlhttp.send(null);

        if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
            return xmlhttp.responseText;
        }
        else {
            return null;
        }
    }
    catch (e) {
        alert("你的浏览器不支持XMLHttpRequest对象, 请升级");
    }

    return null;
}

//公共ajax取数据
function pubajax(url, actionstr, divID) {
    var Action = actionstr;
    var options = {
        method: 'get',
        parameters: Action,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            if (returnvalue.indexOf("??") > -1)
                document.getElementById(divID).innerHTML = '';
            else
                document.getElementById(divID).innerHTML = returnvalue;
        }
    };

    if (url.indexOf("?") == -1) {
        url += '?no-cache=' + Math.random()
    };
    new Ajax.Request(url, options);
}


//公共ajax取数据
function pubPostajax(url, actionstr, divID) {
    document.getElementById(divID).innerHTML = "保存中...";
    var Action = actionstr;
    var options = {
        method: 'get',
        parameters: Action,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            if (returnvalue.indexOf("??") > -1)
                document.getElementById(divID).innerHTML = '保存失败';
            else
                document.getElementById(divID).innerHTML = returnvalue;
        }
    };
    if (url.indexOf("?") == -1) {
        url += '?no-cache=' + Math.random()
    };
    new Ajax.Request(url, options);
}


//判断是否为空
function isSpace(strMain) {
    var strComp = strMain
    try {
        if (strComp == "　" || strComp == "" || strComp == " " || strComp == null || strComp.length == 0 || typeof strMain == "undefined" || strMain == "undefined") {
            return true
        }
        else {
            return false
        }
    } catch (e) { return false }
}

//获得指定元素的位置
function getposition(obj) {

    var r = new Array();
    r['x'] = obj.offsetLeft;
    r['y'] = obj.offsetTop;
    while (obj = obj.offsetParent) {
        r['x'] += obj.offsetLeft;
        r['y'] += obj.offsetTop;
    }
    return r;
}


//----------------------------------------------------------------------窗口打开页面 开始---------------------------------------------------------------------------------
function $(id) { return document.getElementById(id); }

//关闭对话框
function closeDialog(needRefresh) {
    closeWindow();
    if (needRefresh) {
        var url = location.href;
        //if ((/\?/g).test(url))
       //     url = url.replace(/\?.*$/g, ("?" + Math.random()).replace(/\./g, ""));
       // else url += ("?" + Math.random()).replace(/\./g, "");
        if (parent.frames.length == 0) {
            location.href = url;
        } else {
            parent.location.href = parent.location.href
        }
    }
}

/// <summary>
/// 添加事件
/// </summary>
/// <param name="target">载体</param>
/// <param name="type">事件类型</param>
/// <param name="func">事件函数</param>
function addEventHandler(target, type, func) {
    if (target.addEventListener)
        target.addEventListener(type, func, false);
    else if (target.attachEvent)
        target.attachEvent("on" + type, func);
    else target["on" + type] = func;
}

/// <summary>
/// 移除事件
/// </summary>
/// <param name="target">载体</param>
/// <param name="type">事件类型</param>
/// <param name="func">事件函数</param>
function removeEventHandler(target, type, func) {
    if (target.removeEventListener)
        target.removeEventListener(type, func, false);
    else if (target.detachEvent)
        target.detachEvent("on" + type, func);
    else delete target["on" + type];
}

/// <summary>
/// 获得元素的绝对坐标
/// </summary>
/// <param name="element">HTML元素</param>
function absolutePoint(element) {
    var result = { x: element.offsetLeft, y: element.offsetTop };
    element = element.offsetParent;
    while (element) {
        result.x += element.offsetLeft;
        result.y += element.offsetTop;
        element = element.offsetParent;
    }
    return result;
}

/// <summary>
/// 调用脚本
/// </summary>
/// <param name="url">脚本地址</param>
/// <param name="loaded">载入后调用的方法</param>
/// <param name="loaded">异常后调用的方法</param>
/// <param name="charset">脚本字节编码</param>
function callScript(url, loaded, error, charset) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    if (typeof charset == "string") script.charset = charset;
    script.src = url;
    script.onreadystatechange = function() {
        switch (this.readyState) {
            case "complete":
            case "loaded":
                if (typeof loaded == "function") loaded();
                if (script.parentNode) script.parentNode.removeChild(script);
                break;
        }
    }
    script.onload = function() {
        if (typeof loaded == "function") loaded();
        if (script.parentNode) script.parentNode.removeChild(script);
    }
    script.onerror = function() {
        if (typeof error == "function") error();
        if (script.parentNode) script.parentNode.removeChild(script);
    }
    if (window.opera)
        document.getElementsByTagName("HEAD")[0].appendChild(script);
    else document.body.parentNode.appendChild(script);
}

function requestHttp(url, type, data, loaded, error) {
    if (typeof loaded != "function") return;
    var xmlhttp = typeof XMLHttpRequest == "undefined" ?
	    new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4)
            if (xmlhttp.status == 200)
            loaded(xmlhttp);
        else if (parseFloat(xmlhttp.status) > 300 && typeof error == "function")
            error(xmlhttp);
    }
    xmlhttp.open(typeof type == "string" ? type : "GET", url, true);
    if (typeof data == "string") {
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-Length", data.length);
    }
    xmlhttp.send(data);
}

/// <summary>
/// 获得HTML元素当前的样式
/// </summary>
/// <param name="element">HTML元素</param>
function currentStyle(element) {
    return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}

/// <summary>
/// 构造拖拽引擎
/// </summary>
/// <param name="target">拖拽元素</param>
/// <param name="drag">移动元素</param>
/// <parem name="bounds">拖拽范围 left: 左边界 right: 右边界 top: 上边界 bottom: 下边界 (-1 表示不限制)
function DragEngine(target, drag, bounds) {
    this.target = target;
    this.drag = typeof drag != "undefined" ? drag : traget;
    this.drag.style.position = "absolute";
    this.downPoint = {}; // 鼠标按下的坐标
    this.offset = {
        x: parseInt(currentStyle(this.drag).marginLeft) || 0,
        y: parseInt(currentStyle(this.drag).marginTop) || 0
    };
    this.bounds = typeof bounds != "undefined" ? bounds : { left: 0, top: 0, right: -1, bottom: -1 };
    var dragEngine = this;
    this.documentMousemove = function(e) {
        if (window.getSelection)
            getSelection().removeAllRanges();
        else if (document.selection && document.selection.empty)
            document.selection.empty();
        var left = e.clientX - dragEngine.downPoint.x + dragEngine.offset.x;
        var top = e.clientY - dragEngine.downPoint.y + dragEngine.offset.y;
        if (parseInt(dragEngine.bounds.right) >= 0)
            left = Math.min(left, dragEngine.bounds.right - dragEngine.drag.offsetWidth);
        if (parseInt(dragEngine.bounds.bottom) >= 0)
            top = Math.min(top, dragEngine.bounds.bottom - dragEngine.drag.offsetHeight);
        if (parseInt(dragEngine.bounds.left) >= 0)
            left = Math.max(left, dragEngine.bounds.left);
        if (parseInt(dragEngine.bounds.top) >= 0)
            top = Math.max(top, dragEngine.bounds.top);
        dragEngine.drag.style.left = left + "px";
        dragEngine.drag.style.top = top + "px";
        if (typeof dragEngine.onmove == "function") dragEngine.onmove(dragEngine);
    };
    this.documentMouseup = function(e) {
        var iframes = dragEngine.drag.getElementsByTagName("iframe");
        for (var i = 0; i < iframes.length; i++) {
            iframes[i].style.display = "";
            //removeEventHandler(iframes[i], "mouseover", dragEngine.documentMouseup);
        }
        removeEventHandler(document, "mousemove", dragEngine.documentMousemove);
        removeEventHandler(document, "mouseup", dragEngine.documentMouseup);
        removeEventHandler(dragEngine.target, "losecapture", dragEngine.documentMouseup);
        if (dragEngine.target.releaseCapture) dragEngine.target.releaseCapture();
        removeEventHandler(window, "blur", dragEngine.documentMouseup);
        if (typeof dragEngine.onstop == "function") dragEngine.onstop(dragEngine);
    };
    this.targetMousedown = function(e) {
        // which: 1 == left; 2 == middle; 3 == right
        if (!e.which && e.button)
            e.which = e.button & 1 ? 1 : (e.button & 2 ? 3 : (e.button & 4 ? 2 : 0));
        if (e.which != 1) return;
        var iframes = dragEngine.drag.getElementsByTagName("iframe");
        for (var i = 0; i < iframes.length; i++) {
            iframes[i].style.display = "none";
            //addEventHandler(iframes[i], "mouseover", dragEngine.documentMouseup);
        }

        dragEngine.downPoint.x = e.clientX - dragEngine.drag.offsetLeft;
        dragEngine.downPoint.y = e.clientY - dragEngine.drag.offsetTop;
        addEventHandler(document, "mousemove", dragEngine.documentMousemove);
        addEventHandler(document, "mouseup", dragEngine.documentMouseup);
        addEventHandler(dragEngine.target, "losecapture", dragEngine.documentMouseup);
        if (dragEngine.target.setCapture) dragEngine.target.setCapture();
        addEventHandler(window, "blur", dragEngine.documentMouseup);
        if (e.preventDefault) e.preventDefault();
        if (typeof dragEngine.onstart == "function") dragEngine.onstart(dragEngine);
    };
    addEventHandler(this.target, "mousedown", this.targetMousedown);
}

/// <summary>
/// 释放拖拽引擎
/// </summary>
DragEngine.prototype.dispose = function() {
    removeEventHandler(this.target, "mousedown", this.targetMousedown);
}

/*//
标题:对话框
设计:
版权:
版本:20091208
//*/

var globalZIndex = 1001; // 对话框层次
var imagePath = "/Res/img/"; // 图片路径

/// <summary>
/// 获取文档的边界信息
/// </summary>
function getDocumentBounds() {
    if (document.documentElement && document.compatMode == "CSS1Compat") {
        return {
            st: document.documentElement.scrollTop,
            sl: document.documentElement.scrollLeft,
            sw: document.documentElement.scrollWidth,
            sh: document.documentElement.scrollHeight,
            cw: document.documentElement.clientWidth,
            ch: document.documentElement.clientHeight
        }
    } else if (document.body) {
        return {
            st: document.body.scrollTop,
            sl: document.body.scrollLeft,
            sw: document.body.scrollWidth,
            sh: document.body.scrollHeight,
            cw: document.body.clientWidth,
            ch: document.body.clientHeight
        }
    }
}

function IODialog(title, left, top, width, height, closefree, fixup) {
    this.closefree = closefree;
    this.div_dialog = document.createElement("div");
    this.div_dialog.style.textAlign = "left";
    this.div_dialog.style.display = "none";
    this.div_dialog.style.position = "absolute";
    this.div_dialog.style.borderStyle = "none";
    this.div_dialog.style.borderWidth = "0px";
    this.div_dialog.style.zIndex = globalZIndex;
    this.edgeWidth = 25; // 边宽
    document.body.appendChild(this.div_dialog);

    this.table_dialog = document.createElement("table");
    this.table_dialog.cellPadding = "0px";
    this.table_dialog.cellSpacing = "0px";
    this.div_dialog.appendChild(this.table_dialog);

    this.tr_top = this.table_dialog.insertRow(-1);
    this.tr_top.style.height = "40px";

    this.tr_middle = this.table_dialog.insertRow(-1);

    this.tr_bottom = this.table_dialog.insertRow(-1);
    this.tr_bottom.style.height = "25px";

    this.td_top_left = this.tr_top.insertCell(-1);
    this.td_top_left.style.backgroundImage = "url(" + imagePath + "corner.png)";
    this.td_top_left.style.backgroundPosition = "0px -100px";
    this.td_top_left.style.backgroundRepeat = "no-repeat";
    this.td_top_left.style.width = this.edgeWidth + "px";

    /*
    this.img_icon = document.createElement("img");
    this.img_icon.src = imagePath + "icon.gif";
    this.img_icon.style.marginTop = "10px";
    this.img_icon.style.marginLeft = "17px";
    this.td_top_left.appendChild(this.img_icon);
    */

    this.td_top_center = this.tr_top.insertCell(-1);

    this.td_top_center.style.backgroundImage = "url(" + imagePath + "vertical.png)";
    this.td_top_center.style.width = (width - this.edgeWidth * 2) + "px";
    this.td_top_center.style.backgroundPosition = "0px -100px";
    this.td_top_center.style.backgroundRepeat = "repeat-x";

    this.div_title = document.createElement("div");
    this.div_title.style.styleFloat = "left";
    this.div_title.style.cssFloat = "left";
    this.div_title.style.fontWeight = "bold";

    if (!fixup) {
        this.div_title.style.cursor = "move";
        this.dragEngine = new DragEngine(this.div_title, this.div_dialog);
    }
    this.div_title.style.height = "29px";
    this.div_title.style.verticalAlign = "middle";
    this.div_title.style.lineHeight = "29px";
    this.div_title.style.marginTop = "11px";
    this.div_title.dialog = this;
    this.td_top_center.appendChild(this.div_title);

    this.div_close = document.createElement("div");
    this.div_close.style.styleFloat = "right";
    this.div_close.style.cssFloat = "right";
    this.td_top_center.appendChild(this.div_close);

    this.img_close = document.createElement("img");
    this.img_close.src = imagePath + "blank.gif";
    this.img_close.style.backgroundImage = "url(" + imagePath + "closebtn.gif)";
    this.img_close.style.width = "44px";
    this.img_close.style.height = "19px";
    this.img_close.style.backgroundRepeat = "no-repeat";
    this.img_close.style.marginTop = "12px";
    try {
        this.img_close.style.cursor = "pointer";
    }
    catch (e) {
        this.img_close.style.cursor = "hand";
    }
    this.img_close.onmouseover = function() {
        this.hot = true;
        this.doChange();
    }
    this.img_close.onmouseout = function() {
        this.down = false;
        this.hot = false;
        this.doChange();
    }
    this.img_close.onmousedown = function() {
        this.down = true;
        this.doChange();
    }
    this.img_close.onmouseup = function() {
        this.down = false;
        this.doChange();
    }
    this.img_close.onclick = function() {
        if (!this.dialog) return;
        this.dialog.close();
    }
    this.img_close.dialog = this;
    this.img_close.hot = false;
    this.img_close.down = false;
    this.img_close.doChange = function() {
        if (this.disabled)
            this.style.backgroundPosition = "-132px 0px";
        else if (this.down)
            this.style.backgroundPosition = "-88px 0px";
        else if (this.hot)
            this.style.backgroundPosition = "-44px 0px";
        else this.style.backgroundPosition = "0px 0px";
    }
    this.div_close.appendChild(this.img_close)

    this.td_top_right = this.tr_top.insertCell(-1);
    this.td_top_right.style.backgroundImage = "url(" + imagePath + "corner.png)";
    this.td_top_right.style.backgroundRepeat = "no-repeat";
    this.td_top_right.style.backgroundPosition = "-75px -100px";
    this.td_top_right.style.width = this.edgeWidth + "px";

    this.td_middle_left = this.tr_middle.insertCell(-1);
    this.td_middle_left.style.backgroundImage = "url(" + imagePath + "horizontal.png)";
    this.td_middle_left.style.backgroundPosition = "-100px 0px";
    this.td_middle_left.style.backgroundRepeat = "repeat-y";

    this.td_middle_center = this.tr_middle.insertCell(-1);
    this.td_middle_center.style.backgroundColor = "White";

    this.div_html = document.createElement("div");
    this.td_middle_center.appendChild(this.div_html);

    this.td_middle_right = this.tr_middle.insertCell(-1);
    this.td_middle_right.style.backgroundImage = "url(" + imagePath + "horizontal.png)";
    this.td_middle_right.style.backgroundPosition = "-175px 0px";
    this.td_middle_right.style.backgroundRepeat = "repeat-y";

    this.td_bottom_left = this.tr_bottom.insertCell(-1);
    this.td_bottom_left.style.backgroundImage = "url(" + imagePath + "corner.png)";
    this.td_bottom_left.style.backgroundRepeat = "no-repeat";
    this.td_bottom_left.style.backgroundPosition = "0px -175px";

    this.td_bottom_center = this.tr_bottom.insertCell(-1);
    this.td_bottom_center.style.backgroundImage = "url(" + imagePath + "vertical.png)";
    this.td_bottom_center.style.backgroundPosition = "0px -175px";
    this.td_bottom_center.style.backgroundRepeat = "repeat-x";

    this.td_bottom_right = this.tr_bottom.insertCell(-1);
    this.td_bottom_right.style.backgroundImage = "url(" + imagePath + "corner.png)";
    this.td_bottom_right.style.backgroundRepeat = "no-repeat";
    this.td_bottom_right.style.backgroundPosition = "-75px -175px";
    this.resize(left, top, width, height);
    this.setTitle(title);
}

IODialog.prototype.hide = function() {
    this.div_dialog.style.display = "none";
}

IODialog.prototype.resize = function(left, top, width, height) {
    var bounds = getDocumentBounds();
    if (typeof top == "undefined" || top < 0) top = Math.max((bounds.ch - height) / 2 + bounds.st, 10);
    if (typeof left == "undefined" || left < 0) left = Math.max((bounds.cw - width) / 2 + bounds.sl, 10);
    this.left = left;
    this.top = top;
    this.width = width;
    this.height = height;
    this.div_dialog.style.left = this.left + "px";
    //this.div_dialog.style.top =10000+this.top + "px";
    this.div_dialog.style.width = width + "px";
    this.div_dialog.style.height = height + "px";
    this.table_dialog.style.width = width + "px";
    this.table_dialog.style.height = height + "px";
    this.tr_middle.style.height = (height - 40 - 25) + "px";
    this.td_top_center.style.width = (width - this.edgeWidth * 2) + "px";
    this.div_title.style.width = (width - this.edgeWidth * 2 - 50) + "px";
    this.td_middle_center.style.height = (height - 40 - 25) + "px";
    this.div_html.style.width = (width - this.edgeWidth * 2) + "px";
    this.div_html.style.height = (height - 40 - 25) + "px";

    if (typeof this.onresize == "function") this.onresize(this);
}

IODialog.prototype.setTitle = function(title) {
    if (this.title == title) return;
    this.title = title;
    this.div_title.innerHTML = title;
}

IODialog.prototype.show = function() {
    this.div_dialog.style.left = this.left + "px";
    this.div_dialog.style.top = this.top + "px";
    this.div_dialog.style.display = "";
    this.bodyStyleOverflow = document.body.style.overflowX;
    document.body.style.overflowX = "hidden";
    if ((/(msie)\s*(\d+(\.\d+)?)/i).exec(navigator.userAgent)) {
        document.createStyleSheet("javascript:'html{overflow-x:hidden;}'");
        document.createStyleSheet().addRule("html", "overflow-x:hidden;");
        document.createStyleSheet().addRule("body", "overflow-x:hidden;");
    }
}

IODialog.prototype.close = function() {
    if (typeof this.onclose == "function") this.onclose(this);
    if (typeof (this.closefree) != "undefined" && this.closefree)
        this.dispose();
    else this.hide();
    document.body.style.overflowX = this.bodyStyleOverflow;
    if ((/(msie)\s*(\d+(\.\d+)?)/i).exec(navigator.userAgent)) {
        document.createStyleSheet("javascript:'html{overflow-x:auto;}'");
        document.createStyleSheet().addRule("html", "overflow-x:auto;");
        document.createStyleSheet().addRule("body", "overflow-x:auto;");
    }
}

IODialog.prototype.dispose = function() {
    if (typeof this.ondispose == "function") this.ondispose(this);
    if (!fixup) this.dragEngine.dispose();
    this.td_middle_center.removeChild(this.div_html);
    this.div_close.removeChild(this.img_close)
    this.td_top_center.removeChild(this.div_close);
    this.td_top_center.removeChild(this.div_title);
    //this.td_top_left.removeChild(this.img_icon);
    this.div_dialog.removeChild(this.table_dialog);
    document.body.removeChild(this.div_dialog);
}

// 调用封装
var currentDialog = null;
function showWindow(opts) {
    if (!currentDialog) {
        if (typeof opts.width == "undefined")
            opts.width = 200;
        if (typeof opts.height == "undefined")
            opts.height = 200;

        var bounds = getDocumentBounds();
        currentDialog = new IODialog(opts.title, opts.left, opts.top,
			opts.width, opts.height, false, false);
        currentDialog.div_black = document.createElement("div");
        currentDialog.div_black.style.position = "absolute";
        currentDialog.div_black.style.borderStyle = "none";
        currentDialog.div_black.style.zIndex = "1000";
        currentDialog.div_black.style.left = "0";
        currentDialog.div_black.style.top = bounds.st + "px";
        currentDialog.div_black.style.height = "3000px";
        currentDialog.div_black.style.width = "3000px";
        currentDialog.div_black.style.filter = "alpha(opacity = 40)";
        currentDialog.div_black.style.opacity = "0.55857";
        currentDialog.div_black.style.backgroundColor = "#999999";
        document.body.appendChild(currentDialog.div_black);
        currentDialog.onresize = function() {
            var bounds = getDocumentBounds();
            currentDialog.div_black.style.top = bounds.st - 1000 + "px";
        }
        currentDialog.onclose = function() {
            currentDialog.div_black.style.display = "none";
        }
        currentDialog.ondispose = function() {
            document.body.removeChild(currentDialog.div_black);
            currentDialog = null;
        }
    } else {
        currentDialog.div_black.style.display = "block";
        currentDialog.resize(opts.left, opts.top, opts.width, opts.height);
        currentDialog.setTitle(opts.title);
    }
    if (typeof opts.url == "string") {
        if (/\/Manage\/Top\/AddTop\.aspx/.test(opts.url))
            opts.url = opts.url.replace(/%3e/ig, "%uFF1E").replace(/%3c/ig, "%uFF1C")
        currentDialog.div_html.innerHTML = "";
        currentDialog.iframe = document.createElement("iframe");
        currentDialog.iframe.width = (opts.width - currentDialog.edgeWidth * 2) + "px";
        currentDialog.iframe.height = (opts.height - 40 - 25) + "px";
        currentDialog.iframe.style.margin = "0";
        currentDialog.iframe.frameBorder = "0";
        currentDialog.iframe.src = opts.url;
        currentDialog.div_html.appendChild(currentDialog.iframe);
    } else if (typeof opts.html == "string") {
        currentDialog.div_html.innerHTML = opts.html;
    }
    currentDialog.show();
}

function closeWindow() {
    if (currentDialog) currentDialog.close();
}

//-----------------------------------------------------------------------------窗口打开页面 结束------------------------------------------------------------------------------


//-------------------------------------------------------base64开始------------------------------------------
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var base64DecodeChars = new Array(
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
    -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);

function base64encode(str) {
    var out, i, len;
    var c1, c2, c3;

    len = str.length;
    i = 0;
    out = "";
    while (i < len) {
        c1 = str.charCodeAt(i++) & 0xff;
        if (i == len) {
            out += base64EncodeChars.charAt(c1 >> 2);
            out += base64EncodeChars.charAt((c1 & 0x3) << 4);
            out += "==";
            break;
        }
        c2 = str.charCodeAt(i++);
        if (i == len) {
            out += base64EncodeChars.charAt(c1 >> 2);
            out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
            out += base64EncodeChars.charAt((c2 & 0xF) << 2);
            out += "=";
            break;
        }
        c3 = str.charCodeAt(i++);
        out += base64EncodeChars.charAt(c1 >> 2);
        out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
        out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
        out += base64EncodeChars.charAt(c3 & 0x3F);
    }
    return out;
}

function utf16to8(str) {
    var out, i, len, c;

    out = "";
    len = str.length;
    for (i = 0; i < len; i++) {
        c = str.charCodeAt(i);
        if ((c >= 0x0001) && (c <= 0x007F)) {
            out += str.charAt(i);
        } else if (c > 0x07FF) {
            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
            out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
        } else {
            out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
        }
    }
    return out;
}

function base64decode(str) {
    var c1, c2, c3, c4;
    var i, len, out;
    len = str.length;
    i = 0;
    out = "";
    while (i < len) {
        /* c1 */
        do {
            c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
        } while (i < len && c1 == -1);
        if (c1 == -1)
            break;
        /* c2 */
        do {
            c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
        } while (i < len && c2 == -1);
        if (c2 == -1)
            break;
        out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
        /* c3 */
        do {
            c3 = str.charCodeAt(i++) & 0xff;
            if (c3 == 61)
                return out;
            c3 = base64DecodeChars[c3];
        } while (i < len && c3 == -1);
        if (c3 == -1)
            break;
        out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
        /* c4 */
        do {
            c4 = str.charCodeAt(i++) & 0xff;
            if (c4 == 61)
                return out;
            c4 = base64DecodeChars[c4];
        } while (i < len && c4 == -1);
        if (c4 == -1)
            break;
        out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
    }
    return out;
}

function utf8to16(str) {
    var out, i, len, c;
    var char2, char3;
    out = "";
    len = str.length;
    i = 0;
    while (i < len) {
        c = str.charCodeAt(i++);
        switch (c >> 4) {
            case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
                // 0xxxxxxx
                out += str.charAt(i - 1);
                break;
            case 12: case 13:
                // 110x xxxx　 10xx xxxx
                char2 = str.charCodeAt(i++);
                out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
                break;
            case 14:
                // 1110 xxxx　10xx xxxx　10xx xxxx
                char2 = str.charCodeAt(i++);
                char3 = str.charCodeAt(i++);
                out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
                break;
        }
    }
    return out;
}

//------------------------------------------------base64结束------------------------------------------------------

//---------------------------------------------------md5开始---------------------------------------------------------------
var hex_chr = "0123456789abcdef";
function rhex(num) {
    str = "";
    for (j = 0; j <= 3; j++)
        str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
hex_chr.charAt((num >> (j * 8)) & 0x0F);
    return str;
}
function str2blks_MD5(str) {
    nblk = ((str.length + 8) >> 6) + 1;
    blks = new Array(nblk * 16);
    for (i = 0; i < nblk * 16; i++) blks[i] = 0;
    for (i = 0; i < str.length; i++)
        blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
    blks[i >> 2] |= 0x80 << ((i % 4) * 8);
    blks[nblk * 16 - 2] = str.length * 8;
    return blks;
}
function add(x, y) {
    var lsw = (x & 0xFFFF) + (y & 0xFFFF);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 0xFFFF);
}
function rol(num, cnt) {
    return (num << cnt) | (num >>> (32 - cnt));
}
function cmn(q, a, b, x, s, t) {
    return add(rol(add(add(a, q), add(x, t)), s), b);
}
function ff(a, b, c, d, x, s, t) {
    return cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t) {
    return cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t) {
    return cmn(b ^ c ^ d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t) {
    return cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function MD5(str) {
    x = str2blks_MD5(str);
    var a = 1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d = 271733878;
    for (i = 0; i < x.length; i += 16) {
        var olda = a;
        var oldb = b;
        var oldc = c;
        var oldd = d;
        a = ff(a, b, c, d, x[i + 0], 7, -680876936);
        d = ff(d, a, b, c, x[i + 1], 12, -389564586);
        c = ff(c, d, a, b, x[i + 2], 17, 606105819);
        b = ff(b, c, d, a, x[i + 3], 22, -1044525330);
        a = ff(a, b, c, d, x[i + 4], 7, -176418897);
        d = ff(d, a, b, c, x[i + 5], 12, 1200080426);
        c = ff(c, d, a, b, x[i + 6], 17, -1473231341);
        b = ff(b, c, d, a, x[i + 7], 22, -45705983);
        a = ff(a, b, c, d, x[i + 8], 7, 1770035416);
        d = ff(d, a, b, c, x[i + 9], 12, -1958414417);
        c = ff(c, d, a, b, x[i + 10], 17, -42063);
        b = ff(b, c, d, a, x[i + 11], 22, -1990404162);
        a = ff(a, b, c, d, x[i + 12], 7, 1804603682);
        d = ff(d, a, b, c, x[i + 13], 12, -40341101);
        c = ff(c, d, a, b, x[i + 14], 17, -1502002290);
        b = ff(b, c, d, a, x[i + 15], 22, 1236535329);
        a = gg(a, b, c, d, x[i + 1], 5, -165796510);
        d = gg(d, a, b, c, x[i + 6], 9, -1069501632);
        c = gg(c, d, a, b, x[i + 11], 14, 643717713);
        b = gg(b, c, d, a, x[i + 0], 20, -373897302);
        a = gg(a, b, c, d, x[i + 5], 5, -701558691);
        d = gg(d, a, b, c, x[i + 10], 9, 38016083);
        c = gg(c, d, a, b, x[i + 15], 14, -660478335);
        b = gg(b, c, d, a, x[i + 4], 20, -405537848);
        a = gg(a, b, c, d, x[i + 9], 5, 568446438);
        d = gg(d, a, b, c, x[i + 14], 9, -1019803690);
        c = gg(c, d, a, b, x[i + 3], 14, -187363961);
        b = gg(b, c, d, a, x[i + 8], 20, 1163531501);
        a = gg(a, b, c, d, x[i + 13], 5, -1444681467);
        d = gg(d, a, b, c, x[i + 2], 9, -51403784);
        c = gg(c, d, a, b, x[i + 7], 14, 1735328473);
        b = gg(b, c, d, a, x[i + 12], 20, -1926607734);
        a = hh(a, b, c, d, x[i + 5], 4, -378558);
        d = hh(d, a, b, c, x[i + 8], 11, -2022574463);
        c = hh(c, d, a, b, x[i + 11], 16, 1839030562);
        b = hh(b, c, d, a, x[i + 14], 23, -35309556);
        a = hh(a, b, c, d, x[i + 1], 4, -1530992060);
        d = hh(d, a, b, c, x[i + 4], 11, 1272893353);
        c = hh(c, d, a, b, x[i + 7], 16, -155497632);
        b = hh(b, c, d, a, x[i + 10], 23, -1094730640);
        a = hh(a, b, c, d, x[i + 13], 4, 681279174);
        d = hh(d, a, b, c, x[i + 0], 11, -358537222);
        c = hh(c, d, a, b, x[i + 3], 16, -722521979);
        b = hh(b, c, d, a, x[i + 6], 23, 76029189);
        a = hh(a, b, c, d, x[i + 9], 4, -640364487);
        d = hh(d, a, b, c, x[i + 12], 11, -421815835);
        c = hh(c, d, a, b, x[i + 15], 16, 530742520);
        b = hh(b, c, d, a, x[i + 2], 23, -995338651);
        a = ii(a, b, c, d, x[i + 0], 6, -198630844);
        d = ii(d, a, b, c, x[i + 7], 10, 1126891415);
        c = ii(c, d, a, b, x[i + 14], 15, -1416354905);
        b = ii(b, c, d, a, x[i + 5], 21, -57434055);
        a = ii(a, b, c, d, x[i + 12], 6, 1700485571);
        d = ii(d, a, b, c, x[i + 3], 10, -1894986606);
        c = ii(c, d, a, b, x[i + 10], 15, -1051523);
        b = ii(b, c, d, a, x[i + 1], 21, -2054922799);
        a = ii(a, b, c, d, x[i + 8], 6, 1873313359);
        d = ii(d, a, b, c, x[i + 15], 10, -30611744);
        c = ii(c, d, a, b, x[i + 6], 15, -1560198380);
        b = ii(b, c, d, a, x[i + 13], 21, 1309151649);
        a = ii(a, b, c, d, x[i + 4], 6, -145523070);
        d = ii(d, a, b, c, x[i + 11], 10, -1120210379);
        c = ii(c, d, a, b, x[i + 2], 15, 718787259);
        b = ii(b, c, d, a, x[i + 9], 21, -343485551);
        a = add(a, olda);
        b = add(b, oldb);
        c = add(c, oldc);
        d = add(d, oldd);
    }
    return rhex(a) + rhex(b) + rhex(c) + rhex(d);
}
//---------------------------------------------------md5结束--------------------------------------------------------------

//------------------用JavaScript操作COOKIE---------------------------------------------------
function SetCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function GetCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

//参数说明： 
//sMainName Cookie名 
//sSubName Cookie子键名，留空表示单值Cookie 
function getCookie(sMainName, sSubName) {
    var re = new RegExp((sSubName ? sMainName + "=(.*?&)*?" + sSubName + "=(.*?)(&|;)" : sMainName + "=(.*?);"), "i");
    return re.test(unescape(document.cookie)) ? (sSubName ? RegExp["$2"] : RegExp["$1"]) : "";
} 

//------------------------------------用JavaScript操作COOKIE结束



//------------------------------------------------菜单---------------------------------------------------

var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $(id) {
    return document.getElementById(id);
}


var jsmenu = new Array();
var ctrlobjclassName;
jsmenu['active'] = new Array();
jsmenu['timer'] = new Array();
jsmenu['iframe'] = new Array();

//判断是否为空
function isUndefined(strMain) {
    var strComp = strMain
    try {
        if (strComp == "　" || strComp == "" || strComp == " " || strComp == null || strComp.length == 0 || typeof strMain == "undefined" || strMain == "undefined") {
            return true
        }
        else {
            return false
        }
    } catch (e) { return false }
}
function doane(event) {
    e = event ? event : window.event;
    if (is_ie) {
        e.returnValue = false;
        e.cancelBubble = true;
    } else if (e) {
        e.stopPropagation();
        e.preventDefault();
    }
}
function initCtrl(ctrlobj, click, duration, timeout, layer) {
    if (ctrlobj && !ctrlobj.initialized) {
        ctrlobj.initialized = true;
        ctrlobj.unselectable = true;

        ctrlobj.outfunc = typeof ctrlobj.onmouseout == 'function' ? ctrlobj.onmouseout : null;
        ctrlobj.onmouseout = function() {
            if (this.outfunc) this.outfunc();
            if (duration < 3) jsmenu['timer'][ctrlobj.id] = setTimeout('hideMenu(' + layer + ')', timeout);
        }

        if (click && duration) {
            ctrlobj.clickfunc = typeof ctrlobj.onclick == 'function' ? ctrlobj.onclick : null;
            ctrlobj.onclick = function(e) {
                doane(e);
                if (jsmenu['active'][layer] == null || jsmenu['active'][layer].ctrlkey != this.id) {
                    if (this.clickfunc) this.clickfunc();
                    else showMenu(this.id, true);
                } else {
                    hideMenu(layer);
                }
            }
        }

        ctrlobj.overfunc = typeof ctrlobj.onmouseover == 'function' ? ctrlobj.onmouseover : null;
        ctrlobj.onmouseover = function(e) {
            doane(e);
            if (this.overfunc) this.overfunc();
            if (click) {
                clearTimeout(jsmenu['timer'][this.id]);
            } else {
                for (var id = 0; id < jsmenu['timer'].length; id++) {
                    if (jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
                }
            }
        }
    }
}

function initMenu(ctrlid, menuobj, duration, timeout, layer) {
    if (menuobj && !menuobj.initialized) {
        menuobj.initialized = true;
        menuobj.ctrlkey = ctrlid;
        menuobj.onclick = ebygum;
        menuobj.style.position = 'absolute';
        if (duration < 3) {
            if (duration > 1) {
                menuobj.onmouseover = function() {
                    clearTimeout(jsmenu['timer'][ctrlid]);
                }
            }
            if (duration != 1) {
                menuobj.onmouseout = function() {
                    jsmenu['timer'][ctrlid] = setTimeout('hideMenu(' + layer + ')', timeout);
                }
            }
        }
        menuobj.style.zIndex = 50;
        if (is_ie) {
            menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#CCCCCC,strength=2)";
        }
    }
}

function showMenu(ctrlid, click, offset, duration, timeout, layer, showid, maxh, containerid) {
    e = window.event ? window.event : showMenu.caller.arguments[0];
    var ctrlobj = $(ctrlid);
    if (!ctrlobj) return;
    if (isUndefined(click)) click = false;
    if (isUndefined(offset)) offset = 0;
    if (isUndefined(duration)) duration = 2;
    if (isUndefined(timeout)) timeout = 500;
    if (isUndefined(layer)) layer = 0;
    if (isUndefined(showid)) showid = ctrlid;
    var showobj = $(showid);
    var menuobj = $(showid + '_menu');
    if (!showobj || !menuobj) return;
    if (isUndefined(maxh)) maxh = 400;

    hideMenu(layer);

    for (var id = 0; id < jsmenu['timer'].length; id++) {
        if (jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
    }

    initCtrl(ctrlobj, click, duration, timeout, layer);
    ctrlobjclassName = ctrlobj.className;
    ctrlobj.className += ' hover';
    initMenu(ctrlid, menuobj, duration, timeout, layer);

    menuobj.style.display = '';
    if (!is_opera) {
        menuobj.style.clip = 'rect(auto, auto, auto, auto)';
    }

    setMenuPosition(showid, offset, containerid);

    if (is_ie && is_ie < 7) {
        if (!jsmenu['iframe'][layer]) {
            var iframe = document.createElement('iframe');
            iframe.style.display = 'none';
            iframe.style.position = 'absolute';
            iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
            try {
                $('append_parent').appendChild(iframe);
            }
            catch (e) {
                //for Discuz!NT
            }
            jsmenu['iframe'][layer] = iframe;
        }
        jsmenu['iframe'][layer].style.top = menuobj.style.top;
        jsmenu['iframe'][layer].style.left = menuobj.style.left;
        jsmenu['iframe'][layer].style.width = menuobj.w;
        jsmenu['iframe'][layer].style.height = menuobj.h;
        jsmenu['iframe'][layer].style.display = 'block';
    }

    if (maxh && menuobj.scrollHeight > maxh) {
        menuobj.style.height = maxh + 'px';
        if (is_opera) {
            menuobj.style.overflow = 'auto';
        } else {
            menuobj.style.overflowY = 'auto';
        }
    }

    if (!duration) {
        setTimeout('hideMenu(' + layer + ')', timeout);
    }

    jsmenu['active'][layer] = menuobj;
}

function setMenuPosition(showid, offset, containerid) {
    var showobj = $(showid);
    var menuobj = $(showid + '_menu');
    var container = $(containerid);
    if (isUndefined(offset)) offset = 0;
    if (showobj) {
        showobj.pos = fetchOffset(showobj);
        if (container) {
            showobj.X = showobj.pos['left'] - container.offsetLeft;
            showobj.Y = 0;
        }
        else {
            showobj.X = showobj.pos['left'];
            showobj.Y = showobj.pos['top'];
        }
        showobj.w = showobj.offsetWidth;
        showobj.h = showobj.offsetHeight;
        menuobj.w = menuobj.offsetWidth;
        menuobj.h = menuobj.offsetHeight;
        menuobj.style.left = (showobj.X + menuobj.w > document.body.clientWidth) && (showobj.X + showobj.w - menuobj.w >= 0) ? showobj.X + showobj.w - menuobj.w + 'px' : showobj.X + 'px';
        menuobj.style.top = offset == 1 ? showobj.Y + 'px' : (offset == 2 || ((showobj.Y + showobj.h + menuobj.h > document.documentElement.scrollTop + document.documentElement.clientHeight) && (showobj.Y - menuobj.h >= 0)) ? (showobj.Y - menuobj.h) + 'px' : showobj.Y + showobj.h + 'px');
        if (menuobj.style.clip && !is_opera) {
            menuobj.style.clip = 'rect(auto, auto, auto, auto)';
        }
    }
}

function hideMenu(layer) {
    if (isUndefined(layer)) layer = 0;
    if (jsmenu['active'][layer]) {
        try {
            $(jsmenu['active'][layer].ctrlkey).className = ctrlobjclassName;
        } catch (e) { }
        clearTimeout(jsmenu['timer'][jsmenu['active'][layer].ctrlkey]);
        jsmenu['active'][layer].style.display = 'none';
        if (is_ie && is_ie < 7 && jsmenu['iframe'][layer]) {
            jsmenu['iframe'][layer].style.display = 'none';
        }
        jsmenu['active'][layer] = null;
    }
}

function fetchOffset(obj) {
    var left_offset = obj.offsetLeft;
    var top_offset = obj.offsetTop;
    while ((obj = obj.offsetParent) != null) {
        left_offset += obj.offsetLeft;
        top_offset += obj.offsetTop;
    }
    return { 'left': left_offset, 'top': top_offset };
}

function ebygum(eventobj) {
    if (!eventobj || is_ie) {
        window.event.cancelBubble = true;
        return window.event;
    } else {
        if (eventobj.target.type == 'submit') {
            eventobj.target.form.submit();
        }
        eventobj.stopPropagation();
        return eventobj;
    }
}

function menuoption_onclick_function(e) {
    this.clickfunc();
    hideMenu();
}

function menuoption_onclick_link(e) {
    choose(e, this);
}

function menuoption_onmouseover(e) {
    this.className = 'popupmenu_highlight';
}

function menuoption_onmouseout(e) {
    this.className = 'popupmenu_option';
}

function choose(e, obj) {
    var links = obj.getElementsByTagName('a');
    if (links[0]) {
        if (is_ie) {
            links[0].click();
            window.event.cancelBubble = true;
        } else {
            if (e.shiftKey) {
                window.open(links[0].href);
                e.stopPropagation();
                e.preventDefault();
            } else {
                window.location = links[0].href;
                e.stopPropagation();
                e.preventDefault();
            }
        }
        hideMenu();
    }
}


//------------------------------------------------菜单结束-----------------------------------------------


//------------------------------------------------漂浮广告-----------------------------------------------

/**
* 漂浮容器
* @param {String} html 
* @param {Object} opt {top:10,height:300,width:100,isLeft:null,autoFix:null};
*/
function IOCMS_floatDiv(html, opt) {
    var w = window, ivhs = 'iocms_floatDivTimers', divs = 'iocms_floatDivs';
    w[ivhs] instanceof Array ? '' : w[ivhs] = [];
    w[divs] instanceof Array ? '' : w[divs] = [];

    var doc = document,
	docElem = doc.documentElement,
    body = doc.body,
    div = doc.createElement('div'),
	top = (opt.top || 10),
    dstyle = div.style,
	template = function(html) {
	    return html + '<div style="text-align:center;font-size:12px;cursor:pointer;background-color:#ccc;line-height:14px;padding-top:1px;letter-spacing:1em;text-indent:1em;">\u5173\u95ed<\/div>'
	},
	currentY = 0,
	insert = function() { w[divs].push(div); body.insertBefore(div, body.firstChild); },
	imgs, cache = new Image;

    dstyle.top = top + 'px';
    dstyle.height = (opt.height || 300) + 20 + 'px';
    dstyle.width = (opt.width || 100) + 'px';
    dstyle.zIndex = 1000;
    dstyle.overflow = 'hidden';
    dstyle[opt.isLeft ? 'left' : 'right'] = '1px';
    dstyle.position = 'absolute';

    div.innerHTML = template(html);
    div.lastChild.onclick = function() {
        for (var i = w[divs].length; i > 0; i--) {
            w[divs].shift().style.display = 'none';
            if (w[ivhs]) w.clearInterval(w[ivhs].shift());
        }
    };
    imgs = div.getElementsByTagName('img');
    if (imgs.length) {
        cache.onload = insert;
        cache.src = imgs[0].src;
    } else { insert(); }

    if (opt.autoFix == 1) {
        if (/MSIE 6|Maxthon 2/.test(navigator.userAgent)) {
            var ivh = w.setInterval(function() {
                dstyle.top = doc.documentElement.scrollTop + top;
            }, 500);
            w[ivhs].push(ivh);
        } else {
            dstyle.position = 'fixed';
        }
    }
}

//------------------------------------------------漂浮广告 结束------------------------------------------
