// Breite berechnen

$(document).ready(function(){
	

	var browserWidth = $(window).width();
	$('#imprint').css('width', browserWidth);

	var width = 0;
	$('.work').each(function() {
    width += $(this).outerWidth( true );
	});
	$('#container').css('width', width);
	
	// Intro-Scroll
/*	var browserWidth = $(window).width()+200;
	$('html,body').animate({scrollLeft: browserWidth}, 0).animate({scrollLeft: browserWidth}, 500).animate({scrollLeft: 0}, 1400);
*/

// Breite bei Resize neu berechnen
$(window).resize(function() {
	var browserWidth = $(window).width();
	$('#imprint').css('width', browserWidth);

	var width = 0;
  	$('.work').each(function() {
    width += $(this).outerWidth( true );
	});
	$('#container').css('width', width);
});

// Pfeile: Springe zu nächster Arbeit

	$("img.jump-next").click(function(){
		if ($(this).parents('.work').next().find('.ziel').length) {
		var jumpnext = $(this).parents('.work').next().find('.ziel').attr("id");
		window.location.hash = jumpnext;}
		else { var jumpnext = $(this).parents('.work').next().next().find('.ziel').attr("id");
		window.location.hash = jumpnext;}
	});
	
	$("img.jump-prev").click(function(){
		if ($(this).parents('.work').prev().find('.ziel').length) {
		var jumpprev = $(this).parents('.work').prev().find('.ziel').attr("id");
		window.location.hash = jumpprev;}
		else { var jumpprev = $(this).parents('.work').prev().prev().find('.ziel').attr("id");
		window.location.hash = jumpprev;}
	});
	
	// Scrollme-Pfeil Hover

  	$(".scrollme").hover(
  		function () {
  		if (!$(this).is(':animated') ) {
  		$(this).css('backgroundPosition','0px -28px');}
  	}, 
  		function () {
  		if (!$(this).is(':animated') ) {
  		$(this).css('backgroundPosition','0px 8px');}
  	});


  	$(".scrollme").click(function(){
		if (!$(this).is(':animated') ) {$(this).css('backgroundPosition','0px -28px')
		.animate({bottom: "25px"}, 200 ).animate({bottom: "15px"}, 150 ).animate({bottom: "25px"}, 200 ).animate({bottom: "15px"}, 150 ).animate({bottom: "15px"}, 600, function() {
    	// Animation complete. 
		$(this).css('backgroundPosition','0px 8px');
  		});
		}
	});
	
});
