﻿function $get(id) {
    return document.getElementById(id);
}
/*平台进行维护通告ＪＳ*/
function OLUpGradeAd() {
    var olNews = "";
    olNews += "11月13日0：00开始惟有爱官网关闭进行升级维护，预计所需时间为1小时，期间将暂停所有对外服务，包括网站登录、交易等，给您带来不便请见谅！";
    document.getElementById("OLUpGradeAd").innerHTML = olNews;
}
function TopCheckIsLogin() {
    var x = new AjaxRequest('XML', 'status');
    x.para = [];
    x.post('logincheck', '/ajax.aspx', function(s) {
        var xml = x.createXmlDom(s);
        var status = xml.getElementsByTagName("status")[0].firstChild.data;
        if (status == 'ok') {
            $get('OLLogin').innerHTML = "<b>[<a class=\"OLA1\" href=\"javascript:Logout();\">退出</a>]&nbsp;&nbsp;[<a class=\"OLA2\" href=\"/User/index.aspx\">进入我的惟有爱</a>]</b><em>" + xml.getElementsByTagName("username")[0].firstChild.data + "&nbsp;您好，欢迎光临惟有爱！</em>";
        }
        else {
            $get('OLLogin').innerHTML = "<b>[<a class=\"OLA1\" href=\"/User/Login.aspx\">登陆</a>] [<a class=\"OLA2\" href=\"/User/Register.aspx\">免费注册</a>]</b><em>您好，欢迎光临惟有爱！</em>";
        }
    });
}
function Logout() {

    var x = new AjaxRequest('XML', '');
    x.post('userlogout', '/ajax.aspx',
    function(s) {
        var xml = x.createXmlDom(s);
        var status = xml.getElementsByTagName("status")[0].firstChild.data;
        if (status == "ok") {
            if (xml.getElementsByTagName("API_Enable")[0].firstChild.data == "1") {
                var LogOutString = xml.getElementsByTagName("LogOutString")[0].firstChild.data;
                Loginin(LogOutString);
            }
            TopCheckIsLogin();
            if ($get("userIdentity")) {
                $get("userIdentity").style.display = "none";
            }
        }
    });
}
//----------搜索部分
function $select() {
    return document.getElementById(arguments[0]);
}
//取得外部class的属性值
function getCurrentStyle(o) {
    return o.currentStyle || document.defaultView.getComputedStyle(o, null);
}
var SetAllSelects = {
    Offset: function(e) {
        var t = e.offsetTop;
        var l = e.offsetLeft;
        var w = e.offsetWidth;
        var h = e.offsetHeight;
        while (e = e.offsetParent) { t += e.offsetTop; l += e.offsetLeft; }
        return { top: t, left: l, width: w, height: h };
    },
    setCreated: function(obj, status) {
        obj.setAttribute("childCreated", status);
    },
    getCreated: function(obj) {
        var status = obj.getAttribute("childCreated");
        if (status == null) { status = ""; }
        return status;
    },
    setSelectStyle: function(obj, idnum, showHeight) {
        if (obj.id == null || obj.id == "") { obj.id = "selectID_" + idnum; }
        var offset = this.Offset(obj);
        obj.style.visibility = "hidden";
        var mainDiv = document.createElement("div");
        var iDiv = document.createElement("div");
        var js_select_;
        var _this = this;
        iDiv.className = "iDiv";
        iDiv.id = js_select_ + obj.id;
        iDiv.style.width = offset.width + "px";
        iDiv.style.top = offset.top + "px";
        iDiv.style.left = offset.left + "px";
        this.setCreated(iDiv, "");
        mainDiv.appendChild(iDiv);
        var tValue = obj.options[obj.selectedIndex].innerHTML;
        iDiv.innerHTML = tValue;
        //iDiv.onmouseover = function() { iDiv.className = "iDiv iDiv_over"; }
        //iDiv.onmouseout = function() { iDiv.className = "iDiv iDiv_out"; }
        iDiv.onclick = function() {
            var created = _this.getCreated(this);
            if (created != "") {
                if (created == "open") {
                    this.nextSibling.style.display = "none";
                    _this.setCreated(this, "close");
                    iDiv.className = "iDiv iDiv_close";
                }
                else {
                    _this.setCreated(this, "open");
                    var arrLiObj = this.nextSibling.getElementsByTagName("li");
                    var selOjbIndex = 0;
                    for (var i = 0; i < arrLiObj.length; i++) {
                        var status = arrLiObj[i].getAttribute("liSelected");
                        if (status == null) { status = ""; }
                        if (status == "selected") { selOjbIndex = i; break; }
                    }
                    arrLiObj[selOjbIndex].style.background = "#fff7fa";
                    arrLiObj[selOjbIndex].style.color = "#000";
                    this.nextSibling.style.display = "block";
                    iDiv.className = "iDiv iDiv_open";
                }
            }
            else {
                _this.setCreated(this, "open");
                var cDiv = document.createElement("div");
                cDiv.className = "cDiv";
                //cDiv.style.width = offset.width + "px";
                cDiv.style.height = obj.options.length * 27 + "px";
                if (parseInt(cDiv.style.height) > showHeight) {
                    cDiv.style.height = showHeight + "px";
                }
                cDiv.style.top = (offset.top + parseInt(getCurrentStyle(this).height) + 1) + "px";
                cDiv.style.left = offset.left + "px";
                cDiv.onselectstart = function() { return false; };
                var uUl = document.createElement("ul");
                cDiv.appendChild(uUl);
                mainDiv.appendChild(cDiv);
                for (var i = 0; i < obj.options.length; i++) {
                    var lLi = document.createElement("li");
                    lLi.id = obj.options[i].value;
                    lLi.innerHTML = obj.options[i].innerHTML;
                    lLi.sValue = obj.options[i].value;
                    uUl.appendChild(lLi);
                }
                var liObj = uUl.getElementsByTagName("li");
                if (liObj.length > 0) {
                    for (var j = 0; j < obj.options.length; j++) {
                        liObj[j].onmouseover = function() {
                            var arrLiObj = this.parentNode.getElementsByTagName("li");
                            for (var i = 0; i < arrLiObj.length; i++) {
                                var status = "";
                                var _background = "#F06EA1";
                                var _color = "#FFFFFF";
                                if (arrLiObj[i] != this) {
                                    _background = "#fff7fa";
                                    _color = "#000";
                                    status = "selected";
                                }
                                arrLiObj[i].style.background = _background;
                                arrLiObj[i].style.color = _color;
                                arrLiObj[i].setAttribute("liSelected", status);
                            }
                        }
                        liObj[j].onclick = function() {
                            obj.options.length = 0;
                            obj.options[0] = new Option(this.innerHTML, this.sValue);
                            this.parentNode.parentNode.style.display = "none";
                            _this.setCreated(this.parentNode.parentNode.previousSibling, "close");
                            iDiv.innerHTML = this.innerHTML;
                            iDiv.className = "iDiv iDiv_close";
                        };
                        liObj[0].style.background = "#fff7fa";
                        liObj[0].style.color = "#000";
                        liObj[0].setAttribute("liSelected", "selected");
                    }
                    iDiv.className = "iDiv iDiv_open";
                }
            }
        }
        document.body.appendChild(mainDiv);
    },
    setAllSelectStyle: function() {
        var s = document.getElementsByTagName("select");
        for (var i = 0; i < s.length; i++) {
            if (s[i].className == "selectTop") {
                this.setSelectStyle(s[i], i, 2000);
                s[i].style.visibility = "hidden";
            }
        }
    }
}
document.onclick = function(e) {
    e = e || window.event;
    var target = e.target || event.srcElement;
    var s = document.getElementsByTagName("select");
    var js_select_;
    for (var i = 0; i < s.length; i++) {
        if (s[i].className == "selectTop") {
            var objdivtmp = $select(js_select_ + s[i].id);
            var created = SetAllSelects.getCreated(objdivtmp);
            if (created == "open") {
                if (target != objdivtmp) {
                    objdivtmp.nextSibling.style.display = "none";
                    SetAllSelects.setCreated(objdivtmp, "close");
                    objdivtmp.className = "iDiv iDiv_close";
                }
            }
        }
    }
}

