/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/

/*
* Width modifications by Daniel Sundell and Arvid Dyfverman
*/

// Speed of the automatic slideshow
var slideshowSpeed = 6000;

var danafix = 0;

// Variable to store the images we need to set as background
// which also includes some text and url's.
var photos = [ {
		"image" : "work_sliders01.jpg"
	}, {
		"image" : "pizza_hut.jpg"
	}, {
		"image" : "work_sliders02.jpg"
	}, {
		"image" : "work_sliders03.jpg"
	}, {
		"image" : "work_sliders04.jpg"
	}, {
		"image" : "work_sliders05.jpg"
	}, {
		"image" : "work_sliders06.jpg"
	}, {
		"image" : "work_sliders07.jpg"
	}, {
		"image" : "work_sliders08.jpg"
	}, {
		"image" : "work_sliders09.jpg"
	}, {
		"image" : "work_sliders10.jpg"
	}, {
		"image" : "work_sliders11.jpg"
	}, {
		"image" : "work_sliders12.jpg"
	}
];

var titletext=[
	"&bull; Får vi fresta med en Jolt? &bull;",
	"&bull; Pizza Hut är i huset. Have a nice slice. &bull;",
	"&bull; Tintin och godisfabrikens hemlighet. &bull;",
	"&bull; Lätt att handla. Lätt att laga. Enkelt att välja Axfood. &bull;",
	"&bull; Ta ett kliv närmare naturen. &bull;",
	"&bull; Äntligen folk i Folkets park! &bull;",
	"&bull; Är bananerna fina? Japp. Dubbelfina &bull;",
	"&bull; Hav förtröstan. Regnet idag blir till whisky imorgon. &bull;",
	"&bull; Vi har skapat ett monster! &bull;",
	"&bull; Ställ skidorna. Åk Porsche. &bull;",
	"&bull; We are the boat, we are the sea, I sail in you, you sail in me. &bull;",
	"&bull; Mat är en viktig beståndsdel i en balanserad kosthållning. &bull;",
	//"&bull; Dödlig gas är osynlig. Bring out the Canary! &bull;",
	"&bull; Skyddsskor. För att det plötsligt kan hända. &bull;",
	
];


jQuery.fn.myMenuHide = function() {
	$(".button1 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button2 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button3 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button4 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button5 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button6 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button7 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button8 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button9 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button10 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button11 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button12 a").css({ "background-image" : "url(img/dott.png)" });
	$(".button13 a").css({ "background-image" : "url(img/dott.png)" });
	$("#firstline1").css({"display" : "none"});
	$("#secondline1").css({"display" : "none"});
	$("#firstline2").css({"display" : "none"});
	$("#secondline2").css({"display" : "none"});
	$("#firstline3").css({"display" : "none"});
	$("#secondline3").css({"display" : "none"});
	$("#firstline4").css({"display" : "none"});
	$("#secondline4").css({"display" : "none"});
	$("#firstline5").css({"display" : "none"});
	$("#secondline5").css({"display" : "none"});
	$("#firstline6").css({"display" : "none"});
	$("#secondline6").css({"display" : "none"});
	$("#firstline7").css({"display" : "none"});
	$("#secondline7").css({"display" : "none"});
	$("#firstline8").css({"display" : "none"});
	$("#secondline8").css({"display" : "none"});
	$("#firstline9").css({"display" : "none"});
	$("#secondline9").css({"display" : "none"});
	$("#firstline10").css({"display" : "none"});
	$("#secondline10").css({"display" : "none"});
	$("#firstline11").css({"display" : "none"});
	$("#secondline11").css({"display" : "none"});
	$("#firstline12").css({"display" : "none"});
	$("#secondline12").css({"display" : "none"});
	$("#firstline13").css({"display" : "none"});
	$("#secondline13").css({"display" : "none"});
	
 return false;
};

