jQuery(document).ready(function(){

	
	$("body").addClass("js_enabled");
	jQuery().initParallaxScroll();
		
	
	$(window).resize(function(){ //if the user resizes the window...
		$('#container_start').resizeHeight({ });	
		$('#container_sortiment').resizeHeight({ });
		$('#container_gastro').resizeHeight({ });
		$('#container_about').resizeHeight({ });
		$('#container_plant').resizeHeight({ });
		$('#container_tvc').resizeHeight({ });
	  	$('.size1Bottle').resizeHeight({ });
	  	$('.size2Bottle').resizeHeight({ });
		$('.size3Bottle').resizeHeight({ });
		$('.size4Bottle').resizeHeight({ });
		$('#about_content_bottleBackground').resizeHeight({ });
		$('#plant_content_image').resizeHeight({ });
		$('#content_start_teaser').resizeHeight({ });
	});	
	
	
	$(	'#sortiment_content_bottle3,' + 
		'#sortiment_content_bottle4,' + 
		'#sortiment_content_bottle2,' + 
		'#sortiment_content_bottle1,' + 
		'#container_start'
		).bind('inview', function (event, visible) {
		if (visible == true) {
			$(this).addClass("inview");
		} else {
			$(this).removeClass("inview");
		}
	});	
	
	var didScroll = false;
	$(window).scroll(function(){
		didScroll = true;
	});
	setInterval(function(){
		if (didScroll) {
			didScroll = false;
			$(window).trigger("pagescroll");
		}
	}, 20);
	$('#logo').bind('click',function(){
		window.scrollTo(0, 1);
		
	});
	
	var activeID = "#navi_start";
		
	$('#container_start').resizeHeight();
	$('#container_sortiment').resizeHeight({ });
	$('#container_gastro').resizeHeight({ });
	$('#container_about').resizeHeight({ });
	$('#container_plant').resizeHeight({ });
	$('#container_tvc').resizeHeight({ });	
	$('.size1Bottle').resizeHeight({ });
	$('.size2Bottle').resizeHeight({ });
	$('.size3Bottle').resizeHeight({ });
	$('.size4Bottle').resizeHeight({ });
	$('#about_content_bottleBackground').resizeHeight({ });
	$('#plant_content_image').resizeHeight({ });
	$('#content_start_teaser').resizeHeight({ });
		
	$("#accordion_simple_about").accordion({ 
		header: "h3",
		clearStyle: true,
		active: false,
		collapsible: true
	});
	
	$("#accordion_simple_plant").accordion({ 
		header: "h3",
		clearStyle: true,
		active: false,
		collapsible: true
	});
	
	animationRunning = false;
	
	$('#about, #start, #sortiment, #gastro, #plant, #tvc').waypoint();
	$('#about, #start, #sortiment, #gastro, #plant, #tvc').bind('waypoint.reached', function(event, direction) {
		if(!animationRunning)
		{
			activeID = "#navi_" + $(this).attr('id');
			jQuery().setActiveNavigation('#vio_navigation ul li', "#navi_" + $(this).attr('id'));
		}
	});
	
	
	var anchor = self.document.location.hash;
	var scrollToValue_ = $(anchor).offset().top;
			
	if(scrollToValue_ > document.documentElement.scrollTop) scrollToValue_ = scrollToValue_ + 1;
	if(scrollToValue_ < document.documentElement.scrollTop) scrollToValue_ = scrollToValue_ - 1;
	$('html,body').animate({
		scrollTop: scrollToValue_},50, 'linear', function() {
			animationRunning = false;
			
	});
});

