	// PRELOADER

    var preload0 = new Image();
    var preload1 = new Image();
    
    var hover0 = new Image();
    var hover1 = new Image();
    var hover2 = new Image();
    var hover3 = new Image();
    var hover4 = new Image();
    var hover5 = new Image();
    var hover6 = new Image();
    var hover7 = new Image();
    
	preload0.src="gfx/preloader_swirl.gif";
	preload1.src="gfx/preloader_bg.png";	

    hover0.src="GFX/top_bar_icon_contact1.png";		
    hover1.src="GFX/top_bar_icon_info1.png";		
    hover2.src="GFX/quicklinks_link_icon1.png";		
    hover3.src="GFX/back_link_icon1.png";		
    hover4.src="GFX/section_nav_icon_left1.png";		
    hover5.src="GFX/section_nav_icon_right1.png";		
    hover6.src="GFX/video_bt1.png";		
    hover7.src="GFX/load_more_cases1.png";		



	// VARIABLES
	var arrVideos = [	"19285885",
						"19285980",
						"",
						"19469597",
						"",
						"",
						"19595749",
						"19185978",
						"19222565",
						"19679772",
						"",
						"19676144",
						"19596201",
						"",
						""];
	var loadedCases = 0;	


	$(document).ready(function(){
		
		$(document).cdzPreloadImages(function(total){/*start */}, function(loaded, total){/* progress */}, function(){showContent()} );
		function showContent() {
			
				setTimeout(function() { $('#main').show();$('#preloader').animate({opacity: 0}, 1000, 'easeInOutExpo',function() {

					$("#top_wrapper").animate({top: '-171px'} ,400,'easeOutExpo');		
					$("#pin").animate({opacity: 0} ,200).animate({right: '200px', opacity: 1} ,400,'easeOutElastic');					
					
					$("#logo").animate({opacity: 0} ,320).animate({opacity: 1, left: '-43px'},1000,'easeOutElastic');		
					$('#preloader').remove();

					setTimeout(function() {$('#suburb_byttorp').animate({opacity: 1} ,300,'easeOutElastic');}, 500);
					setTimeout(function() {$('#suburb_hestra').animate({opacity: 1} ,1000,'easeOutElastic');}, 550);
					setTimeout(function() {$('#suburb_bergdalen').animate({opacity: 1} ,1000,'easeOutElastic');}, 600);
					setTimeout(function() {$('#suburb_bramhult').animate({opacity: 1} ,1000,'easeOutElastic');}, 650);
					setTimeout(function() {$('#suburb_sormarken').animate({opacity: 1} ,1000,'easeOutElastic');}, 700);
					setTimeout(function() {$('#suburb_trandared').animate({opacity: 1} ,1000,'easeOutElastic');}, 750);
					setTimeout(function() {$('#suburb_kristineberg').animate({opacity: 1} ,1000,'easeOutElastic');}, 800);

					
				});}, 2000);
		}

	
		// Social icons hover
		$(".footer_icon").hover(
			function () {
				$(this).stop().animate({"opacity": "1"}, 350);
			}, 
			function () {
				$(this).stop().animate({"opacity": "0.3"}, 350);
			}
		);	
		
		
		// VCARD
		$("#phone_content").hover(
			function () {
				$('#vcard').stop().animate({"opacity": "1", "top": "-70"}, 400,'easeInOutExpo');
				$('#phone_content_hover').fadeIn(400,'easeInOutExpo');
				$('#phone_highlight').stop().animate({"opacity": "0.8"}, 400,'easeInOutExpo');

			}, 
			function () {
				$('#vcard').stop().animate({"opacity": "0", "top": "-55"}, 400,'easeInOutExpo');
				$('#phone_content_hover').fadeOut(400,'easeInOutExpo');
				$('#phone_highlight').stop().animate({"opacity": "0"}, 400,'easeInOutExpo');

			}
		);
		
		
		$("#phone_content").click(function(){
  			window.location = 'http://www.linuslerge.com/vcard/linuslerge.vcf';
		});	
		
		

			
		
	
	});
	
	
	// LOAD MORE CASES	
	
	function loadCases() {
		
		if(loadedCases < 1){
			$("#load_more_cases").append("<img src='gfx/preloader_swirl.gif' width='24px' height='24px' style='margin-top:15px;'>");

			$.ajax({
			  url: "cases.html",
			  cache: false,
			  success: function(html){
				
				$("#content").append(html);
				
				$("#load_more_cases").animate({opacity: 1},1000).animate({opacity: 0},500,'easeInOutExpo' , function() {
					$('#load_more_cases').remove();
				});
	
				setTimeout(function() {
					$("#main").animate({height: String($("#main").height() + 7640) + 'px'},2600,'easeInOutExpo');
					$("#content").animate({height: String($("#content").height() + 7760) + 'px'},2600,'easeInOutExpo');
			//		$('#case2 .webwidget_slideshow_dot').append("<div class='next_case' onMouseOver='$(this).css('background-image', 'url(GFX/quicklinks_link_icon1.png)');' onMouseOut='$(this).css('background-image', 'url(GFX/quicklinks_link_icon0.png)');' onClick='scrollPage('#case3', 1000);'></div>");	
					
				}, 1500);
				
			  }
			});   		

			loadedCases++
		}
	}


	// SCROLL

	function scrollPage(variable, time) {
		$('html, body').animate({
			scrollTop: $(variable).offset().top-15
		}, time, 'easeInOutExpo');
		
	}
	


	// VIDEO PREVIEW
	
	function handleVideo(index){
	
		if ($('#case'+index+' .video_container').length == 0) {
		
			$('#case'+index+' .videos').append("<img src='gfx/preloader_swirl.gif' width='24px' height='24px' style='margin-left:10px;' class='video_preloader'>");
			$('.video_container').remove();
			$('#case'+index+' .screen .slideshow').append("<div class='video_container' style='display:none;'><iframe src='http://player.vimeo.com/video/" + arrVideos[index] + "?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff' width='723' height='425' frameborder='0' id='movie_frame'></iframe></div>");	
			$('.video_container #movie_frame').css('margin-top', '422px');
			$('#case'+index+' .screen .slideshow .video_container').fadeIn(900, 'easeOutExpo');
			
			setTimeout(function() {
				$('.video_preloader').remove();
				$('.video_container #movie_frame').animate({marginTop: '0px'}, 1500, 'easeInOutExpo');
				$('#main').append("<div id='movie_fader' onClick='eraseFade();'></div>");
				$('#movie_fader').fadeIn(600, 'easeInOutExpo');

				$('#main').append("<div id='tooltip'></div>");

				
				$("#movie_fader").mousemove(function(e){
        			$("#tooltip").fadeIn(100);
        			$("#tooltip").css({
           			 top: (e.pageY + 10) + "px",
           			 left: (e.pageX + 10) + "px"
        			});
    			});
    			
    			$("#movie_fader").mouseout(function(e){
       				//$("#tooltip").hide();
       				$("#tooltip").fadeOut(100)
    			});					
				
			}, 2000);



		}
	}
	
	function eraseFade(){
		$('#movie_fader').remove();
		$('.video_container').remove();
		$("#movie_fader").die("mousemove");
		$("#movie_fader").die("mouseout");
		$("#tooltip").remove();
	}
	

	
	






