﻿function getLeftPx(objectWidth) { var pageWidth = parseInt(document.body.clientWidth); return parseInt((pageWidth - objectWidth) / 2) } function getTopPx(topPx) { var h = parseInt($u.getScrollTop(document)); return parseInt(h + topPx) }
function correctPNG() {
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;" + img.style.cssText;
            if (img.align == "left") imgStyle = "float:left;" + imgStyle;
            if (img.align == "right") imgStyle = "float:right;" + imgStyle;
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
            var strNewHTML = "<span " + imgID + imgClass + " style=\"width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src='" + img.src + "', sizingMethod='scale');\"></span>";
            img.outerHTML = strNewHTML;
            i = i - 1;
        }
    }
}
if (Lei.browser.msie6) {
    document.execCommand("BackgroundImageCache", false, true);
}
function MenuDiv(id, obj) {
    MenuDivHide();
    if ($id("MenuDiv" + id)) {

        $id("MenuDiv" + id).style.display = "";
    }
    else {
        var div = document.createElement("div");
        div.id = "MenuDiv" + id;
        div.className = "MenuDiv" + id;
        if (id == 1) {
            div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/main_btn_over_03.png\"/></a>";
        } else if (id == 6) {
            div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/minishop_over_01.png\"/></a>";
        }
        else if (id == 2) {
            div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/main_btn_over_05.png\"/></a><div class=\"MenuDivTop\"></div><div class=\"MenuDivMid\">"+$id("MenuDivA2").innerHTML+"</div><div class=\"MenuDivBtn\"></div>";
        }
        else if (id == 3) {
        div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/main_btn_over_07.png\"/></a><div class=\"MenuDivTop\"></div><div class=\"MenuDivMid\">" + $id("MenuDivA3").innerHTML + "</div><div class=\"MenuDivBtn\"></div>";
        }
        else if (id == 4) {
        div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/main_btn_over_09.png\"/></a><div class=\"MenuDivTop\"></div><div class=\"MenuDivMid\">" + $id("MenuDivA4").innerHTML + "</div><div class=\"MenuDivBtn\"></div>";
        }
        else if (id == 5) {
        div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/minishop_over_04.png\"/></a><div class=\"MenuDivTop\"></div><div class=\"MenuDivMid\">" + $id("MenuDivA5").innerHTML + "</div><div class=\"MenuDivBtn\"></div>";
    }
    else if (id == 7) {
        div.innerHTML = "<a href=\"" + obj.href + "\"><img src=\"/static/images2/minishop_over_03.png\"/></a><div class=\"MenuDivTop\"></div><div class=\"MenuDivMid\">" + $id("MenuDivA5").innerHTML + "</div><div class=\"MenuDivBtn\"></div>";
    }
        div.onmouseover = function() { this.style.display = ""; }
        div.onmouseout = function() { MenuDivOut(id); }
        document.body.appendChild(div);

    }
    var topNum = 10;
    if (Lei.browser.msie8) {
        topNum = 32;
    }
    if (Lei.browser.msie9) {
        topNum = 33;
    }
    if (Lei.browser.mozilla) {
        topNum = 20;
    }
    $id("MenuDiv" + id).style.left = Lei.Utils.getObjectPos(obj).left - 13 + "px";
    $id("MenuDiv" + id).style.top = Lei.Utils.getObjectPos(obj).top - topNum + "px";
    if (Lei.browser.msie6) {
        correctPNG();
    }
}
function MenuDivOut(id) {
    if ($id("MenuDiv" + id)) {
        $id("MenuDiv" + id).style.display = "none";
    }
}
function MenuDivHide() {
    for (var id = 1; id < 8; id++) {
        if ($id("MenuDiv" + id)) {
            $id("MenuDiv" + id).style.display = "none";
        }
    }
}
var Request = {
QueryString: function(item) {
    var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
    return svalue ? svalue[1] : svalue;
}
 }
function Sort(v) 
{
    var l = window.location.href;
    if (l.indexOf("sort=") > 0) {
        l = l.replace(/(sort=\w*)/, function(a) {
            return "sort=" + v;
        });

        location.href = l;
    }
    else {
        if (l.indexOf("?") > 0) {
            location.href = l + "&sort=" + v;
        }
        else {
            location.href = l + "?sort=" + v;
        }
    }
}