///--------------搜索JS-----------------------------------
function keyValue(e) {
    var key = window.event ? e.keyCode : e.which;
    return key;
}
function toSearch() {
    var text = $get("inputSearch");
    if (text != null) {
        var sText = text.value.replace(/\s/g, "");
        sText = sText.replace(/&/g, "");
        if (sText.length == 0) {
            alert("抱歉，您输入的内容不在查询范围内。");
            return false;
        }

        var sText = text.value.replace(/&/g, " ");

        if (sText != '' && sText == '输入商品搜索条件，如:梦幻抱枕') {
            alert("请输入您的搜索条件");
            return false;
        } else {
            s = document.getElementsByTagName("select");
            for (var i = 0; i < s.length; i++) {
                if (s[i].className == "selectTop") {
                    searchType = s[i].options[s[i].selectedIndex].value;
                }
            }
            if (searchType == 0) {
                window.location.href = "/search-1-102-2-all-desc-" + encodeURI(sText) + ".shtml";
            } else {
                window.location.href = "/search/s.aspx?c=&f=0&wd=" + encodeURI(sText);
            }
        }
    }
}
function clearContent() {
    if ($get('inputSearch').value == "输入商品搜索条件，如:梦幻抱枕") { $get('inputSearch').value = ""; }
}
function Recover() {
    if ($get('inputSearch').value == "") { $get('inputSearch').value = "输入商品搜索条件，如:梦幻抱枕"; }
}
function checkPress(e) {
    if (keyValue(e) == 13) {
        isearch();
    }
}
//底部搜索JS
function searchProduct() {
    var keyword = document.getElementById("proKeyword").value;
    if (keyword == '' || keyword == null) {
        alert("请填写您想搜索的关键词");
        return;
    } else {
        window.open("http://www.onlylove.hk/search/s.aspx?c=2&f=0&wd=" + escape(keyword));
    }
}
//广告统计
var PageCookie = {
    Set_Cookie: function(name, value, date) {
        var exdt = new Date();
        exdt.setDate(exdt.getDate() + date);
        var path = "/";
        var site = "onlylove.hk";
        document.cookie = name + "=" + escape(value) + "; expires=" + exdt.toGMTString() + "; path=" + path + "; domain=" + site;
    },
    Get_Cookie: function(name) {
        var args = name + "=";
        var alen = args.length;
        var clen = document.cookie.length;
        var i = 0, j = 0;
        while (i < clen) {
            j = i + alen;
            if (document.cookie.substring(i, j) == args) {
                return this.Val_Cookie(j);
            }
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) {
                break;
            }
        }
        return null;
    },
    Val_Cookie: function(offset) {
        var endstr = document.cookie.indexOf(";", offset);
        if (endstr == -1) {
            endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
    },
    Del_Cookie: function(name, date) {
        var value = this.Get_Cookie(name);
        if (value != null) {
            var exdt = new Date();
            exdt.setDate(exdt.getDate() - date);
            var path = "/";
            var site = "onlylove.hk";
            document.cookie = name + "=" + escape(value) + "; expires=" + exdt.toGMTString() + "; path=" + path + "; domain=" + site;
        }
    },
    Chk_Cookie: function(name) {
        return this.Get_Cookie(name) == null ? false : true;
    }
};
if (PageCookie.Chk_Cookie("BannerADCount")) {
    PageCookie.Del_Cookie("BannerADCount", 999)
}
function httpAdsImg() {
    if (window.ActiveXObject) {
        AjaxHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        AjaxHttp = new XMLHttpRequest();
    }
}
var theTimer;
var numImage = 2;
function setTrans() {
    if (document.all) {
        $get("roll_main").filters.BlendTrans.duration = 1;
        $get("roll_main").filters.BlendTrans.apply();
    }
}
function playTrans() {
    if (document.all) {
        $get("roll_main").filters.BlendTrans.play();
    }
}
function nextImg() {
    clearTimeout(theTimer);
    numImage = numImage < 2 ? numImage + 1 : 0;
    playImg(numImage);
    theTimer = setTimeout("nextImg()", 5000);
}
function hitsImg(thisNum) {
    clearTimeout(theTimer)
    numImage = thisNum;
    playImg(numImage);
    theTimer = setTimeout("nextImg()", 5000);
}
function viewAd(adid) {
    httpAdsImg();
    var url = "/IAA/ADCount.aspx?Action=View&ADID=" + adid;
    AjaxHttp.open("GET", url, true);
    AjaxHttp.onreadystatechange = function() {
        if (AjaxHttp.readyState == 4) {
            if (AjaxHttp.status == 200) {
            }
        }
    }
    AjaxHttp.send(null);
}
function playImg(thisNum) {
    setTrans();
    $get("roll_main").innerHTML = $get("roll_image_" + thisNum).innerHTML;
    for (var i = 0; i < 3; i++) {
        if (i == thisNum) {
            $get("roll_menu_" + i).className = "roll_on";
        } else {
            $get("roll_menu_" + i).className = "roll_ou";
        }
    }
    playTrans();
    adid = $get("roll_image_" + numImage).firstChild.id.replace("ad_", "");
    if (PageCookie.Chk_Cookie("BannerADCount")) {
        var BannerADCookies = PageCookie.Get_Cookie("BannerADCount");
        if (BannerADCookies.indexOf("|" + adid + "|") == -1) {
            httpAdsImg();
            var url = "/IAA/ADCount.aspx?Action=View&ADID=" + adid;
            AjaxHttp.open("GET", url, true);
            AjaxHttp.onreadystatechange = function() {
                if (AjaxHttp.readyState == 4) {
                    if (AjaxHttp.status == 200) {
                        var NewBannerADCookies = BannerADCookies + adid + "|";
                        PageCookie.Set_Cookie("BannerADCount", NewBannerADCookies, 1);
                    }
                }
            }
            AjaxHttp.send(null);
        }
    } else {
        httpAdsImg();
        var url = "/IAA/ADCount.aspx?Action=View&ADID=" + adid;
        AjaxHttp.open("GET", url, true);
        AjaxHttp.onreadystatechange = function() {
            if (AjaxHttp.readyState == 4) {
                if (AjaxHttp.status == 200) {
                    PageCookie.Set_Cookie("BannerADCount", "|" + adid + "|", 1);
                }
            }
        }
        AjaxHttp.send(null);
    }
}
function CountClick(adid) {
    httpAdsImg();
    var url = "/IAA/ADCount.aspx?Action=Click&ADID=" + adid;
    AjaxHttp.open("GET", url, true);
    AjaxHttp.onreadystatechange = function() {
        if (AjaxHttp.readyState == 4) {
            if (AjaxHttp.status == 200) {
                //
            }
        }
    }
    AjaxHttp.send(null);
}
//tabjs
function selectTag(showContent, selfObj) {
    var tag = $get("tags").getElementsByTagName("li");
    var taglength = tag.length;
    for (var i = 0; i < taglength; i++) {
        tag[i].className = "";
    }
    selfObj.className = "tabOn";
    for (var j = 0; j < taglength; j++) {
        $get("tagCont" + j).style.display = "none";
    }
    $get(showContent).style.display = "block";
}

