/**
 * 123plakat.de - Content Management System
 *
 * This is the jQuery JCAROUSEL JS DOCUMENT
 * of the 123plakat.de - content managament system frontend
 *
 * @file    jquery.jcarousel.exec.js
 * @author  dpi one <www.dpi-one.de>
 */


var jcarousel_itemList = [];
function jcarousel_initCallback(carousel) {
	carousel.clip.hover(function() {
		carousel.options.auto = 0;
		carousel.stopAuto();
	}, function() {
		carousel.startAuto(5);
	});
}
function jcarousel_itemVisibleInCallback(carousel, item, i, state, evt) {
	// The index() method calculates the index from a
	// given index who is out of the actual item range.
	var idx = carousel.index(i, jcarousel_itemList.length);
	carousel.add(i, jcarousel_itemList[idx - 1]);
}
function jcarousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
	carousel.remove(i);
}
jQuery(document).ready(function() {
	jQuery('DIV#slideshow DIV.layer-left').css({'opacity': '0.6'});
	jQuery('DIV#slideshow DIV.layer-right').css({'opacity': '0.6'});
	var width = 0;
	jQuery('DIV#slideshow DIV.jcarousel-clip > UL > LI').each(function() {
		width += jQuery(this).outerWidth(true);
		jcarousel_itemList.push(jQuery(this).html());
	});
	if (jQuery('DIV#slideshow DIV.jcarousel-clip').innerWidth() < width) {
		jQuery('DIV#slideshow DIV.jcarousel-clip > UL').html('<!-- The content will be dynamically loaded in here -->');
		jQuery('DIV#slideshow DIV.jcarousel-clip > UL').jcarousel({
			auto: 5,
			animation: 1250,
			wrap: 'circular',
			scroll: 1,
			initCallback: jcarousel_initCallback,
			itemVisibleInCallback: {onBeforeAnimation: jcarousel_itemVisibleInCallback},
			itemVisibleOutCallback: {onAfterAnimation: jcarousel_itemVisibleOutCallback}
		});
	}
});
