jQuery(document).ready(function(){

    /* if Internet Explorer 6 */
    if ((jQuery.browser.version == "6.0") && (jQuery.browser.msie)) {
        /* Dropdown Menu */
        jQuery('#menu').superfish({
            onShow:        function(){         // callback function fires once reveal animation completed – 'jQuery(this)' is the opened ul
                                jQuery(this).prev("a").addClass("hover");
                                jQuery(this).find("a").css("width",jQuery(this).width());
                           },
            onHide:        function(){         // callback function fires after a sub-menu has closed – 'jQuery(this)' is the ul that just closed
                                jQuery(this).prev("a").removeClass("hover");
                                jQuery(this).find("a").css("width","auto");
                           },
            delay:         200,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing
            animation:     {opacity:'show'},   // an object equivalent to first parameter of jQuery’s .animate() method
            speed:         0,                  // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method
            autoArrows:    false,              // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance
            dropShadows:   false,              // completely disable drop shadows by setting jQuery(this) to false
            disableHI:     false               // set to true to disable hoverIntent detection
        });
    }
    
    /* Slideshow */
    jQuery('#slideshow .csc-textpic-imagecolumn').cycle({
        fx:           'fade',              // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle) 
        timeout:       4000,               // milliseconds between slide transitions (0 to disable auto advance) 
        speed:         1000,               // speed of the transition (any valid fx speed value) 
        sync:          1,                  // true if in/out transitions should occur simultaneously 
        random:        1,                  // true for random, false for sequence (not applicable to shuffle fx) 
        pause:         0                   // true to enable "pause on hover" 
    });
    
    /* Hoverbox */
    jQuery('a.hoverbox').each(function(){
        // wrap with span
        jQuery(this).wrapInner('<span></span>');
        // add icon
        jQuery(this).append('<img class="icon" src="fileadmin/layout/2009/grundriss.gif" alt="Grundriss ansehen" />');
        // append image
        jQuery(this).append('<img class="original" src="'+jQuery(this).attr("href")+'" alt="'+jQuery(this).attr("title")+'" />');
        // enable hover
        jQuery(this).bind("mouseenter mouseleave", function(){
            // remove z-indexes
            if (jQuery(this).parents('.contenttable').length == 1) {
                jQuery(".contenttable td[style]").removeAttr('style');
                jQuery(".contenttable[style]").removeAttr('style');
                if ((jQuery(this).parents('.left').length == 1) || (jQuery(this).parents('.right').length == 1)) {
                    jQuery(".twoCol-float .left[style]").removeAttr('style');
                    jQuery(".twoCol-float .right[style]").removeAttr('style');
                }
            }
            else {
                jQuery(".tx-fdfx2cols-pi1[style]").removeAttr('style');
                jQuery(".tx-fdfx2cols-pi1 div div[style]").removeAttr('style');
            }
            // add hover class
            jQuery(this).find("img.original").toggleClass("hover");
            // add z-indexes
            if (jQuery(this).parents('.contenttable').length == 1) {
                jQuery(this).parent().parent().parent().parent().parent().css({'z-index': '10', 'position': 'relative'});
                jQuery(this).parent().parent().css('z-index', '9');
                if ((jQuery(this).parents('.left').length == 1) || (jQuery(this).parents('.right').length == 1)) {
                    jQuery(this).parent().parent().parent().parent().parent().parent().css({'z-index': '10'});
                }
            }
            else {
                jQuery(this).parent().parent().parent().parent().css('z-index', '10');
                jQuery(this).parent().parent().css('z-index', '9');
            }
        });
        // disable click
        jQuery(this).click(function(){
            return false;
        });
    });

});