
$(document).ready(function() {


    //购物车-收货信息//
    $("ul.addr_list :radio").mousedown(function() {
        $("ul.addr_list :radio").nextAll("a.action").hide();
        $(this).nextAll("a.action").show();
    })

    //试用专区切换
    $("ul.free_tab li").click(function() {
        var num = $("ul.free_tab li").index(this);
        $("ul.free_tab li").removeClass("curr");
        $("ul.free_tab li").removeClass("currL")
        if (num == 4) {
            $(this).addClass("currL");
        } else {
            $(this).addClass("curr");
        }
        $(".free_content").hide();
        $(".free_content").eq(num).show();
    })

    //表格鼠标滑过变色
    if ($(".record_tbl").size != 0) {
        var tblSum = $(".record_tbl").length;
        for (i = 0; i < tblSum; i++) {
            var trSum = $(".record_tbl").eq(i).find("tr").length;
            var trObj = $(".record_tbl").eq(i).find("tr");
            for (j = 1; j < trSum; j++) {
                trObj.eq(j).mouseover(function() {
                    $(this).addClass("curr");
                })
                trObj.eq(j).mouseout(function() {
                    $(this).removeClass("curr");
                })
            }
        }

    }

    //鼠标滑过商品名 显示商品图
    if ($(".record_tbl td.name").size != 0) {
        $(".record_tbl td.name a").mouseover(function() {
            $(this).next("img.goods_pic").animate({ opacity: "100%" }, 0);
        })
        $(".record_tbl td.name a").mouseout(function() {
            $(this).next("img.goods_pic").animate({ opacity: "0%" });
        })

        ////团购占座
        $(".seat_area li img").mouseover(function() {
            $(this).next(".seat_tips").show();
            if ($(this).attr("src") == "../images/sofa_off.gif") {
                $(this).attr("src", "../images/sofa_on.gif");
            } else if ($(this).attr("src") == "../images/seat_off.gif") {
                $(this).attr("src", "../images/seat_on.gif");
            }
        })
        $(".seat_area li img").mouseout(function() {
            $(this).next(".seat_tips").hide();
            if ($(this).attr("src") == "../images/sofa_on.gif") {
                $(this).attr("src", "../images/sofa_off.gif");
            } else if ($(this).attr("src") == "../images/seat_on.gif") {
                $(this).attr("src", "../images/seat_off.gif");
            }
        })
        $(".seat_area .seat_tips").mouseover(function() {
            $(this).show();
        })
        $(".seat_area .seat_tips").mouseout(function() {
            $(this).hide();
        })

        ////团购下单填写地址
        $("span.show_addr").click(function() {
            $("tr.addr_more").toggle();
            var isIE = !!window.ActiveXObject;
            var isIE6 = isIE && !window.XMLHttpRequest;
            if (isIE6) {
                $("tr.addr_more select").toggle();
            }
        })

    }

    ////团购答疑-我要提问
    $(".group_QAlist a#ask_btn").click(function() {
        $("ul.group_ask").toggle();
    })
    $(".group_ask a#ask_cancel").click(function() {
        $("ul.group_ask").hide();
    })

    ////团购答疑-列表颜色区分
    if ($(".gQA_list").size != 0) {
        $(".gQA_list ul.item:odd").addClass("item_gray");
    }

    //初始化页面
    //InitPageHeadLoginInfo();

    //试用专区切换
    $("ul.free_tab li").click(function() {
        var num = $("ul.free_tab li").index(this);
        $("ul.free_tab li").removeClass("curr");
        $("ul.free_tab li").removeClass("currL")
        if (num == 4) {
            $(this).addClass("currL");
        } else {
            $(this).addClass("curr");
        }
        $(".free_content").hide();
        $(".free_content").eq(num).show();
    })
    
    ////导航二级菜单
    $("ul.nav li.C2_tit").mouseover(function() {
        $(this).children(".vice_nav").show();
        $(this).children("h2").children("a").addClass("curr");
    })
    $("ul.nav li.C2_tit").mouseout(function() {
        $(this).children(".vice_nav").hide();
        $(this).children("h2").children("a").removeClass("curr");
    })
    
    
});


//首页焦点图切换
var k = 4; //图片总数-1
var img_total = 4; //图片总数-1
//自动播放
function rdl_play() {
    if (k < img_total) {
        k++;
    } else { k = 0; }
    $("ul.focus_pic").hide();
    $("ul.focus_pic").eq(k).show();
    $("div.focus_index span").html("<img src='images/point_flash_off.gif' />");
    $("div.focus_index span").eq(k).html("<img src='images/point_flash_on.gif' />");
    a = setTimeout("rdl_play()", 8000);
}
//鼠标停留和离开
function rdl_stop() {
    clearTimeout(a);
}
function rdl_goon() {
    a = setTimeout("rdl_play()", 8000);
}
//鼠标滑过数字，显示对应图片
function rdl_goto(num) {
    clearTimeout(a);
    k = num;
    $("ul.focus_pic").hide();
    $("ul.focus_pic").eq(k).show();
    $("div.focus_index span").html("<img src='images/point_flash_off.gif' />");
    $("div.focus_index span").eq(k).html("<img src='images/point_flash_on.gif' />");
}
window.onload = rdl_play;


