$("document").ready( function() { TabChange();CatDetailShow(); });
function TabChange(){
    var tab_index;
    var tabs;
    var nowtab;
    var h;
    tabs = $("#CatTab").children();
    tabs.click(
        function(){
            nowtab = $(this);
            tab_index=nowtab.prevAll().length;
            tabs.removeClass("comTIA_f");
            tabs.addClass("comTIA_vis");
            nowtab.removeClass("comTIA_vis");
            nowtab.addClass("comTIA_f");

            for(var i=0;i<6;i++){
                h=$("#CatTab").children().eq(i);
                h.children().eq(0).removeClass("comTIA_f1");
                h.children().eq(1).removeClass("comTIA_f2");
                h.children().eq(2).removeClass("comTIA_current_hover");
                h.children().eq(0).addClass("vi_f1");
                h.children().eq(1).addClass("vi_f2");
                h.children().eq(2).addClass("comTIA_vis_titl");
            }
            nowtab.children().eq(0).removeClass("vi_f1");
            nowtab.children().eq(1).removeClass("vi_f2");
            nowtab.children().eq(2).removeClass("comTIA_vis_titl");
            nowtab.children().eq(0).addClass("comTIA_f1");
            nowtab.children().eq(1).addClass("comTIA_f2");
            nowtab.children().eq(2).addClass("comTIA_current_hover");

            $("#CatCon").children().hide();
            $("#CatCon").children().eq(tab_index).show();
        }
        );
}

function CatDetailShow(){
    $("#CatDetail").children().mouseover(
        function(){
            $("#CatDetail").children().removeClass("comTIA_exam_per co_current");
            $("#CatDetail").children().addClass("comTIA_exam_per co_next");
            $(this).removeClass("comTIA_exam_per co_next");
            $(this).addClass("comTIA_exam_per co_current");

            $(this).click(
                function(){
                    $(".comptiashowif").hide();
                    $(this).children().eq(2).show();
                }
            );
        }
    );
}

function CatTotal(cat){
    var proid;
    var price;
    var total=0;
    var proids="";
    $("input[name*='"+cat+"']").each(
        function(){
            proid = $(this).attr("value");
            price = parseFloat($("#Pro_"+proid).html());
            if($(this).attr("checked") == true){
                total = total + price;
                proids = proids + proid + ",";
            }
        }
    );
    total = (Math.round(total*100)/100);
    proids = proids.substring(0,(proids.length-1));
    if(total>0){
        $("#CheckButton_"+cat).val(proids);
        $("#Total_"+cat).html(total);
        $("#Check_"+cat).show();
    }else{
        $("#Check_"+cat).hide();
    }
}

function linkshow(param){
    $(".comptiashowif").hide();
    $("#"+param).children().eq(2).show();
    $('html,body').animate({
        scrollTop: 500
    }, 1000);
    
}