function showProCont(tabName) {
    var tabArr = new Array("pro_gala_", "pro_new_", "pro_hot_");
    for (var i = 0; i < 3; i++) {
        $get(tabArr[i] + "tab").style.backgroundPosition = "0 45px";
        $get(tabArr[i] + "cont").style.display = "none";
    }
    $get(tabName + "_cont").style.display = "block";
    if (tabName == "pro_new") {
        $get(tabName + "_tab").style.backgroundPosition = "0 -80px";
    } else if (tabName == "pro_hot") {
        $get(tabName + "_tab").style.backgroundPosition = "0 -80px";
    } else if (tabName == "pro_gala") {
        $get(tabName + "_tab").style.backgroundPosition = "0 -45px";
    }
}
function showTabCont(tabName) {
    if (tabName == "safe") {
        $get("safe_tab").style.backgroundPosition = "-750px -127px";
        $get("safe_tab").style.color = "#d0497e";
        $get("union_tab").style.backgroundPosition = "-850px -127px";
        $get("union_tab").style.color = "#7d7d7d";
        $get("safe_cont").style.display = "block";
        $get("union_cont").style.display = "none";
    } else {
        $get("safe_tab").style.backgroundPosition = "0 -10px";
        $get("safe_tab").style.color = "#7d7d7d";
        $get("union_tab").style.backgroundPosition = "-100px -10px";
        $get("union_tab").style.color = "#d0497e";
        $get("safe_cont").style.display = "none";
        $get("union_cont").style.display = "block";
    }
}
function selectProTab(showContent, selfObj) {
    var tag = document.getElementById("sub_tab").getElementsByTagName("li");
    var taglength = tag.length;
    for (var i = 0; i < taglength; i++) {
        tag[i].className = "";
    }
    selfObj.className = "liOn";
    for (var j = 0; j < taglength; j++) {
        document.getElementById("subCont" + j).style.display = "none";
    }
    document.getElementById(showContent).style.display = "block";
}
function selectNewsTab(showContent, selfObj) {
    var tag = document.getElementById("news_tab").getElementsByTagName("li");
    var taglength = tag.length;
    for (var i = 0; i < taglength; i++) {
        tag[i].className = "";
    }
    selfObj.className = "liOn";
    for (var j = 0; j < taglength; j++) {
        document.getElementById("newsCont" + j).style.display = "none";
    }
    document.getElementById(showContent).style.display = "block";
}
function selectLinkTab(showContent, selfObj) {
    var tag = document.getElementById("linkTab").getElementsByTagName("li");
    var taglength = tag.length;
    for (var i = 0; i < taglength; i++) {
        tag[i].className = "";
    }
    selfObj.className = "LinkOn";
    for (var j = 0; j < taglength; j++) {
        document.getElementById("linkCont" + j).style.display = "none";
    }
    document.getElementById(showContent).style.display = "block";
}