//焦点图左侧新闻切换
function show_news(obj, num) {
    $("dl.news dt.tab b").removeClass("curr");
    $(obj).addClass("curr");
    $("dl.news dd.tab_content").hide();
    $("dl.news dd.tab_content").eq(num).show();
}

//用户中心-我的消息//
function show_msg(obj) {
    obj = "#" + obj;
    $(obj).toggle();
}

//商品详细页详情切换
function show_detail(num) {
    $("div.detail_tab b").removeClass("curr");
    //$(obj).addClass("curr");
    $("div.detail_tab b").eq(num).addClass("curr");
    $(".detail_content").hide();
    $(".detail_content").eq(3).show();
    $(".detail_content").eq(num).show();
    if (num == 1 || num == 2) {
        $(".detail_content").eq(num).children(".comment_connent").show();
        $(".detail_content").eq(num).children(".comment_go").hide();
    }
}

function show_com(num) {
    $(".detail_content").eq(num).children(".comment_connent").hide();
    $(".detail_content").eq(num).children(".comment_go").show();
}
function hide_com(num) {
    $(".detail_content").eq(num).children(".comment_connent").show();
    $(".detail_content").eq(num).children(".comment_go").hide();
}




//判断是否有ajax在执行
var isHaveAjaxStatus = false;
//判断是否ajax检查通过
var isAjaxCheckStatus = false;
//Ajax执行等待时间
var waitAjaxTime = 0;


var ajaxCustomerUrl = "../AjaxService/Customer.aspx";

function InitPageHeadLoginInfo() {
    isHaveAjaxStatus = true;
    bohinetAjaxWholeUrlPost(ajaxCustomerUrl, "action=getlogincustomer", null, CallBack);
    function CallBack(returnVaule) {
        var WelcomeStr = "您好，欢迎光临乌衣巷！";
        if (GetKeyValueFromCombineStr(ajaxSuccess, returnVaule) != ajaxNoResult) {
            var CustomerIDStr = GetKeyValueFromCombineStr("CustomerID", returnVaule);
            if (CustomerIDStr != "") {
                WelcomeStr = "欢迎 " + CustomerIDStr + " 光临乌衣巷！ <a href='#'>[退出登录]</a>";
                $("#welcome").next("a").hide();
                $("#welcome").next("a").next("span").hide();
                $("#welcome").next("a").next("span").next("a").hide();
            }
        }

        $("#welcome").html(WelcomeStr);
        $("#welcome").find("a").bind("click", function() { CustomerLoginOut(); });
        isHaveAjaxStatus = false;


    }
}


function CustomerLoginOut() {
    if (confirm('您确定退出登录？')) {
        isHaveAjaxStatus = true;
        bohinetAjaxWholeUrlPost(ajaxCustomerUrl, "action=loginoutcustomer", null, CallBack);
    }
    function CallBack(returnVaule) {
        alert(returnVaule);
        if (GetKeyValueFromCombineStr(ajaxSuccess, returnVaule) != ajaxNoResult) {
            var WelcomeStr = "您好，欢迎光临乌衣巷！";
            $("#welcome").html(WelcomeStr);
            $("#welcome").next("a").show();
            $("#welcome").next("a").next("span").show();
            $("#welcome").next("a").next("span").next("a").show();
        }
        isHaveAjaxStatus = false;
    }
}

//弹出窗口
function ShowBohinet(URL, Width, Height, top, left) {
    //window.open('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')
    window.open(URL, '', 'width=' + Width + ',height=' + Height + ', top=' + top + ', left=' + left + ', resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no');
}

//商品评论里的星星滑过效果
function choose_stars(index, num) {

    for (i = 0; i < 5; i++) {
        if (i < num + 1) {
            document.getElementById("stars_td" + index).getElementsByTagName("img")[i].src = "../images/mul_starOn.gif";
        } else {
            document.getElementById("stars_td" + index).getElementsByTagName("img")[i].src = "../images/mul_starOff.gif";
        }
        switch (num) {
            case 0: document.getElementById("stars_num_td" + index).innerHTML = num + 1 + "Star&nbsp;&nbsp;差"; break;
            case 1: document.getElementById("stars_num_td" + index).innerHTML = num + 1 + "Star&nbsp;&nbsp;一般"; break;
            case 2: document.getElementById("stars_num_td" + index).innerHTML = num + 1 + "Star&nbsp;&nbsp;较好"; break;
            case 3: document.getElementById("stars_num_td" + index).innerHTML = num + 1 + "Star&nbsp;&nbsp;好"; break;
            case 4: document.getElementById("stars_num_td" + index).innerHTML = num + 1 + "Star&nbsp;&nbsp;很好"; break;
        }
    }
}

	
	
	
	
	
	
	
	
	
	
	
	
	
	


