﻿$(document).ready(function() {
    if ($("#carousel").length > 0) {
        $("#carousel").tabs();
    }
    if ($("#outlet-rec").length > 0) {
        $("#outlet-rec").tabs();
        $("#outlet-rec").tabs("rotate", 3000 , false);
    }
    if ($("#additional").length > 0) {
        $("#additional").tabs();
    }

    $("div.minicart").hover(
        function() {
            $("div.hover", this).stop(true, true).show("slow");
        },
        function() {
            $("div.hover", this).stop(true, true).hide("slow");
        }
    );

    if ($("a.go-to-comments").length > 0) {
        $("a.go-to-comments").click(function() {
            javascript: $('#additional').tabs('select', 3);
            return false;
        });
    }

    if ($("div.shipping li.government-customer input:checkbox").length > 0) {
        $("div.shipping li.government-customer input:checkbox").click(
                function() {

                    var strValueToFind = $(this).attr("value");

                    if ($(this).is(':checked')) {
                        ToggleGovernmentCustomer(true);
                    }
                    else {
                        ToggleGovernmentCustomer(false);
                    }
                }
            );
        if ($("div.shipping li.government-customer input:checkbox").length > 0) {
            ToggleGovernmentCustomer($("div.shipping li.government-customer input:checkbox").is(':checked'));
        }
    }

    if ($("div.product-add-to-cart").length > 0) {
        $('div.product-add-to-cart').livequery(function() {
            setTimeout('$("div.success").fadeOut("slow")', 1000);
            $("div.error").fadeOut("slow");
        });
    }
});

function ToggleGovernmentCustomer(bDisplay) {
    if (bDisplay == true) {
        $("div.shipping li.requisition-number").show();
        $("div.shipping li.ean-location-number").show();
        $("div.shipping li.contact-person").show();
    }
    else {
        $("div.shipping li.requisition-number").hide();
        $("div.shipping li.ean-location-number").hide();
        $("div.shipping li.contact-person").hide();
    }
}
