﻿$(function () {

    $("a.manualOrder, #CardList li a, #HowMuch").hover(function () {
        $(".extraContentWrapper", this).toggleClass("active");
    });

    $(".compareTable tbody tr td:last").addClass("last");

    $(".compareTable tbody:not('.active')").hide();
    $(".compareTable thead").click(function () {
        if ($(this).hasClass("active")) {
            $(this).next("tbody").slideUp();
            $(this).removeClass("active");
        } else {
            $("tbody").slideUp().siblings().removeClass("active");
            $(this).next("tbody").slideDown();
            $(this).addClass("active");
        }
    });

    $("#CardFilter li").click(function () {
        var cards = $("a", this).attr("href").substr(1);
        $("#CardListAll > li").show();
        if (cards != "alle") {
            $("#CardListAll li:not(." + cards + ")").hide();
        }
    });

    $(".compareLink").click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        if ($("#CardListAll input:checked").length < 2) {
            alert("Du må velge minst 2 kort");
            return false;
        }

        var url = $(this).attr("href") + "?cards=";
        $("#CardListAll input:checked").each(function () {
            url += $(this).attr("id").replace("card-", "") + ",";
        });
        location.href = url;
    });

});

