jQuery(document).ready ( function () {

    /*
    * Klappbare Listen fuer Produktuebersichtsseiten
    */
    //jQuery("div.products").hide();
    //jQuery("div.displayme").show();
    
    /*
    * Klappfunktion fuer H3
    */
    jQuery("div.productcat").find("h3").click(function(){

        jQuery(this).parent().parent().find("div.productcat").each(
             function(intIndex){
                if ( jQuery(this).find("div.products").css("display") != "none"){
                    jQuery(this).find("div.products").slideUp("slow");
                    jQuery(this).find("h3").removeClass("headeractive");
                    var strucId = "#structure"+jQuery(this).find("h3").attr("id").substr(5);
                    jQuery(strucId).removeClass("active");
                }
            });

        if ( jQuery(this).parent().find("div.products").css("display") != "none"){
            jQuery(this).removeClass("headeractive");
            jQuery(this).parent().find("div.products").slideUp("slow");
        } else {
            jQuery(this).addClass("headeractive");
            jQuery(this).parent().find("div.products").slideDown("slow");
            var strucId = "#structure"+jQuery(this).attr("id").substr(5);
            jQuery(strucId).addClass("active");
        }
    });
    
    /*
    * Klappfunktion fuer das Produktbild
    */
    jQuery("div.categoryimage").click(function(){
        jQuery(this).parent().parent().parent().find("div.productcat").each(
             function(intIndex){
                if ( jQuery(this).find("div.products").css("display") != "none"){
                    jQuery(this).find("div.products").slideUp("slow");
                    jQuery(this).find("h3").removeClass("headeractive");
                    var strucId = "#structure"+jQuery(this).find("h3").attr("id").substr(5);
                    jQuery(strucId).removeClass("active");
                }
            });
    
        if ( jQuery(this).parent().find("div.products").css("display") != "none"){
            jQuery(this).parent().parent().find("h3").removeClass("headeractive");
            jQuery(this).parent().find("div.products").slideUp("slow");
        } else {
            jQuery(this).parent().parent().find("h3").addClass("headeractive");
            jQuery(this).parent().find("div.products").slideDown("slow");
            var strucId = "#structure"+jQuery(this).parent().parent().find("h3").attr("id").substr(5);
            jQuery(strucId).addClass("active");
        }
    });
    
    /*
    * Klappfunktion fuer die Kurzbeschreibung
    */
    jQuery("div.description").click(function(){
        jQuery(this).parent().parent().parent().find("div.productcat").each(
             function(intIndex){
                if ( jQuery(this).find("div.products").css("display") != "none"){
                    jQuery(this).find("div.products").slideUp("slow");
                    jQuery(this).find("h3").removeClass("headeractive");
                    var strucId = "#structure"+jQuery(this).find("h3").attr("id").substr(5);
                    jQuery(strucId).removeClass("active");
                }
            });
    
        if ( jQuery(this).parent().find("div.products").css("display") != "none"){
            jQuery(this).parent().parent().find("h3").removeClass("headeractive");
            jQuery(this).parent().find("div.products").slideUp("slow");
        } else {
            jQuery(this).parent().parent().find("h3").addClass("headeractive");
            jQuery(this).parent().find("div.products").slideDown("slow");
            var strucId = "#structure"+jQuery(this).parent().parent().find("h3").attr("id").substr(5);
            jQuery(strucId).addClass("active");
        }
    });

});