/*
 * jQuery JavaScript Library v1.3.2
 */

/* IE Fix*/
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('footer');

//$.html5(); // initialize html elements for IE

 
 $(document).ready(function(){


    $.reject({  
        reject: {  
            msie6: true, // Microsoft Internet Explorer  
            msie7: true, // Opera  
			msie8:false,
			safari4:true
        },
		display: ['safari','firefox','chrome','opera'], // Displays only firefox, chrome, and opera 
		closeCookie: true // Set cookie to remmember close for this session  
    }); // Customized Browsers  
      

	
	$.fn.pause = function(duration) {
		$(this).animate({ dummy: 1 }, duration);
		return this;
	};
  
	function animateResults(){  
		var count = 0;
		$(".statistics .stat").each(function(){  
			count+=250;
			$(this).children().hide().pause(800+count).fadeIn();
			var percentage = $(this).css("width");  

			$(this).css({width: "0%"}).pause(500+count).animate({  
				width: percentage}, 1500+count,'easeOutCirc');  
				
				
		});  
	}  
	animateResults();

  
  
  
  
		// Dots
		var n = $(".image_browser .images").children().size();
/*		var n = $(".div_browser .images").children().size();		*/
		
		var currentdot = 1;
		
		for(i=0; i<n; i++){
			add_dot(i);
		}
		
		
		var references = n+1;
		//var move_width = 700;
/*		var move_width = $(".image_browser").width();*/
		var move_width =  944;
		var max_width = -1*(move_width*references);
		var timeonscreen = 6000;
		
		var autoslide = true;
		if ($(".slide_images").length) { var autoslide = false; }
		
		function autosliding(){
			if(autoslide == true){
				$(".dot_active").removeClass("dot_active").addClass("dot_inactive");			
				if(currentdot < n){
					currentdot++;
				}else{
					currentdot  = 1;
				}
				/*
	
				*/
				var element = $("#"+currentdot);
	
				$("#"+(currentdot-1)).removeClass("dot_inactive").addClass("dot_active");			
				var nextmargin = (currentdot-1)*move_width;
				slide_to_margin(-nextmargin);
				// slide to currentdot
				
			}
		}		

		var timer = window.setInterval(autosliding, timeonscreen);
		
		
		// add navigation dots
		
		function add_dot(int){
			if(int != 0){
				$(".slider_control").append('<li><a href="#next" class="dot_inactive dot" id="'+int+'">Picture '+i+'</a></li>');	
			}else{
				$(".slider_control").append('<li><a href="#next" class="dot_active dot" id="'+int+'">Picture '+i+'</a></li>');		
			}
		}
		
		$(".dot").click(function(){
	//		alert('activate: '+$(this).attr('id'));
			$(".dot_active").removeClass("dot_active").addClass("dot_inactive");			
			$(this).removeClass("dot_inactive").addClass("dot_active");			
			var nextmargin = parseInt($(this).attr('id'))*move_width;
			currentdot = parseInt($(this).attr('id'))+1;
			slide_to_margin(-nextmargin);
			window.clearInterval(timer);
			timer = window.setInterval(autosliding, timeonscreen);
	//		alert('currentdot: '+currentdot)
			return false;
		});
		
		function slide_to_margin(margin){
			//alert(margin)
	
				
	//		$('.images').stop().animate({"marginLeft": (margin) + "px"}, 1400,'easeOutBounce');			
			$('.images').stop().animate({"marginLeft": (margin) + "px"}, 1400,'easeOutCirc');				
		}
		
		
		// mouseover dots. alpha 80		
		
		
		
		$('.images')
		.mouseover(function(){
			$('.dots').stop().animate({opacity: 0.8}, 1400,'easeOutCirc');			

			
		})
		.mouseout(function(){
			$('.dots').stop().animate({opacity: 0.1}, 1400,'easeOutCirc');												   
			
		})
		
		$('.dots')
		.mouseover(function(){
			$('.dots').stop().animate({opacity: 0.8}, 1400,'easeOutCirc');			

			
		})
		.mouseout(function(){
			$('.dots').stop().animate({opacity: 0.1}, 1400,'easeOutCirc');												   
			
		})
		
		
		$('.dots').stop().animate({opacity: 0.1}, 1400,'easeOutCirc');		
		
		
		
		/* medarbejderinfo */
		
		$('.info_containers .box')
		.mouseover(function(){
			var target = $(this).attr("id");
			$("#info_"+target).stop().animate({opacity: 0.9}, 600,'easeOutCirc');
/*			$(".box").stop().animate({opacity: 0.0}, 500,'easeOutCirc');												   			*/
		})
		.mouseout(function(){
			var target = $(this).attr("id");

			$("#info_"+target).stop().animate({opacity: 0.0}, 1400,'easeOutCirc');
/*			$(".box").stop().animate({opacity: 1.0}, 500,'easeOutCirc');												   			*/
			
		})
		
		/* medarbejderbilled */
		
		$('.medarbejdere')
		.mouseover(function(){
			var target = $(this).attr("id");
			$("#img_"+target).stop().animate({opacity: 0.9}, 600,'easeOutCirc');
/*			$(".box").stop().animate({opacity: 0.0}, 500,'easeOutCirc');												   			*/
		})
		.mouseout(function(){
			var target = $(this).attr("id");

			$("#img_"+target).stop().animate({opacity: 0.0}, 1400,'easeOutCirc');
/*			$(".box").stop().animate({opacity: 1.0}, 500,'easeOutCirc');												   			*/
			
		})
			
  
  
  
  
 });
