

jQuery.noConflict(); 

jQuery(document).ready(function() {

/* Gößentabelle ein und ausblenden */

var sizechart = jQuery("div#sizechart");
jQuery('body').prepend(sizechart);

jQuery(document).find("#messageslayer").height(jQuery(document).find("body").height())

jQuery(document).find("a[href='/help/#tabs-2']").each(function(){
	jQuery(this).attr("href","#");
	jQuery(this).addClass("sizechart");
});

jQuery(document).find("a.sizechart").click(function() {
	jQuery(document).find("#sizechart").show();
	jQuery(document).find("#messageslayer").show();
	
});

jQuery(document).find("#sizechart").click(function() {
	jQuery(document).find("#sizechart").hide();
	jQuery(document).find("#messageslayer").hide();
});

jQuery(document).find("#messageslayer").click(function() {
	jQuery(document).find("#sizechart").hide();
	jQuery(document).find("#messageslayer").hide();
});

/* ENDE Größentabelle */



/* homepage: bestsellers carousel */
	jQuery('div#bestsellers').scrollable({ 
		size: 4,
		clickable: false,
		prevPage: ".nav_scroll_prev",
		nextPage: ".nav_scroll_next",
		disabledClass: "nav_scroll_disabled"
	});

/* search page: header positioning */
	var searchHeader = jQuery('body.catalogsearch-result-index div.page-head');
	searchHeader.prependTo('body.catalogsearch-result-index .catalog-listing');

/* homepage: message positioning */
	var messageBox = jQuery('body.cms-home ul.messages');
	messageBox.insertBefore('body.cms-home #new-products');

/* homepage: message fadeOut */
	var messageBoxes = jQuery(this).find("ul.messages").html();
	var cartBoxes = jQuery(this).find("table#shopping-cart-table").html();
	if(messageBoxes != null) { 
		if(cartBoxes == null){
		jQuery(function($){ 
				var e = jQuery(this).find("ul.messages"); 
				e.fadeIn(); 
				e.queue(function(){
								 setTimeout(function(){
													 	e.dequeue();
													 },6000);
								 });
				e.fadeOut('fast'); 
				}
			);
		}
	}
/* homepage: cart slider */
	function mouseIn() {
		jQuery(this).animate({
			top: '364px',
			height: '65px'
		}, "fast" );
	}
	
	function mouseOut() {
		jQuery(this).animate({
			top: '409px',
			height: '20px'
		}, "fast" );
	}
	
	var config = {
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
		 interval: 100, // number = milliseconds for onMouseOver polling interval
		 over: mouseIn, // function = onMouseOver callback (REQUIRED)
		 timeout: 1000, // number = milliseconds delay before onMouseOut
		 out: mouseOut // function = onMouseOut callback (REQUIRED)
	};
	
	jQuery('body.cms-home .col-right').hoverIntent(config);
	
/* tooltips */
	toolTipArr = jQuery("#new-products li, #bestsellers li, .catalog-listing li");
	
	toolTipArr.each(function(i){
		var tipContent = jQuery(this).find("span.tipContent").html();
		
		if(tipContent != null) {
			jQuery(this).simpletip({
				// Configuration properties
				content: tipContent,
				fixed: true,
				position: [5,5]
			});
		}
    });

/* cart icon hover */
	cartIconArr = jQuery("#new-products li, #bestsellers li");
	
	cartIconArr.find("span.in-stock").hide();
	
	cartIconArr.hover(
		function () {
			jQuery(this).find("span.in-stock").show();
		}, 
		function () {
			jQuery(this).find("span.in-stock").hide();
		}
    );

/* apply droppy */
	droppyArr = jQuery("#narrow-by-list, #sort-by-select, #lang-switch");
	droppyArr.droppy();
	
	/* round fieldset */
	/*jQuery(this).find("fieldset").corner();*/
	

	var helpbox=jQuery(this).find('#tabs').html();
				// Tabs
		if(helpbox != null) { 
				jQuery(this).find('#tabs').tabs();
				
				//hover states on the static widgets
				jQuery(this).find('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
		}

		
/*Banner-Rotation on Homepage*/
  var items = jQuery("#banner-rotation .item");
  var speed = 5000;
  var fn = {
		loop: function() {
			fn.blend();
			setTimeout(fn.loop, speed);
		},
		blend: function() {
			var current = items.filter(".current").fadeOut(1000).removeClass("current");
			current = (current.next().length) ? current.next() : jQuery("#banner-rotation .item:first");
			current.fadeIn(1500).addClass("current");
		}
	}
  if (items.length >= 2) {
	items.hide();
	jQuery("#banner-rotation .item:first").show(1,function() {
		setTimeout(fn.loop, speed);
	}).addClass('current');
  }

}); //End $(Document).ready();

