function ImgesRoll() {
    this.defaultImg = "";
    this.smallImagPath = "";
    this.bigImagPath = "";
    this.imgUrl = new Array();
    this.imgOpenUrl = new Array();
    this.imgTxt = new Array();
    this.key = 0;
    this.VisIndex = 0;
    this.imgPre = new Array();
    this.j = 0;
    this.itemCount = 0;
    this.init = function() {
        for (i = 1; i <= this.imgUrl.length; i++) {
            if ((this.imgTxt[i] != "") && (this.imgOpenUrl[i] != "")) {
                this.j++;
            }
            else {
                break;
            }
        }

    };
    this.nextImg = function() {
        if (this.img != null && this.txt != null) {
            if (this.itemCount == 0) {
                this.img.src = this.defaultImg;
                return;
            }
            if (this.itemCount == 1) {
                this.img.src = this.smallImagPath + this.imgUrl[0];
                this.txt.innerHTML = this.imgTxt[0];
                return;
            }
            if (this.VisIndex + 1 < this.itemCount)
                this.VisIndex++;
            else
                this.VisIndex = 0;

            if (this.key == 0) {
                this.key = 1;
                this.VisIndex = 0;
            }
            else {
                //if (this.img.filters) {
                //    this.img.filters.revealTrans.Transition = 23;
                //    this.img.filters.revealTrans.apply();
                //    this.img.filters.revealTrans.play();
                //}
            }
            this.img.src = this.smallImagPath + this.imgUrl[this.VisIndex];
            this.img.alt = this.imgTxt[this.VisIndex];
            this.txt.innerHTML = this.imgTxt[this.VisIndex];
        }
        this.next();

    };
    this.goUrl = function() {
        window.open(this.bigImagPath + this.imgOpenUrl[this.VisIndex]);
    }


}

function Vote(t, r, v, d, u) {
    this.strResultUrl = r;
    this.strViewUrl = v;
    this.voteID = d;
    this.tableID = t;
    this.userID = u;
    this.CheckSelected = function() {
        var Tab = document.getElementById(this.tableID); //需定位到在线调查的DIV
        if (Tab == null)
            return;
        var chks = Tab.getElementsByTagName("input");
        if (chks == null)
            return;
        var count = 0;
        var a = new Array();
        var j;
        for (i = 0; i < chks.length; i++) {
            if (chks[i].checked && (chks[i].type == "checkbox" || chks[i].type == "radio")) {
                for (j = i; j < i + 1; j++) {
                    a[j] = i;
                }
            }
        }
        if (a != "") {
            $.ajax({
                type: "post",
                dataType: "text",
                url: this.strResultUrl,
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                data: { "Edit": a, "userID": u },
                success: function(d) {
                    if (d == 'success') {
                        alert('调查提交已成功！');
                    }
                    else {
                        alert('您已提交过调查！');
                    }
                }
            });
        }
        else {
            alert('请先选择选项后再提交！');
            return false;
        }
        for (i = 0; i < chks.length; i++) {
            if (chks[i].checked && (chks[i].type == "checkbox" || chks[i].type == "radio")) {
                chks[i].checked = false;
            } 
        }
    };
    this.View = function() {
        window.open(this.strViewUrl + '?EditID=' + this.voteID + '&userID=' + this.userID, "ShowResearch", "width=550,height=350,toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=300");
        return false;
    }
}
function calculagraph() {
    this._id = null;
    this._cT = null;
    this._eT = null;
    this._lT = null;
    this._gT = function() {
        if (this._lT == null) {
            var _xT = (parseInt(this._eT.match(/-(\d+)\s/)[1]) >= parseInt(this._cT.match(/-(\d+)\s/)[1])) ? (parseInt(this._eT.match(/-(\d+)\s/)[1]) - parseInt(this._cT.match(/-(\d+)\s/)[1])) : 0;
            this._cT = parseInt(this._cT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._cT.split(":")[1] * 60) + parseInt(this._cT.split(":")[2]);
            this._eT = _xT * 24 * 3600 + parseInt(this._eT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._eT.split(":")[1] * 60) + parseInt(this._eT.split(":")[2]);
            this._lT = (this._eT - this._cT);
        }
        if (this._lT >= 0) {
            var _D = Math.floor(this._lT / (3600 * 24));
            var _H = Math.floor((this._lT - _D * 3600 * 24) / 3600);
            var _M = Math.floor((this._lT - _H * 3600 - _D * 3600 * 24) / 60);
            var _S = (this._lT - _H * 3600) % 60;
//            document.getElementById(this._id).innerHTML = _D + "天剩余<strong>" + _H + "</strong>小时<strong>" + _M + "</strong>分<strong>" + _S + "</strong>秒";
            document.getElementById(this._id).innerHTML = "<span class='em2'>" + _D + "</span>天<span class='em3'>" + _H + ":" + _M + ":" + _S + "</span>";
            this._lT--;
        } else {
        document.getElementById(this._id).innerHTML = "<span class='em2'>抢购结束</span>";
            clearInterval(this._interval);
        }
    }
    this._interval = function() {
        var o = this;
        this._interval = setInterval(function() { o._gT() }, 1000)
    }
}
