﻿// JScript 文件
var QjwClass = function() {
}
QjwClass.prototype.$ = function(ctl) { return document.getElementById(ctl); }
QjwClass.prototype.Get = function(strUrl, callBack) {
    try {
        var xmlHttpReq;
        try {
            if (window.XMLHttpRequest) {
                xmlHttpReq = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                try {
                    xmlHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
                }
                catch (e) {
                    try {
                        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) { }
                }
            }
        } catch (e) { }
        xmlHttpReq.open("get", strUrl, true);
        xmlHttpReq.send(null);
        xmlHttpReq.onreadystatechange = function() {
            if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200) {
                if (callBack != null) {
                    if (typeof (callBack) == "function") {
                        callBack(xmlHttpReq.responseText);
                    }
                    else
                        callBack.innerHTML = xmlHttpReq.responseText;
                }
            }
        }
    }
    catch (err) { alert(err.message); }
}
QjwClass.prototype.WinOpen = function(strUrl, strTitle, strWidth, strHeight, strScroll) {
    try {
        window.open(strUrl, strTitle, 'width=' + strWidth + 'px,height=' + strHeight + 'px,left=' + (screen.width - parseInt(strWidth)) / 2 + ',top=' + (screen.height - parseInt(strHeight)) / 2 + ',toolbar=no, menubar=no, scroll=' + strScroll + ', resizable=no,location=no,status=no');
    }
    catch (e) { }
}
QjwClass.prototype.Show = function(strTitle, strUrl, intWidth, intHeight, blnShade, blnScroll) {
    //为关闭做了修改，固定了id
    if (document.getElementById("fixDialog") != null) {
        document.removeChild(document.getElementById("fixDialog"));
    }
    var dialogBox = document.createElement("div");
    dialogBox.id = "fixDialog"; //固定了id
    dialogBox.className = "fixDialog";
    dialogBox.style.width = intWidth + "px";
    dialogBox.style.height = intHeight + "px";
    if (window.navigator.userAgent.toLowerCase().indexOf("ie 6") != -1)
        dialogBox.style.marginTop = document.documentElement.scrollTop - (intHeight / 2) + "px";
    else
        dialogBox.style.marginTop = -(intHeight / 2) + "px";
    dialogBox.style.marginLeft = -(intWidth / 2) + "px";
    dialogBox.innerHTML += "<div class='control'><span class='title'>" + strTitle + "</span><span class='close' onclick='Qjw.Remove(Qjw.$(\"shadeBox\"));Qjw.Remove(this.parentNode.parentNode)'>关闭</span></div>";
    dialogBox.innerHTML += "<div class='box'><div class='loading' style=\"width:" + parseInt(intWidth - 6) + "px;height:" + (intHeight - 28) + "px;\"></div><iframe onload='javascript:Qjw.Remove(Qjw.Find(this.parentNode,\"div\",\"tag\"))' src='" + strUrl + "' width='" + (intWidth - 6) + "' height='" + (intHeight - 28) + "' frameborder='0' scrolling='" + (blnScroll ? "auto" : "no") + "'></iframe></div>";

    if (blnShade) {
        try {
            var shadeBox = document.createElement("div");
            shadeBox.id = "shadeBox";
            shadeBox.className = "shade";
            document.body.appendChild(shadeBox);
            if (shadeBox.clientHeight < document.body.clientHeight)
                shadeBox.style.height = document.body.clientHeight + "px";
        }
        catch (e) { }
    }
    document.body.appendChild(dialogBox);

    //ie bug
    try {
        dialogBox.getElementsByTagName("iframe")[0].src = strUrl;
    } catch (e) { }
}
QjwClass.prototype.Find = function(findContainer, findCtl, findType) {
    switch (findType) {
        case "tag":
            return findContainer.getElementsByTagName(findCtl);
        case "id":
            return findContainer.getElementById(findCtl);
    }
    return null;
}
QjwClass.prototype.Remove = function(ctls) {
    if (ctls.length != undefined) {
        if (ctls.length > 0) {
            for (var i = 0; i < ctls.length; i++) {
                ctls[i].parentNode.removeChild(ctls[i]);
            }
        }
    }
    else {
        ctls.parentNode.removeChild(ctls);
    }
}
QjwClass.prototype.Go = function(strUrl) { window.location.href = strUrl; }
QjwClass.prototype.GoLeft = function(demo, demo1, demo2, speed, flag) {
    //向左滚动函数，demo包含demo1与demo2,speed是滚动速度，flag一个网页内有多个时设置为不同的任意字符。
    demo = document.getElementById(demo);
    demo1 = document.getElementById(demo1);
    demo2 = document.getElementById(demo2);
    demo2.innerHTML = demo1.innerHTML;
    function Marquee() {
        if (demo2.offsetWidth - demo.scrollLeft <= 0) {
            demo.scrollLeft -= demo1.offsetWidth;
        }
        else {
            demo.scrollLeft = demo.scrollLeft + 1;
        }
    }
    flag = setInterval(Marquee, speed);
    demo.onmouseover = function() { clearInterval(flag); }
    demo.onmouseout = function() { flag = setInterval(Marquee, speed); }
}
QjwClass.prototype.GoTop = function(demo, demo1, demo2, speed, flag) {
    //向上滚动函数，demo包含demo1与demo2,speed是滚动速度，flag一个网页内有多个时设置为不同的任意字符。
    demo = document.getElementById(demo);
    demo1 = document.getElementById(demo1);
    demo2 = document.getElementById(demo2);
    demo2.innerHTML = demo1.innerHTML;
    function Marquee() {
        if (demo2.offsetTop - demo.scrollTop <= 0) {
            demo.scrollTop -= demo1.offsetHeight;
        }
        else {
            demo.scrollTop++;
        }
    }
    flag = setInterval(Marquee, speed);
    demo.onmouseover = function() { clearInterval(flag); }
    demo.onmouseout = function() { flag = setInterval(Marquee, speed); }
}
QjwClass.prototype.DoTab = function(tabTag) {
    var tabs = document.getElementById(tabTag).getElementsByTagName("div");
    if (tabs.length > 0) {
        for (var i = 0; i < tabs.length; i++) {
            tabs[i].onmouseover = function() {
                var tabs = this.parentNode.getElementsByTagName("div");
                for (var i = 0; i < tabs.length; i++) {
                    if (tabs[i] == this) {
                        tabs[i].className = "current";
                        document.getElementById(this.parentNode.id + (i + 1)).style.display = "";
                    }
                    else {
                        tabs[i].className = "";
                        document.getElementById(this.parentNode.id + (i + 1)).style.display = "none";
                    }
                }
            }
        }
    }
}

