$("document").ready(function(){
    ProChange();
    ProBTabChange();
    TabChange("ProDesTab","ProDesCon","d_t_current","d_t_active");
    $('#hardcopy_word').qtip({
        content: {
            url: '/hardcopy_tip.html'
        },
        show: 'mouseover',
        hide: 'unfocus',
        position: {
            corner: {
                target: 'rightMiddle',
                tooltip: 'leftMiddle'
            }
        },
        style: {
            width: 300,
            border: {
                width: 1,
                radius: 2
            },
            tip:true,
            padding: 5,
            textAlign: 'left',
            name: 'cream' // Style it according to the preset 'cream' style
        }
    });
    $(".star_rating").each(function(){
        $(this).children("li").each(function(){
            $(this).click(function(){
                $(this).parent().children("li").unbind( "click" );
                var star_local = $(this).attr("id");
                $(this).parent().attr("class","star_rating "+star_local+"star");
                alert("Your rating result has been submitted. Thank you for concerning our site and products.");
            //alert($(this).parent().attr("class"));
            });
        });
    });
});
function hardcopy_select(Obj){
    var product_type = $(Obj).attr("alt");
    var software_id;
    var hardcopy_id
    if($(Obj).attr('checked')==true){
        software_id = $("#" + product_type + "_software").val();
        hardcopy_id = $("#" + product_type + "_hardcopy").val();
        $("#" + product_type + "_addtocart").val(software_id + "," + hardcopy_id);
        $("#" + product_type + "_checkout").val(software_id + "," + hardcopy_id);
    }else{
        software_id = $("#" + product_type + "_software").val();
        $("#" + product_type + "_addtocart").val(software_id);
        $("#" + product_type + "_checkout").val(software_id);
    }
}
/*
 * 多产品背景切换
 */
function ProChange(){
    $("#ProList").children().mouseover(
        function(){
            $("#ProList").children().removeClass("es_exams x_hover");
            $("#ProList").children().addClass("es_exams");
            $(this).addClass("es_exams x_hover");
        }
        );
}

/*
 * 产品页底部标签切换
 */
function ProBTabChange(){
    var tab_index;
    var tabs;
    var nowtab;
    var h;
    tabs = $("#ProBTab").children();
    if($("#ProBTab").children().length < 2){
        return false;
    }
    tabs.click(
        function(){
            nowtab = $(this);
            tab_index=nowtab.prevAll().length;
            tabs.removeClass("reviews_f");
            tabs.addClass("vis");
            nowtab.removeClass("vis");
            nowtab.addClass("reviews_f");

            for(var i=0;i<2;i++){
                h=$("#ProBTab").children().eq(i);
                h.children().eq(0).removeClass("r1");
                h.children().eq(1).removeClass("r3");
                h.children().eq(2).removeClass("current_hover");
                h.children().eq(0).addClass("vi_f1");
                h.children().eq(1).addClass("vi_f2");
                h.children().eq(2).addClass("vis_titl");
            }
            nowtab.children().eq(0).removeClass("vi_f1");
            nowtab.children().eq(1).removeClass("vi_f2");
            nowtab.children().eq(2).removeClass("vis_titl");
            nowtab.children().eq(0).addClass("r1");
            nowtab.children().eq(1).addClass("r3");
            nowtab.children().eq(2).addClass("current_hover");
           
            $("#ProBCon").children().hide();
            $("#ProBCon").children().eq(tab_index).show();
        }
        );
}
function product_show_more(Obj){
    $(Obj).parent().parent().next().next().show();
}

function Chrismas(sortsnum){
    $.post(
        "/ajax/chrismas/",
        {
            sortsnum:sortsnum
        },
        function(flag){
            $("#ChrismasPrice").html(flag);
        },
        "html"
        )
}