//Scroll function
function goToByScroll(id){
     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

function goToByScrollDelay(id){
     	$('html,body').delay(700).animate({scrollTop: $("#"+id).offset().top},'slow');
}

$(document).ready(function() {


// Ny navigation 
$('#wrapperstad1').hide();
$('#wrapperstad2').hide();
$('#wrapperstad3').hide();
$('#wrapperstad4').hide();


// Stockholm
$('#npp_stad1').mouseenter(function() {
	$('#wrapperstad1').show();
	$('#npp_stad1_link').css({'color' : '#6D6D6D', 'text-decoration' : 'underline'});
	return false;
}
);

$('#npp_stad1').mouseleave(function() {
	$('#wrapperstad1').hide();
	$('#npp_stad1_link').css({'color' : '#aaa', 'text-decoration' : 'none'});
 return false;
}
);

// Uppsala
$('#npp_stad2').mouseenter(function() {
	$('#wrapperstad2').show();
	$('#npp_stad2_link').css({'color' : '#6D6D6D', 'text-decoration' : 'underline'});
	return false;
}
);

$('#npp_stad2').mouseleave(function() {
	$('#wrapperstad2').hide();
	$('#npp_stad2_link').css({'color' : '#aaa', 'text-decoration' : 'none'});
 return false;
}
);

// Västerås
$('#npp_stad3').mouseenter(function() {
	$('#wrapperstad3').show();
	$('#npp_stad3_link').css({'color' : '#6D6D6D', 'text-decoration' : 'underline'});
	return false;
}
);

$('#npp_stad3').mouseleave(function() {
	$('#wrapperstad3').hide();
	$('#npp_stad3_link').css({'color' : '#aaa', 'text-decoration' : 'none'});
 return false;
}
);

// Örebro
$('#npp_stad4').mouseenter(function() {
	$('#wrapperstad4').show();
	$('#npp_stad4_link').css({'color' : '#6D6D6D', 'text-decoration' : 'underline'});
	return false;
}
);

$('#npp_stad4').mouseleave(function() {
	$('#wrapperstad4').hide();
	$('#npp_stad4_link').css({'color' : '#aaa', 'text-decoration' : 'none'});
 return false;
}
);





  // Toggle contentDiv sthlmaddress
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#wrappersthlm').hide();
 // shows the slickbox on clicking the noted link
  $('.sthlmlink').mouseenter(function() {	
	$('#wrappersthlm').fadeIn()(100);
	$('#wrapperuppsala').hide();
	$('#wrappervasteras').hide();
	$('#wrapperorebro').hide();
	$('.arvidsTest').css({'color' : '#6D6D6D'});
	$('.arvidsTest').css({'text-decoration' : 'underline'});
    return false;
  });
    $('.sthlmlink').mouseleave(function() {	
	$('#wrappersthlm').fadeOut()(100);
	$('.arvidsTest').css({'color' : '#6D6D6D'});
	$('.arvidsTest').css({'text-decoration' : 'underline'});
    return false;
  });
	$('#wrappersthlm').mouseenter(function() {	
	$('.arvidsTest').css({'color' : '#6D6D6D'});
	$('.arvidsTest').css({'text-decoration' : 'underline'});
    return false;
  });
	$('#wrappersthlm').mouseleave(function() {	
	$('#wrappersthlm').fadeOut();
	$('.arvidsTest').css({'color' : '#AAAAAA'});
	$('.arvidsTest').css({'text-decoration' : 'none'});
    return false;
  });
  
    // Toggle contentDiv sthlmaddress
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#wrapperuppsala').hide();
 // shows the slickbox on clicking the noted link
  $('.uppsalalink').mouseenter(function() {	
	if ($("#wrapperuppsala").is(":hidden")) {
	$('#wrapperuppsala').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrappervasteras').hide();
	$('#wrapperorebro').hide();
	}else{
	$('#wrapperuppsala').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrappervasteras').hide();
	$('#wrapperorebro').hide();
	}
    return false;
  });
     $('.uppsalalink').mouseleave(function() {	
	$('#wrapperuppsala').fadeOut()(100);
    return false;
  });
	$('#wrapperuppsala').mouseenter(function() {	
	$('#wrapperuppsala').show();
    return false;
  });
	$('#wrapperuppsala').mouseleave(function() {	
	$('#wrapperuppsala').fadeOut();
    return false;
  });
  
    // Toggle contentDiv sthlmaddress
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#wrappervasteras').hide();
 // shows the slickbox on clicking the noted link
  $('.vasteraslink').mouseenter(function() {	
	if ($("#wrappervasteras").is(":hidden")) {
	$('#wrappervasteras').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrapperuppsala').hide();
	$('#wrapperorebro').hide();
	}else{
	$('#wrappervasteras').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrapperuppsala').hide();
	$('#wrapperorebro').hide();
	}
    return false;
  });
     $('.vasteraslink').mouseleave(function() {	
	$('#wrappervasteras').fadeOut()(100);
    return false;
  });
	$('#wrappervasteras').mouseenter(function() {	
	$('#wrappervasteras').show();
    return false;
  });
	$('#wrappervasteras').mouseleave(function() {	
	$('#wrappervasteras').fadeOut();
    return false;
  });
  
    // Toggle contentDiv orebroaddress
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#wrapperorebro').hide();
 // shows the slickbox on clicking the noted link
  $('.orebrolink').mouseenter(function() {	
	if ($("#wrapperorebro").is(":hidden")) {
	$('#wrapperorebro').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrapperuppsala').hide();
	$('#wrappervasteras').hide();
	}else{
	$('#wrapperorebro').fadeIn()(100);
	$('#wrappersthlm').hide();
	$('#wrapperuppsala').hide();
	$('#wrappervasteras').hide();
	}
    return false;
  });
    $('.orebrolink').mouseleave(function() {	
	$('#wrapperorebro').fadeOut()(100);
    return false;
  });
	$('#wrapperorebro').mouseenter(function() {	
	$('#wrapperorebro').show();
    return false;
  });
	$('#wrapperorebro').mouseleave(function() {	
	$('#wrapperorebro').fadeOut();
    return false;
  });
  
  // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#nppmoreinfo').hide();
 
 
 // Toggle contentDiv MER INFO NPP
 // shows the slickbox on clicking the noted link
   $('.nppmoreinfolink').click(function() {
	if ($("#nppmoreinfo").is(":hidden")) {
	$('#nppmoreinfo').slideDown()('slow');
	}else{
	$('#nppmoreinfo').slideDown()('slow');
	}
    return false;
  });
   
   
   // Close contentDiv FAMILJEN NPP
   // hides the slickbox on clicking the noted link
   $('#closenppstaffwrapper').click(function() {
	$('#nppstaff').slideUp()('slow');
    return false;
  });
   
   
   // Close contentDiv JOBB
   // hides the slickbox on clicking the noted link
   $('#closenppjobswrapper').click(function() {
	$('#nppjobs').slideUp()('slow');
    return false;
  });
   
   
   // Close contentDiv PRESS
   // hides the slickbox on clicking the noted link
   $('#closenpppresswrapper').click(function() {
	$('#npppress').slideUp()('slow');
    return false;
  });
   
   
   // Close contentDiv FACEBOOK
   $('.nppsocialmedialink2').show();
 // hides the slickbox on clicking the noted link
   $('.closenppsocialmedia').click(function() {
	$('.nppsocialmedialink2').fadeIn(500);
	$('#nppsocialmedia').slideUp()('slow'); 
    return false;
    });
   
   
   // Toggle contentDiv JOBB
    // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#nppjobs').hide();
  $('.nppjobslink').click(function() {
	$('#nppjobs').slideDown('slow');
  });
  
  
  // Toggle contentDiv PRESS
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#npppress').hide();
  $('.npppresslink').click(function() {
	$('#npppress').slideDown('slow');
  });
  
  
  // Toggle contentDiv NPP
   // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#nppstaff').hide();
 // shows the slickbox on clicking the noted link
  $('.nppstafflink').click(function() {	
	if ($("#nppstaff").is(":hidden")) {
	$('#nppstaff').slideDown()('slow');
	}else{
	$('#nppstaff').slideDown()('slow');
	}
    return false;
  });
  
  
  // Toggle contentDiv FACETITLETEXT
  // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#nppsocialmedia').hide();
 // shows the slickbox on clicking the noted link  
  $('.nppsocialmedialink').click(function() {
	$('#nppsocialmedia').slideDown('slow');
	$('.nppsocialmedialink2').fadeOut(500);
	retu
  });
  $('.nppsocialmedialink2').click(function() {
	$('#nppsocialmedia').slideDown('slow');
	$('.nppsocialmedialink2').fadeOut(500);
  });
  
  
  //BrandsFlipp
  var currentPosition = 0;
  var slideWidth = 873;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Move left</span>')
    .append('<span class="control" id="rightControl">Move right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='rightControl')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      });
    });

  // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show()
    }
    
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
  }






	// showhidecasetext				   
  $('#headertxtwrapper').hide();
  $('#showhidecasetext').click(function() {
   
   	if ($("#headertxtwrapper").is(":hidden")) {
		stopAnimation();
		$('.showhidecase').html("&bull; G&ouml;m text &bull;");
		}else{
//		navigate("next");
		stopAnimation();
		interval = setInterval(function() {
		navigate("next");
	},	slideshowSpeed);
		$(".showhidecase").html(titletext[currentImg-1]);
	}
	
	if ($("#headertxtwrapper").is(":hidden")) {
		$('#headertxtwrapper').slideDown()('slow');
		}else{
		$('#headertxtwrapper').slideUp()('slow');
	}
    return false;
  });
   
   
   
	// Backwards navigation
	$("#back").click(function() {
		stopAnimation();
		navigate("back");
	});
	
	// Forward navigation
	$("#next").click(function() {
		stopAnimation();
		navigate("next");
	});

	
	// Case1 navigation
	$(".button1").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders01.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline1").css({"display" : "block"});
			$("#secondline1").css({"display" : "block"});
			$(".button1 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[0]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 1;
	});
	
	// Case2 navigation
	$(".button2").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/pizza_hut.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline2").css({"display" : "block"});
			$("#secondline2").css({"display" : "block"});
			$(".button2 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 2;
	});
	
		// Case3 navigation
	$(".button3").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders02.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline3").css({"display" : "block"});
			$("#secondline3").css({"display" : "block"});
			$(".button3 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[2]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 3;
	});
	
	// Case4 navigation
	$(".button4").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders03.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline4").css({"display" : "block"});
			$("#secondline4").css({"display" : "block"});
			$(".button4 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[3]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 4;
	});
	
	// Case5 navigation
	$(".button5").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders04.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline5").css({"display" : "block"});
			$("#secondline5").css({"display" : "block"});
			$(".button5 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[4]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 5;
	});
	
	// Case6 navigation
	$(".button6").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders05.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline6").css({"display" : "block"});
			$("#secondline6").css({"display" : "block"});
			$(".button6 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[5]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 6;
	});
	
		// Case7 navigation
	$(".button7").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders06.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline7").css({"display" : "block"});
			$("#secondline7").css({"display" : "block"});
			$(".button7 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[6]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 7;
	});
	
		// Case8 navigation
	$(".button8").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders07.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline8").css({"display" : "block"});
			$("#secondline8").css({"display" : "block"});
			$(".button8 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[7]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 8;
	});
	
		// Case9 navigation
	$(".button9").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders08.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline9").css({"display" : "block"});
			$("#secondline9").css({"display" : "block"});
			$(".button9 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[8]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 9;
	});
		// Case10 navigation
	$(".button10").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders09.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline10").css({"display" : "block"});
			$("#secondline10").css({"display" : "block"});
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[9]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 10;
	});
		// Case11 navigation
	$(".button11").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders10.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline11").css({"display" : "block"});
			$("#secondline11").css({"display" : "block"});
			$(".button11 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[10]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 11;
	});
		// Case13 navigation
	$(".button12").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders11.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline12").css({"display" : "block"});
			$("#secondline12").css({"display" : "block"});
			$(".button12 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[11]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 12;
	});
		// Case13 navigation
	$(".button13").click(function() {
		stopAnimation();
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/work_sliders12.jpg)",
			"display" : "block",
			"z-index" : currentZindex
		});
			jQuery.fn.myMenuHide();
			$("#firstline13").css({"display" : "block"});
			$("#secondline13").css({"display" : "block"});
			$(".button13 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[11]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			currentImg = 13;
	});
	
	var interval;
	$("#control").toggle(function(){
		stopAnimation();
	}, function() {
		// Change the background image to "pause"
		$(this).css({ "background-image" : "url(img/btn_pause.png)" });
		
		// Show the next image
		navigate("next");
		
		// Start playing the animation
		interval = setInterval(function() {
			navigate("next");
		}, slideshowSpeed);
	});
	
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
			if(currentImg == 1) {
			jQuery.fn.myMenuHide();
			$(".button1 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 2) {
			jQuery.fn.myMenuHide();
			$(".button2 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 3) {
			jQuery.fn.myMenuHide();
			$(".button3 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 4) {
			jQuery.fn.myMenuHide();
			$(".button4 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 5) {
			jQuery.fn.myMenuHide();
			$(".button5 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 6) {
			jQuery.fn.myMenuHide();
			$(".button6 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 7) {
			jQuery.fn.myMenuHide();
			$(".button7 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 8) {
			jQuery.fn.myMenuHide();
			$(".button8 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 9) {
			jQuery.fn.myMenuHide();
			$(".button9 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 10) {
			jQuery.fn.myMenuHide();
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 11) {
			jQuery.fn.myMenuHide();
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 12) {
			jQuery.fn.myMenuHide();
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
			if(currentImg == 13) {
			jQuery.fn.myMenuHide();
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(img/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		$(".showhidecase").html(photoObject.title);
			

			if(currentImg == 1) {
			jQuery.fn.myMenuHide();
			$("#firstline1").css({"display" : "block"});
			$("#secondline1").css({"display" : "block"});
			$(".button1 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			
			}
			if(currentImg == 2) {
			jQuery.fn.myMenuHide();
			$("#firstline2").css({"display" : "block"});
			$("#secondline2").css({"display" : "block"});
			$(".button2 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 3) {
			jQuery.fn.myMenuHide();
			$("#firstline3").css({"display" : "block"});
			$("#secondline3").css({"display" : "block"});
			$(".button3 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 4) {
			jQuery.fn.myMenuHide();
			$("#firstline4").css({"display" : "block"});
			$("#secondline4").css({"display" : "block"});
			$(".button4 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 5) {
			jQuery.fn.myMenuHide();
			$("#firstline5").css({"display" : "block"});
			$("#secondline5").css({"display" : "block"});
			$(".button5 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 6) {
			jQuery.fn.myMenuHide();
			$("#firstline6").css({"display" : "block"});
			$("#secondline6").css({"display" : "block"});
			$(".button6 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 7) {
			jQuery.fn.myMenuHide();
			$("#firstline7").css({"display" : "block"});
			$("#secondline7").css({"display" : "block"});
			$(".button7 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}		
			if(currentImg == 8) {
			jQuery.fn.myMenuHide();
			$("#firstline8").css({"display" : "block"});
			$("#secondline8").css({"display" : "block"});
			$(".button8 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}	
			if(currentImg == 9) {
			jQuery.fn.myMenuHide();
			$("#firstline9").css({"display" : "block"});
			$("#secondline9").css({"display" : "block"});
			$(".button9 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 10) {
			jQuery.fn.myMenuHide();
			$("#firstline10").css({"display" : "block"});
			$("#secondline10").css({"display" : "block"});
			$(".button10 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 11) {
			jQuery.fn.myMenuHide();
			$("#firstline11").css({"display" : "block"});
			$("#secondline11").css({"display" : "block"});
			$(".button11 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 12) {
			jQuery.fn.myMenuHide();
			$("#firstline12").css({"display" : "block"});
			$("#secondline12").css({"display" : "block"});
			$(".button12 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
			if(currentImg == 13) {
			jQuery.fn.myMenuHide();
			$("#firstline13").css({"display" : "block"});
			$("#secondline13").css({"display" : "block"});
			$(".button13 a").css({ "background-image" : "url(img/dott_yellow.png)" });
			if ($("#headertxtwrapper").is(":hidden")) {
				$(".showhidecase").html(titletext[currentImg-1]);
				}else{
				$('.showhidecase').html("&bull; G&ouml;m text &bull;");
			}
			}
				
		
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 0);
		});
	};
	
	var stopAnimation = function() {
		// Change the background image to "play"
		$("#control").css({ "background-image" : "url(img/btn_play.png)" });
		
		// Clear the interval
		clearInterval(interval);
	};
	
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
	//AFFE
	$(".affe").hover(
		function(){
			$(".affepic").fadeIn();
		},
		function(){
			$(".affepic").fadeOut();
	}); 
	
	
	//BÅÅTH
	$(".baath").hover(
		function(){
			$(".baathwrapper").animate({'opacity' : '0', '-moz-opacity' : '0', '-khtml-opacity' : '0'});
			$('.baathmail').html("david.baath<br/>@strateg.se");
		},
		function(){
			$(".baathwrapper").animate({'opacity' : '0.2', '-moz-opacity' : '0.2', '-khtml-opacity' : '0.2'});
			$(".baath").css({ "display" : "none" });
	});
	
	//DANA
	$(".dana").hover(
		function(){
			$(".danawrapper").animate({'opacity' : '1', '-moz-opacity' : '1', '-khtml-opacity' : '1'});
			$(".danapic").fadeIn();
		},
		function(){
			$(".danawrapper").animate({'opacity' : '0.2', '-moz-opacity' : '0.2', '-khtml-opacity' : '0.2'});
			$(".danapic").fadeOut();
	}); 
	
	
	//HELEN
	$(".helen").hover(
		function(){
			$(".helenwrapper").animate({'opacity' : '1', '-moz-opacity' : '1', '-khtml-opacity' : '1'});
		},
		function(){
			$(".helenwrapper").animate({'opacity' : '0.1', '-moz-opacity' : '0.1', '-khtml-opacity' : '0.1'});
			$(".helen").css({ "display" : "none" });
	});
	
	//JONTE
	$(".jonte").hover(
		function(){
			$(".jontepic").fadeIn('fast');
		},
		function(){
			$(".jontepic").fadeOut('fast');
	});
	
	//MARTAIN
	$(".martain").hover(
		function(){
			$(".martainpic").fadeIn();
		},
		function(){
			$(".martainpic").fadeOut();
	}); 
	
	
	//MAX
	$(".max").hover(
		function(){
			$(".maxpic").fadeIn();
		},
		function(){
			$(".maxpic").fadeOut();
	}); 

	
	//UFFE
	$(".uffe").hover(
		function(){
			$(".uffepic").fadeIn();
		},
		function(){
			$(".uffepic").fadeOut();
	}); 
	
	
});