var isSetDeposit = false;
var isDoing = false;
QjwClass.prototype.GetDeposit = function(userId, userName, e, ctl) {
    isSetDeposit = true;
    function setDeposit(txt) {
        var ns4 = document.layers;
        var ns6 = document.getElementById && !document.all;
        var x = (ns4 || ns6) ? e.pageX : event.x + document.documentElement.scrollLeft;
        var y = (ns4 || ns6) ? e.pageY : event.y + document.documentElement.scrollTop;

        if (y > parseInt(document.body.clientHeight) - 200) {
            y = y - 190;
        }

        var dX = document.getElementById("poptitle");
        if (x != 0 && y != 0) {
            dX.style.left = x + 10 + "px";
            dX.style.top = y + 5 + "px";
        }
        dX.style.display = "block";
        dX.innerHTML = txt;
    }
    setDeposit("");
    if (ctl.rel == "") {
        this.Get("../Services/DepositService.ashx?userId=" + userId + "&userName=" + escape(userName) + "&date=" + new Date().getTime(), function(txt) {
            ctl.rel = txt;
            if (isSetDeposit) {
                setDeposit(txt);
            }
        });
    }
    else {
        if (isSetDeposit) {
            setDeposit(ctl.rel);
        }
    }
}

QjwClass.prototype.HideDeposit = function() {
    isSetDeposit = false;
    document.getElementById("poptitle").innerHTML = "";
    document.getElementById("poptitle").style.display = "none";
}

QjwClass.prototype.Close = function() { window.close(); }

var Qjw = new QjwClass();
