if(typeof console === 'undefined') {
	var console = { log: function() {}};
}
var schott = {};
jQuery(function($) {
	schott = {
		'increaseQuantity': function() {
			var input = $("div.productInfoContainer div.selection div.quantityContainer input[type='text']");
			var num = Math.floor($(input).val() * 1);
			if((num % 1 != 0) || num < 0) {
				$(input).val('1');
				return;
			}
			(input).val(num + 1);
		},
		'decreaseQuantity': function() {
			var input = $("div.productInfoContainer div.selection div.quantityContainer input[type='text']");
			var num = Math.floor($(input).val() * 1);
			if((num % 1 != 0) || num <= 1) {
				$(input).val('1');
				return;
			}
			(input).val(num - 1);
		},
		'changePicture': function(var_pic_name) {
			var picture_path = "images/product_images/info_images/" + var_pic_name;
			$("#prodImage").attr("src", picture_path);
		},
		'ui': {
			'initialize': function() {
			
				$("div.productListingContainer div.listContainer ul li").mouseenter(function() {
					$(this).addClass('highlight');
				}).mouseleave(function() {
					$(this).removeClass('highlight');
				});
			//product highlight mode in product highlightmodule
			/*$("div.highlightProductContainer").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);
			
			$("div.topSellersProductContainer").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);
			
			$("div.categorieListing ul li").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);

				$("div.productListingContainer div.listContainer ul li").mouseenter(
					function() {
						$(this).addClass('highlight');
						
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);
			
				// product highlight mode in product overview pages
				$("div.productListingContainer ul li").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);

				// product highlight mode in "featured products" bar
				$("div.featuredProductsContainer ul li").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);

				// category highlight mode in category selection
				$("div.subCategoriesContainer td[class!='empty']").mouseenter(
					function() {
						$(this).addClass('highlight');
					}
				).mouseleave(
					function() {
						$(this).removeClass('highlight');
					}
				);*/
								
				$("ul.categorieul li").mouseenter(
						function(){													
							$(this).addClass('visible');
						}
					).mouseleave(
						function() {					
							$(this).removeClass('visible');
						}
					);
				$("ul.categorieul li.subcatli").mouseenter(
						function() {
							$(this).addClass('hover');
						}
					).mouseleave(
						function() {
							$(this).removeClass('hover');
						}
					);
				
			}
 		},
 		'additionalContent': {
 			'initialize': function() {

 				// load slideshow for startpage
 				var elem = $("#startPageContentContainer");
 				if(elem.length == 1) {
 					var htmlcode = "<ul id='slideimg'><li><img src='templates/schott/img/slides/schott-slide-1.jpg' alt='Schott Jacken' /></li><li><img src='templates/schott/img/slides/schott-slide-2.jpg' alt='Schott Jacken' /></li><li><img src='templates/schott/img/slides/schott-slide-3.jpg' alt='Schott Jacken' /></li><li><img src='templates/schott/img/slides/schott-slide-4.jpg' alt='Schott Jacken' /></li><li><img src='templates/schott/img/slides/schott-slide-5.jpg' alt='Schott Jacken' /></li></ul>";
					
					$('#startPageContentContainer #slideShowContainer').html(htmlcode);
					
                    $("head").prepend('<script type="text/javascript" src="templates/schott/javascript/jquery.bxslider2.0.1.min.js"></script>');
                    $('#slideimg').bxSlider({
                        alignment: 'horizontal', // 'horizontal', 'vertical' - direction in which slides will move
                        controls: false, // determines if default 'next'/'prev' controls are displayed
                        speed: 1200, // amount of time slide transition lasts (in milliseconds)
                        pager: false, // determines if a numeric pager is displayed (1 2 3 4...)
                        pager_short: false, // determines if a 'short' numeric pager is displayed (1/4)
                        pager_short_separator: ' / ', // text to be used to separate the short pager
                        margin: 50, // if 'horizontal', applies a right margin to each slide, if 'vertical' a
                        // bottom margin is applied. example: margin: 50
                        next_text: 'next', // text to be displayed for the 'next' control
                        next_image: '', // image to be used for the 'next' control
                        prev_text: 'prev', // text to be displayed for the 'prev' control
                        prev_image: '', // image to be used for the 'prev' control
                        auto: true, // determines if slides will move automatically
                        pause: 3500, // time between each slide transition (auto mode only) 
                        auto_direction: 'left', // order in which slides will transition (auto mode only)
                        auto_hover: true, // determines if slideshow will pause while mouse is hovering over slideshow
                        auto_controls: false, // determines if 'start'/'stop' controls are displayed (auto mode only)
                        ticker: false, // determines if slideshow will behave as a constant ticker
                        ticker_controls: false, // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
                        ticker_direction: 'next', // order in which slides will transition (ticker mode only)
                        ticker_hover: true, // determines if slideshow will pause while mouse is hovering over slideshow
                        stop_text: 'stop', // text to be displayed for the 'stop' control
                        start_text: 'start', // text to be displayed for the 'start' control
                        wrapper_class: 'bxslider_wrap' // class name to be used for the outer wrapper of the slideshow
                    }); 
 				}

 				// category menu for startpage
 				var cats = $("a.hasSubcategories");
 				if(cats.length > 0) {
 					var innerContainer = $("div#innerCategoryList");
 					var subCatContainer = innerContainer.find("div#subCategories");
 					cats.mouseenter(function() {
 						subCatContainer.empty();
 						innerContainer.find("a img").attr('src', 'templates/schott/img/menu_arrow_ffffff_12x12.gif');
 						subCatContainer.append($(this).parent().parent().parent().find("h3:first").text() + ':&nbsp;&nbsp;&nbsp;');
 						subCatContainer.append($(this).parent().find("ul:first").clone().show());
 						$(this).find("img").attr('src', 'templates/schott/img/menu_arrow_cc0000_12x12.gif');
 					});
 					innerContainer.mouseleave(function() {
 						$(this).find("a img").attr('src', 'templates/schott/img/menu_arrow_ffffff_12x12.gif');
 						innerContainer.find("div#subCategories").empty();
 					});
 				}
 			}
 		},
 		'initialize': function() {
 			this.ui.initialize();
 			this.additionalContent.initialize();
 		}
	};
	schott.initialize();
});

