$(document).ready(function(){

	// save page number
	var page = 1;
	// set default speed of animations
	var speed = 600;
	// show even more button
	$('#bt-even-more').show();

	// add other titles
	$('#headerTitles').html('<img src="/static/imgs/casestudies_new/voila-2_en.png" id="voila-2" /><img src="/static/imgs/casestudies_new/voila-3_en.png" id="voila-3" />');

	// add class to who has link
	$('#content_cases_strip li > a').each(function() {
		$(this).parent().addClass('linked');
	});

	// apply click event to container
	$('div.cases li.linked').click(function() {
		location.href = $('a',this).attr('href');
	});

	// underline see more link on container over
	$('div.cases li.linked').hover(
		function(){
				$(this).addClass('on');
		},
		function() {
				$(this).removeClass('on');
		});

	// reset all elements
	function resetAll(n) {
		// save page number
		page = n;
		// hide all buttons of the header
		$('#header_cases a').hide();
	}

	// click event of button even more
	$('#bt-even-more').click(function() {
		// hide title 3 and show 2
		$('#voila-3').hide();
		$('#voila-2').show();
		// save old page info
		var old_page = page;
		// reset all elements
		resetAll(2);
		// show button full list
		$('#bt-back-01').show();
		$('#bt-full-list').show();
		// animate left
		$('#content_cases_strip').animate({left:-900}, speed);
		return false;
	});

	// click event of button full list
	$('#bt-full-list').click(function() {
		// hide title 2 and show 3
		$('#voila-2').hide();
		$('#voila-3').show();
		// save old page info
		var old_page = page;
		// reset all elements
		resetAll(3);
		// show back button
		$('#bt-back').show();
		// animate left
		$('#content_cases_strip').animate({left:-1800}, speed);
		return false;
	});

	// click event of back button
	$('#bt-back, #bt-back-01').click(function() {
		// hide all titles
		$('#voila-3').hide();
		$('#voila-2').hide();
		// save old page info
		var old_page = page;
		// reset all elements
		resetAll(1);
		// show even more button
		$('#bt-even-more').show();
		// animate left
		$('#content_cases_strip').animate({left:0}, speed);
		return false;
	});


	// borders on hover
	$(".border").css({opacity:"0.0"});
	/*
	$(".cases li").hover(
		function(){
		$(this).find(".border").animate({opacity:"1.0"}, 200);
		},
		function() {
		$(this).find(".border").animate({opacity:"0.0"}, 200);
		}
	);
	*/

	// change border color on mouse down.. back to normal mouseup
	 $(".cases li").mousedown(function(){
      $(this).find(".border").css({borderColor:"#ED228E"});
    }).mouseup(function(){
      $(this).find(".border").css({borderColor:"#CCCCCC"});
    });



});