function g(Dom) {
    return document.getElementById(Dom);
}
$(document).ready(function() {
    $(".B21,.B24").each(function(i) {
        $(this).click(function() {
            var obj = $(this).clone();
            var offset = $(this).offset();
            $(".B23").remove();
            obj.addClass("B23").removeClass('B24').removeClass('B21');
            obj.find(".B211 img")[0].src=StylePath + "/Images/"+i+'_b.gif';
            obj.css({ "left": offset.left - 5 + 'px', "top": offset.top + 'px' });
            $("body").append(obj);
            obj.show();
        });
    });
    //展开回复
    $(".C22412").each(function(i) {
        $(this).click(function() {
            if ($(".C228").eq(i).css('display') == 'none') {
                $(".C228").eq(i).show();
                $(".C22411 img").get(i).src = StylePath + '/Images/hf2.jpg';
                SetWinHeight(parent.document.getElementById("tb_iframe"));
            } else {
                $(".C228").eq(i).hide();
                $(".C22411 img").get(i).src = StylePath + '/Images/hf1.jpg';
                SetWinHeight(parent.document.getElementById("tb_iframe"));
            }
        });
    });
    //展开更多回复
    /*$(".C228 a").each(function(i) {
        $(this).click(function() {
            if ($(".C228_hide").eq(i).css('display') == 'none') {
                $(".C228_hide").eq(i).show();
                $(this).html("隐藏更多回复");
            } else {
                $(".C228_hide").eq(i).hide();
                $(this).html("展示更多回复");
            }
        });
    });
	*/
    //显示我来说说
    $(".C227").each(function(i) {
        $(this).click(function() {
        $(".divShow").hide();
            var left = $(this).offset().left - 230;
            var top = $(this).offset().top + 20;
            var hh = top - getyScrolltop() + $(".divShow").eq(i).height();
            if (document.documentElement.clientHeight < hh) {
                $(".divShow").eq(i).css({ "left": left + 'px', "top": top - $(".divShow").eq(i).height() + 'px' });
            } else {
                $(".divShow").eq(i).css({ "left": left + 'px', "top": top + 'px' });
            }
            $(".divShow").eq(i).show();
        });
    });
    $(".divShow .Close").click(function() {
        $(".divShow").hide();
    });
    $(".DS32 img").click(function() {
        $(".divShow").hide();
    });
    //活动信息页面的回复显示
    //展开回复
    $(".D22412").each(function(i) {
        $(this).click(function() {
            if ($(".D228").eq(i).css('display') == 'none') {
                $(".D228").eq(i).show();
                $(".D22411 img").get(i).src = StylePath + '/Images/hf2.jpg';
                SetWinHeight(parent.document.getElementById("tb_iframe"));
            } else {
                $(".D228").eq(i).hide();
                $(".D22411 img").get(i).src = StylePath + '/Images/hf1.jpg';
                SetWinHeight(parent.document.getElementById("tb_iframe"));
            }
        });
    });
    //展开更多回复
    /*$(".D228 a").each(function(i) {
        $(this).click(function() {
            if ($(".D228_hide").eq(i).css('display') == 'none') {
                $(".D228_hide").eq(i).show();
                $(this).html("隐藏更多回复");
            } else {
                $(".D228_hide").eq(i).hide();
                $(this).html("展示更多回复");
            }
        });
    });
	*/
    //显示我来说说
    $(".D227").each(function(i) {
        $(this).click(function() {
        $(".divShow").hide();
            var left = $(this).offset().left - 230;
            var top = $(this).offset().top + 20;
            var hh = top - getyScrolltop() + $(".divShow").eq(i).height();
            if (document.documentElement.clientHeight < hh) {
                $(".divShow").eq(i).css({ "left": left + 'px', "top": top - $(".divShow").eq(i).height() + 'px' });
            } else {
                $(".divShow").eq(i).css({ "left": left + 'px', "top": top + 'px' });
            }
            $(".divShow").eq(i).show();
        });
    });
    $(".divShow .Close").click(function() {
        $(".divShow").hide();
    });
    $(".DS32 img").click(function() {
        $(".divShow").hide();
    });
    //显示获取积分层
    $(".D231 a").eq(1).click(function() {
        var left = $(this).offset().left - 270;
        var top = $(this).offset().top + 80;
        var hh = top - getyScrolltop() + $(".divScore", parent.document).height();
        if (document.documentElement.clientHeight < hh) {
            $(".divScore", parent.document).css({ "left": left + 'px', "top": top - $(".divScore").height() + 'px' });
        } else {
            $(".divScore", parent.document).css({ "left": left + 'px', "top": top + 'px' });
        }
        addoverlay(true);
        $(".divScore", parent.document).show();
    });
    //$(".divScore").hide();
    $("#a_jf").click(function() {
        var left = $(this).offset().left - 270;
        var top = $(this).offset().top + 80;
        var hh = top - getyScrolltop() + $(".divScore", parent.document).height();
        if (document.documentElement.clientHeight < hh) {
            $(".divScore", parent.document).css({ "left": left + 'px', "top": top - $(".divScore").height() + 'px' });
        } else {
            $(".divScore", parent.document).css({ "left": left + 'px', "top": top + 'px' });
        }
        addoverlay(true);
        $(".divScore", parent.document).show();
    });
    $(".divScore .Close").click(function() {
        $(".divScore").hide();
        closeOverlay(true);
    });
    $(".C8 ul li img").each(function(i) {
        $(this).css({ "margin-top": parseInt((68 - $(this).height()) / 2) + 'px', "margin-left": parseInt((68 - $(this).width()) / 2) });
        $(".C8 ul li").eq(i).click(function() {
            $(".C8 ul li").css({ "border-color": "#E1E1E1" });
            $(".C8 ul li").eq(i).css({ "border-color": "#FFF9E5" });
        });
    });
    if (g('mycarousel')) {
        $('#mycarousel').jcarousel({
            scroll: 1
        });
    }
    //疯狂抢购
    $(".C2_tab").eq(0).show();
    $(".C1_tab div").each(function(i) {
        $(this).click(function() {
            if ($(this).attr("class") == "C12") {
                $(".C11").removeClass("C11").addClass("C12");
                $(this).addClass("C11").removeClass("C12");
                if (i == 1) {
                    $(this).css({ "margin-left": "20px" });
                    $(".C12").css({ "margin-left": "0px" });
                }
                $(".C2_tab").hide();
                $(".C2_tab").eq(i).show();
            }
        });
    });
    $(".H").css({ "height": $(".Middle").height() + 'px' });
    //商家活动信息选项卡
    $(".D1_tab1 div").each(function(i) {
        $(this).click(function() {
            if (this.className == 'nor') {
                $(".D1_tab1 .act").removeClass("act").addClass("nor");
                this.className = 'act';
                $(".D2_tab1").hide();
                $(".D2_tab1").eq(i).show();
                //showDiv();
            }
        });
    });
    $(".D2_tab1").eq(0).show();
    //显示价格设置
    $("#Dv1_Set,#Dv2_Set").click(function() {
        var left = $(this).offset().left;
        var top = $(this).offset().top + 20;
        var hh = top - getyScrolltop() + $(".DivPrice").height();
        $(".DivPrice").css({ "left": left + 'px', "top": '10px' });
        $(".DivPrice").show();
        addoverlay();
    });
    $(".DivPrice .Close").click(function() {
        $(".DivPrice").hide();
        closeOverlay();
    });
}); 