//顶部弹出层JS
var ctrlobjclassName;
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);
var jsmenu = new Array();
jsmenu['active'] = new Array();
jsmenu['timer'] = new Array();
jsmenu['iframe'] = new Array();
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 isUndefined(variable) {
    return typeof variable == 'undefined' ? true : false;
}
function getPopuID(id) {
    return document.getElementById(id);
}
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('hidePopu(' + 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 showPopu(this.id, true);
                } else {
                    hidePopu(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('hidePopu(' + layer + ')', timeout);
                }
            }
        }
        menuobj.style.zIndex = 50;
        if (is_ie) {
            menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#CCCCCC,strength=2)";
        }
    }
}
function showPopu(ctrlid, myPosX, myPosY, click, offset, duration, timeout, layer, showid, maxh, containerid) {
    e = window.event ? window.event : showPopu.caller.arguments[0];
    var ctrlobj = getPopuID(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 = getPopuID(showid);
    var menuobj = getPopuID(showid + '_menu');
    if (!showobj || !menuobj) return;
    if (isUndefined(maxh)) maxh = 400;
    hidePopu(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)';
    }
    setPopuPosition(showid, offset, containerid, myPosX, myPosY);
    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 {
                getPopuID('append_parent').appendChild(iframe);
            }
            catch (e) {
            }
            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('hidePopu(' + layer + ')', timeout);
    }

    jsmenu['active'][layer] = menuobj;
}
function setPopuPosition(showid, offset, containerid, myPosX, myPosY) {
    var showobj = getPopuID(showid);
    var menuobj = getPopuID(showid + '_menu');
    var container = getPopuID(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 + myPosX + 'px' : showobj.X + myPosY + 'px';
        menuobj.style.left = showobj.X + showobj.w - menuobj.w + myPosX + '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) - myPosX + 'px' : showobj.Y + showobj.h - myPosY + 'px');
        if (menuobj.style.clip && !is_opera) {
            menuobj.style.clip = 'rect(auto, auto, auto, auto)';
        }
    }
}
function hidePopu(layer) {
    if (isUndefined(layer)) layer = 0;
    if (jsmenu['active'][layer]) {
        try {
            getPopuID(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 popuoption_onclick_function(e) {
    this.clickfunc();
    hidePopu();
}
function popuoption_onclick_link(e) {
    choose(e, this);
}
function popuoption_onmouseover(e) {
    this.className = 'popupmenu_highlight';
}
function popuoption_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();
            }
        }
        hidePopu();
    }
}
function setBubble(showid, tipname) {
    var menuobj = getPopuID(showid + '_menu');
    menuobj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
    menuobj.style.opacity = 0;

    _attachEvent(window, 'load', function() { initBubble(showid, tipname) });
    _attachEvent(window, 'resize', function() { initBubble(showid, tipname, true) });
}
function initBubble(showid, tipname, onresize) {
    var menuid = showid + "_menu";


    var showobj = getPopuID(showid);
    var menuobj = getPopuID(showid + '_menu');
    var offset = 0;
    if (showobj) {
        showobj.pos = fetchOffset(showobj);
        showobj.X = showobj.pos['left'];
        showobj.Y = showobj.pos['top'];
        showobj.w = showobj.offsetWidth;
        showobj.h = showobj.offsetHeight;
        if (menuobj.style.display == 'none') {
            menuobj.style.visibility = 'hidden';
            menuobj.style.display = '';
            menuobj.w = menuobj.offsetWidth;
            menuobj.h = menuobj.offsetHeight;
            menuobj.style.visibility = 'visible';
            menuobj.style.display = 'none';
        } else {
            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.left = showobj.X + showobj.w - menuobj.w + '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)';
        }
    }
    getPopuID(menuid).style.top = parseInt(getPopuID(menuid).style.top) - menuobj.h - 18 + 'px';
    getPopuID(menuid).style.left = parseInt(getPopuID(menuid).style.left) + 5 + 'px';
    getPopuID(menuid).style.height = menuobj.h;

    menuobj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    menuobj.style.opacity = 1;

    if (typeof onresize != 'undefined' && onresize === true)
        return;
    if (getcookie('discuz_tips_' + tipname) == "1") {
        menuobj.style.display = 'none';
    } else {
        setTimeout('display_opacity(\'' + menuid + '\',100)', 8000);
        setcookie('discuz_tips_' + tipname, 1, 365 * 24 * 60 * 60);
    }

}
///结束