//author: Søren Østergaard
//client: Nodo Arktitekter

$(document).ready(function(){
	
	//Slideshow
		
	$('#photos img').css('opacity','0');
	$('#photos img:last').css('opacity','1');
	
	setTimeout(showImg, 4000);
	
	function showImg(){
		$('#photos img').css('opacity','1');
	};
	
	setTimeout(slideShow, 5000);
		
	function slideShow(e) {			
		$('.a').css('zIndex', '3').fadeOut(0).fadeIn(500);
		$('.b').css('zIndex', '2');
		$('.c').css('zIndex', '1');
		
		var current = $('.a');
		var prev = current.prev().length ? current.prev() : current.parent().children(':last');
		var next = current.next().length ? current.next() : current.parent().children(':first');
		
		$(current).addClass('b').removeClass('a').removeClass('c');		
		$(next).addClass('a').removeClass('b').removeClass('c');
		$(prev).addClass('c').removeClass('b').removeClass('a');
		
		setTimeout(slideShow, 5000);
	};

	//Thumbs functionality in caseview
	
	$('#cases_container_noscroll > img').css('opacity', 0);
	$('#cases_container_noscroll :nth-child(3)').css('opacity', 1);
	
	$('#case_thumbs :nth-child(1)').click(function(){
		$('#cases_container_noscroll > img').css('opacity', 0);
		$('#cases_container_noscroll :nth-child(3)').css('opacity', 1);
	});
	
	$('#case_thumbs :nth-child(2)').click(function(){
		$('#cases_container_noscroll > img').css('opacity', 0);
		$('#cases_container_noscroll :nth-child(2)').css('opacity', 1);
	});
	
	$('#case_thumbs :nth-child(3)').click(function(){
		$('#cases_container_noscroll > img').css('opacity', 0);
		$('#cases_container_noscroll :nth-child(1)').css('opacity', 1);
	});

	//Menu 'Team' hover
	$('.upunkt').css({display: "none"}, 0);
	
	$("#menu_omos").mouseover(function () {
   		$('.upunkt').css({display: "block"}, 0);
  	});

	$("#menu_omos").mouseout(function () {
   		$('.upunkt').css({display: "none"}, 0);
  	});
  	
  	$("#menu_omos").click(function () {
   		$('.upunkt').css({display: "block"}, 0);
  	});

  	//Menu hover
  		
  	$("#menu_erhverv, #menu_offentlig, #menu_bolig, #menu_erhverv, #menu_omos, #menu_koncept, #menu_referencer, #menu_kontakt").mouseover(function() {
  		$('a', this).css('color','#555555');
   	}).mouseleave(function(){
   		$('a', this).css('color','#6e6e6e');
   	}); 
   	
   	$('#cases_container img:last').css('marginBottom','0px');

});

// Attach scrollbar
$(window).bind("load", function() {		
	$('#scrollbar1').tinyscrollbar();	
});
