﻿var _tmpmid = 1;
function muenqh(id) {
    if (_tmpmid != id) {
        mbh(_tmpmid, false);
        var _isb = mbh(id, true);
        if (_isb) {
            _tmpmid = id;
        }
    }
}
function mbh(id, isshow) {
    var control = document.getElementById('mbox');
    var nowclass = control.className;
    var _classstr = 'cbox_img';
    var _classstr1 = 'muenimg';
    var _partid = 'cbox';
    var control1 = document.getElementById(_partid + id);
    if (isshow == true) {
        if (nowclass.indexOf(_classstr + id) <= -1) {
            control.className = _classstr1 + ' ' + _classstr + id;
        }
        control1.style.display = 'block';
        return true;
    }
    else {
        control1.style.display = 'none';
        return true;
    }
    return false;
}
function cmbox(index) {
    var classID = 'linebox sl muenbgimg_1 muenbgimg';
    var control = document.getElementById('cmbox');
    if (control.className != classID + index) {
        control.className = classID + index;
    }
}
var Muen = function(time, id, pid, maxv, minv) {
    var mcid = id;
    var pmcid = pid;
    var timeout = time;
    var topmin = minv;
    var topmax = maxv < 0 ? maxv : -maxv;
    var timeid = 0;
    var timeid1 = 0;
    var onestop = topmax / timeout;
    var unloadtimeid = 0;
    function display(isnone) {
        var pmc = document.getElementById(pmcid);
        if (isnone == true) {
            if (pmc.style.display == 'none') {
                pmc.style.display = 'block';
            }
        }
        else {
            if (pmc.style.display == 'block') {
                pmc.style.display = 'none';
            }
        }
    }
    function priLoad() {
        display(true);
        clearTime();
        clearTimeout(timeid1);
        var mc = document.getElementById(mcid);
        var tmptop = mc.offsetTop;
        if ((-onestop) < 1) {
            onestop = -1;
        }
        if (tmptop < topmin) {
            var tmptop1 = tmptop - onestop;
            if (tmptop1 >= minv) {
                tmptop1 = minv;
            }
            mc.style.top = tmptop1 + 'px';
            if (tmptop1 == minv) {
                clearTimeout(timeid);
                return;
            }
            timeid = window.setTimeout(function() { priLoad(); }, 1);
        }
    }
    function priUnLoad() {
        var mc = document.getElementById(mcid);
        clearTime1();
        var tmptop = mc.offsetTop;
        window.clearTimeout(timeid);
        if (tmptop > topmax) {
            if ((-onestop) < 1) {
                onestop = -1;
            }
            var tmptop1 = tmptop + onestop;
            if (tmptop1 <= topmax) {
                tmptop1 = topmax;
            }
            mc.style.top = tmptop1 + 'px';
            if (tmptop1 == topmax) {
                clearTimeout(timeid1);
                display(false);
                return;
            }
            timeid1 = window.setTimeout(function() { priUnLoad(); }, 1);
        }
    }
    function clearTime() {
        if (timeid > 0) {
            window.clearTimeout(timeid);
            timeid = 0;
        }
    }
    function clearTime1() {
        if (timeid1 > 0) {
            window.clearTimeout(timeid1);
            timeid1 = 0;
        }
    }
    function prisetHTML(txt) {
        var mc = document.getElementById(mcid);
        mc.innerHTML = txt;
    }
    this.setHtml = function(txt) {
        prisetHTML(txt);
    };
    this.Load = function() {
        priLoad();
    };
    this.UnLoad = function() {
        priUnLoad();
    };
};
