    $(document).ready(function() {

    	//$.preLoadCSSImages();
    	 $('.colorbox').colorbox();
    	 $(document).bind('cbox_complete', function(){
     		$.colorbox.resize();
     	});
     	
    	 
        $('.insideLabeled').insideLabel();
        $('.hoverButton').hoverbutton();
        $('.heroTeaser').not('.schoeningh').rotator({
        	'elementClass': 'image',
            'viewportClass': 'imageContainer',
            'linkClass': 'link',
            'activeElementClass': 'active',
            'activeLinkClass': 'active',
            'onInitializationFinished': function(rootElem,rotateFunc) {
            	$('.navigation li a').hover(function() {
            		var prevs  = $(this).parent().prevAll();
            		$(rootElem).addClass('paused');
            		rotateFunc(rootElem,prevs.size());
            	}, function() {
            		$(rootElem).removeClass('paused');
            	});
            },
            'onElementActivation': function(element,index) {
            	$('.navigation li a').removeClass('active');
            	$('.navigation li a').eq(index).addClass('active');
        	}
        });

        /* bei Schöningh über andere Navi */
        $('.heroTeaser').filter('.schoeningh').rotator({
        	'elementClass': 'image',
            'viewportClass': 'imageContainer',
            'linkClass': 'link',
            'activeElementClass': 'active',
            'activeLinkClass': 'active',
            'onInitializationFinished': function(rootElem,rotateFunc) {
            	$('#mainNav li a').hover(function() {
            		var prevs  = $(this).parent().prevAll();
            		$(rootElem).addClass('paused');
            		rotateFunc(rootElem,prevs.size());
            	}, function() {
            		$(rootElem).removeClass('paused');
            	});
            },
            'onElementActivation': function(element,index) {
            	$('#mainNav li a').removeClass('active');
            	$('#mainNav li a').eq(index).addClass('active');
        	}
        });

        if ($('.rotatorTeaser').size() > 0) {
	        $('.rotatorTeaser').each(function() {
	        	$(this).rotator({
	        	'elementClass': 'element',
	            'viewportClass': 'elementContainer',
	            'linkClass': 'link',
	            'activeElementClass': 'active',
	            'activeLinkClass': 'active',
	            'onLinkActivation': function(activatedLink) {
	        		var newSrc = $('img',activatedLink).attr('src').replace('inactive','active');
	        		$('img',activatedLink).attr('src',newSrc);
	        	},
	        	'onLinkDeactivation': function(activatedLink) {
	        		var newSrc = $('img',activatedLink).attr('src').replace('active','inactive');
	        		$('img',activatedLink).attr('src',newSrc);
	        	}
	        	});
	        });
        }

        // Set up dropdowns
        $('.fancydropdown').fancydropdown();
        if ($('.sortSelect select').size() > 0) {
        	$('.sortSelect select').fancydropdown();
        }
        $('.multiselect').each(function() {
        	$(this).fancymultiselect({maxHeight: '300'});
        });

        $('.checkmultiselect').each(function() {
        	$(this).fancycheckmultiselect();
        });

        $('.hasTooltip').each(function() {
        	$(this).tooltip();
        });

        $('.hasDetailTooltip').each(function() {
        	$(this).detailTooltip();
        });

        $('.optionalContentContainer .close').click(function(e) {
        	$(this).closest('.optionalContentContainer').slideUp();
        	$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
        	$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
        });

        if ($.browser.msie && $.browser.version.substr(0,1)<7) {
	        $('.png').hover(function() {
	        	//DD_belatedPNG.fix('.png');
	        });
        }

        $('.showMoreList').each(function() {
        	$(this).showmorelist({
        		'showMoreLabel': 'Alle anzeigen',
        		'showLessLabel': 'Weniger anzeigen'
        	});
        });

        $('#loginLink').click(function() {
        	$('#schulbuchzentrumContainer .optionalContentContainer').hide();
        	$('#schulbuchzentrumLogin').show();
        	$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
        	$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
        	return false;
        });
        $('#schulbuchzentrumInfoLink').click(function() {
            $('#schulbuchzentrumContainer .optionalContentContainer').hide();
    		$('#schulbuchzentrumInfo').show();
    		$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
    		$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
    		return false;
    	});
        $('#schulbuchzentrumMyAccountLink').click(function() {
            $('#schulbuchzentrumContainer .optionalContentContainer').hide();
    		$('#schulbuchzentrumMyAccount').show();
    		$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
    		$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
    		return false;
    	});
        $('#schulbuchzentrumInfoLink').click(function() {
            $('#schulbuchzentrumContainer .optionalContentContainer').hide();
    		$('#schulbuchzentrumInfo').show();
    		$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
    		$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
    		return false;
    	});
        $('.active #schulbuchzentrumLeafletLink').click(function() {
            $('#schulbuchzentrumContainer .optionalContentContainer').hide();
            $('#schulbuchzentrumLeaflet').show();
    		if ($('#schulbuchzentrumLeafletLink').parent().hasClass('expanded')) {
    			$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
    			$('#schulbuchzentrumLeaflet').slideUp();
    		} else {
    			$('#schulbuchzentrumLeaflet').show();
    			$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
    			$('#schulbuchzentrumLeafletLink').parent().addClass('expanded');
    		}
    		return false;
    	});
        $('.active #schulbuchzentrumShoppingCartLink').click(function() {
            $('#schulbuchzentrumContainer .optionalContentContainer').hide();
            $('#schulbuchzentrumShoppingCart').show();
    		if ($('#schulbuchzentrumShoppingCartLink').parent().hasClass('expanded')) {
    			$('#schulbuchzentrumShoppingCartLink').parent().removeClass('expanded');
    			$('#schulbuchzentrumShoppingCart').slideUp();
    		} else {
    			$('#schulbuchzentrumShoppingCart').show();
    			$('#schulbuchzentrumLeafletLink').parent().removeClass('expanded');
    			$('#schulbuchzentrumShoppingCartLink').parent().addClass('expanded');
    		}
    		return false;
    	});

        $('.teaserTablistH2er .scrollpanelContainer .scrollpanelTab').scrollpanel({borderSize: 2});
        $('.teaserTablistH2er').each(function(i) {
        	$(' ._jsScrollpanel', this).each(function(index) {
            	if(index == 0) {
            		$(this).addClass('active');
            	} else {
            		$(this).addClass('inactive');
            	}
        	});
        });

        $('.teaserTablistH2er .navigation a').click(function() {
        	var TAB_INITIAL_INDEX = 'tabNavigation.initialIndex';
        	var teaser = $(this).closest('.teaserTablistH2er');
        	var index = $(this).closest('li').index();

        	// Cancel the hovering of tab navigation
        	$(this).closest('ul').data(TAB_INITIAL_INDEX,index);

        	// Change css classes
       		$('a',$(this).closest('ul')).removeClass('active');
       		$(this).addClass('active');

       		// Switch content
       		$('._jsScrollpanel',teaser).removeClass('active').addClass('inactive');
       		$($('._jsScrollpanel',teaser).get(index)).removeClass('inactive').addClass('active');

        	return false;
        });

        $('.teaserRotatorXXL li').click(function(e) {
        	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        		$('shape',$(this).closest('ul')).each(function() {
        			$(this).hide();
        		});
        	}
        	$(this).siblings().removeClass('active');
        	$(this).addClass('active');
        	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        		$('.active shape',$(this).closest('ul')).each(function() {
        			$(this).show();
        		});
        	}

        });

        $('.sbzListMap').each(function() {
        	$('li',this).each(function() {
        		$(this).hover(function() {
        			$(this).addClass('hovered');
        			$(this).hide();
        			$(this).show();
        			if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        			var liElem = this;
        			var nubElem = $('span.nub',this).get(0);
        			var aelem = $('a',this).get(0);
        			setTimeout(function () { /* wouldn't work as intended without setTimeout */
        				DD_belatedPNG.applyVML(nubElem);
        				DD_belatedPNG.applyVML(liElem);
        				DD_belatedPNG.applyVML(aelem);
        			}, 1);
        			};
        		},function() {
        			$(this).removeClass('hovered');
        			if ($.browser.msie && $.browser.version.substr(0,1)<7) {
            			var liElem = this;
            			var nubElem = $('span.nub',this).get(0);
            			var aelem = $('a',this).get(0);
            			setTimeout(function () { /* wouldn't work as intended without setTimeout */
            				DD_belatedPNG.applyVML(nubElem);
            				DD_belatedPNG.applyVML(liElem);
            				DD_belatedPNG.applyVML(aelem);
            			}, 1);
        			};
        		});
        	});
        });



    });
