
$(document).ready(function () {
   // $(document).pngFix();
  /* $(function () {
    $(".fancy").tooltip({
        track: true,
        delay: 0,
        showURL: false,
        fixPNG: true,
        showBody: " - ",
        extraClass: "pretty fancy",
        top: -15,
        left: 5
    	});
	}); */
   
   
	$(function () {
        $("#main_menu").lavaLamp({
            fx: "backout",
            speed: 500
        });
    });
    if ($('#lieferadresse:checked').val() == "true") {
        $('#andere_lieferanschrift').fadeIn('fast');
    }
    $(".filter_ueberschrift").click(function () {
        if ($(this).hasClass("opend")) {
            $(this).removeClass("opend");
            $(this).addClass("closed");
        } else {
            $(this).removeClass("closed");
            $(this).addClass("opend");
        }
        $(this).siblings(".box_wrapper").slideToggle('fast', function () {
            if ($(this).hasClass("opend_box")) {
                $(this).removeClass("opend_box");
                $(this).addClass("closed_box");
            } else {
                $(this).removeClass("closed_box");
                $(this).addClass("opend_box");
            }
        });
    });
    $('.left_content').corner();

    $('.box_wrapper').corner("6px bottom");
    $('#show_artikel').corner();
    $('.pagination_wrapper').corner();
    //$('.uebersicht_wrapper').corner(); 
    //$('.uebersicht_button').corner();
    //$('.detail_infobox').corner();
    //$('.detail_box').corner();
    $('.uebersicht_button').corner().parent().css('padding', '8px').corner("round 14px");
    $('.detail_box').corner().parent().css('padding', '8px').corner("round 14px");
    $('#preise_versand').corner().parent().css('padding', '8px').corner("round 14px");




    $('.passende_artikel').corner();
    $('.warenkorb_wrapper').corner();
    $('.overview_wrapper').corner();
    $('.register_wrapper, .search_wrapper').corner();
    $('.register_content').corner();
    $('.overview_content').corner();
    $('.warenkorb_content').corner();



    $('#lieferadresse').change(function () {
        if ($(this + ":checked").val() == "true") {
            $("#vk_laender").fadeOut();
            $('#andere_lieferanschrift').fadeIn('fast', function () {
                jQuery("#liefer_land, #liefer_anrede").select_skin();

            });
        } else {
            if ($("#vk_land").html() != "") $("#vk_laender").fadeIn();
            $('#andere_lieferanschrift').fadeOut('fast', function () {
                jQuery("#liefer_land, #liefer_anrede").select_unskin();
            });
        }
    });
    $('#insert_warenkorb').submit(function () {
        // alert($("input[name='ident_nr']:checked").val() + "drin");
        if (typeof $("input[name='ident_nr']:checked").val() == "undefined") {
            alert("Bitte wählen Sie erst eine Größe aus.");
            return false;
        } else
        return true;
    });


    $('#warenkorb_button').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_in_den_warenkorb_hover.gif");
    });
    $('#warenkorb_button').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_in_den_warenkorb.gif");
    });
    $('#weiter_einkaufen_button').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_weiter_einkaufen_hover.png");
    });
    $('#weiter_einkaufen_button').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_weiter_einkaufen.png");
    });
    $('#zur_kasse_button').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_zur_kasse_hover.gif");
    });
    $('#zur_kasse_button').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_zur_kasse.gif");
    });
    $('#zurueck').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_zurueck_hover.png");
    });
    $('#zurueck').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_zurueck.png");
    });
    $('#weiter_zahlung').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_weiter_hover.png");
    });
    $('#weiter_zahlung').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_weiter.png");
    });
    $('#bestellung_abschicken').mouseover(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_bestellung_abschicken_hover.png");
    });
    $('#bestellung_abschicken').mouseout(function () {
        $(this).attr("src", "./styles/" + template_style + "/pics/btn_bestellung_abschicken.png");
    });

    jQuery("#anrede, #land, #order_by").select_skin();

    $(function () {
        $("#groessen_auswahl").buttonset();
    });
    $(".gr_radio").change(function () {
        var price = $(this).attr("title");
        $("#price_value").fadeOut("fast", function () {
            $("#price_value").html(price);
        });
        $("#price_value").fadeIn("fast");
    });

    if (typeof $(".gr_radio:checked").val() != "undefined") {
        var price = $(".gr_radio:checked").attr("title");
        $("#price_value").fadeOut("fast", function () {
            $("#price_value").html(price);
        });
        $("#price_value").fadeIn("fast");
    };


    jQuery("#user_data").validationEngine();

    $("#order_by").focus(function () {
        // Store the current value on focus, before it changes
        previous = $(this).val();
    }).change(function () {
        if (previous != $(this).val()) $("#sort_option").submit();

    });

    $("#land").change(function () {
        $("#land option:selected").each(function () {
            if (typeof($(this).attr("rel")) != "undefined") {
                $("#vk_value").html($(this).attr("rel"));
                $("#vk_land").html($(this).val());

                if ($("#lieferadresse:checked").val() != "true") $("#vk_laender").fadeIn();
            } else {

                $("#vk_laender").fadeOut('fast', function () {
                    $("#vk_value").html("");
                    $("#vk_land").html("");

                });
            }
        });
    });

    $("#liefer_land").change(function () {
        $("#liefer_land option:selected").each(function () {
            if (typeof($(this).attr("rel")) != "undefined") {
                $("#vk_value_liefer").html($(this).attr("rel"));
                $("#vk_land_liefer").html($(this).val());
                $("#vk_laender_liefer").fadeIn();
            } else {
                $("#vk_laender_liefer").fadeOut('fast', function () {
                    $("#vk_value_liefer").html("");
                    $("#vk_land_liefer").html("");

                });

            }
        });
    });

    $("#search_page").focus(function () {
        if ($(this).val() == "Suche") {
            $(this).val("");
        }
        $(this).css("color", "#2f0b71");

    });

    $("#submit_button").click(function () {
        $("#search_form").submit();
    });

    $("input:radio[name='zahlungsart']").click(function () {
        if ($("input:radio:checked[name='zahlungsart']").val() == "paypal") {
            $(".paypal_notifier").fadeIn('fast');
        } else {
            $(".paypal_notifier").fadeOut('fast');
        }

    });
});
