﻿// User actions
$(document).ready(function () {

    $("#koerekort_box").hide();
    $("#varetrin_box").hide();
    $("#varevaegt_box").hide();
    $("#preamieClassic").hide();
    $("#ansvarkasko_box").hide();
    $("#gender_box").hide();


    // Alder
    $("#txtalder").blur(function () {
        var _alder = $("#txtalder").val();
        if (parseInt(_alder) < 25) {
            $("#koerekort_box").show("slow");
        }
        else {
            $("#koerekort_box").hide("slow");
        }
    });

    // Ansvar - Kasko
    $("input[name='ansvarkasko']").click(function () {
        if ($("input[name='ansvarkasko']:checked").val() == '1') {
            // Kasko
            $("#ansvarkasko_box").hide("slow");
        }
        else if ($("input[name='ansvarkasko']:checked").val() == '0') {
            // Ansvar
            $("#ansvarkasko_box").show("slow");
        }
    });

    // Person - Varevogn
    $("input[name='type']").click(function () {
        if ($("input[name='type']:checked").val() == '0') {
            $("#trin_box").show("slow");
            $("#varetrin_box").hide("slow");
            $("#vaegt_box").show("slow");
            //$("#varevaegt_box").hide("slow");
            $("#selvrisiko_box").show("slow");
            $("#hk_box").show("slow");
            $("#friskade_box").show("slow");
        }
        else if ($("input[name='type']:checked").val() == '1') {
            $("#trin_box").hide("slow");
            $("#varetrin_box").show("slow");
            $("#vaegt_box").hide("slow");
            //$("#varevaegt_box").show("slow");
            $("#selvrisiko_box").hide("slow");
            $("#hk_box").hide("slow");
            $("#friskade_box").hide("slow");
        }
    });

    // DAF jubilæum
    //    $("#txtalder").blur(function () {
    //        // Tjek alder
    //        var _alder = $("#txtalder").val();
    //        if (parseInt(_alder) > 35) {
    //            var el = $('#PriceOptions');
    //            el.html(el.html().replace('##procent##', '15%'));
    //        }
    //        else {
    //            var el = $('#PriceOptions');
    //            el.html(el.html().replace('##procent##', '10%'));
    //        }

    //        // Tjek trin
    //        if ($("input[name='premietrin']:checked").val() > '1' && $("input[name='premietrin']:checked").val() < '4' && ($("input[name='vaegt']:checked").val() < '1200')) {
    //            $('#PriceOptions :input').attr('disabled', false);
    //        }
    //        else {
    //            $('#PriceOptions :input[id^=rbDafJubiTrin]:radio').attr('disabled', true);
    //            $('#PriceOptions :input[id^=rbDafJubiRabat]:radio').attr('checked', true);
    //        }
    //   });
    $("input[name='vaegt']").click(function () {
        // Tjek trin
        if (($("input[name='premietrin']:checked").val() > '1' && $("input[name='premietrin']:checked").val() < '4') && (($("input[name='vaegt']:checked").val() == '0') || ($("input[name='vaegt']:checked").val() == '801') || ($("input[name='vaegt']:checked").val() == '1001'))) {
            $('#PriceOptions :input').attr('disabled', false);
        }
        else {
            $('#PriceOptions :input[id^=rbDafJubiTrin]:radio').attr('disabled', true);
            $('#PriceOptions :input[id^=rbDafJubiRabat]:radio').attr('checked', true);
        }
    });
    $("input[name='premietrin']").click(function () {
        // Tjek trin
        if (($("input[name='premietrin']:checked").val() > '1' && $("input[name='premietrin']:checked").val() < '4') && (($("input[name='vaegt']:checked").val() == '0') || ($("input[name='vaegt']:checked").val() == '801') || ($("input[name='vaegt']:checked").val() == '1001'))) {
            $('#PriceOptions :input').attr('disabled', false);
        }
        else {
            $('#PriceOptions :input[id^=rbDafJubiTrin]:radio').attr('disabled', true);
            $('#PriceOptions :input[id^=rbDafJubiRabat]:radio').attr('checked', true);
        }
    });

    $("input[name='dafrabat']").click(function () {
        if ($("input[name='dafrabat']:checked").val() == '0' || $("input[name='dafrabat']:checked").val() == '1') {
            $("#preamieDafJubi").show("slow");
            $("#preamieClassic").hide("slow");

            $('#preamieDafJubi :input:button').attr('disabled', false);
        }
        else if ($("input[name='dafrabat']:checked").val() == '2') {
            $("#preamieDafJubi").hide("slow");
            $("#preamieClassic").show("slow");

            $('#preamieDafJubi :input:button').attr('disabled', true);
        }
    });


});


