// Firebug Console Debugging
if (! ('console' in window) || !('firebug' in console)) {  
	var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];  
	window.console = {};  
	for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};  
}

// Baut Carousel aus Array
function itemLoadCallbackFunction(carousel, state)
{
	for (var i = carousel.first; i <= carousel.last; i++) {
		if (!carousel.has(i)) {
			carousel.add(i, megaSlide_itemList[i-1]);
		}
	}
};



// Load jQuery functions, if DOM is ready
$(document).ready(function() {
	

	// Start Slideshow
	
	// Calculate the width an pre / append spacer if needed
	var mega	= $('#megaslide');
	var menu	= $('#slidemenu');
	var megaWidth	= mega.width();
	var menuWidth	= menu.width();
	var spacerClass	= 'spacer';
	var spacerHTML	= '<a class="'+ spacerClass +'"></a>';
	if (megaWidth > menuWidth) {
		menu
		.prepend(spacerHTML)
		.append(spacerHTML)
		.find('.'+spacerClass)
			.width((megaWidth-menuWidth-1)/2)
			.fadeTo(0, 0.6);
	}

	if ( document.getElementById('slideshow') ) {
  
		// Pause on hover, resume on out
		$('#slideshow')
		.cycle()
		.hover(
			function() { $(this).cycle('pause') },
			function() { $(this).cycle('resume') }
		);
	}


	if ( document.getElementById('slidemenu') ) {
  
		// Direct display on A hover, pause
		$('#slidemenu a.menu')
		.fadeTo(0, 0.6)
		.hover(
			function() { 
				$('#slideshow').cycle('pause').cycle($('#slidemenu a.menu').index(this));
				$(this).animate(
				{ 	
					height		: ($.browser.msie) ? "30px" : "36px",
			 		lineHeight	: ($.browser.msie) ? "30px" : "36px",
			    		opacity		: 0.9,
		 			marginTop	: ($.browser.msie) ? "0px" : "-3px"
				},
				{ 
					queue		: false, 
					duration	: 4000
				} );
			},
			function() {
				$(this).animate( 
				{ 
					height		: "30px",
		 			lineHeight	: "30px",
			    		opacity		: 0.6,
			 		marginTop	: "0px"
				},
		 		{ 
					queue		: false, 
					duration	: 4000
				} );
			}
		);
	}
});


