	var NavInterval;
	var ContentInterval;

/*@cc_on
(function(f){
 window.setTimeout =f(window.setTimeout);
 window.setInterval =f(window.setInterval);
})(function(f){return function(c,t){var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)}});
@*/

function moveIt(parent, el, direction, speed, interval) {
	
	if(direction == "up") {
		var pos = 0;
		var toPos = parseInt(el.css('top')) + speed;
		el.css('top', toPos);
		
		if(parseInt(el.css('top')) > 0 ) {
			el.css('top', 0);
			clearInterval ( interval );
			return false;
		}
		
		
	}else if(direction == "down") {
		var pos = parent.height() - el.outerHeight();
		
		if(parseInt(el.css('top')) <= pos ) {
			
			el.css('top', pos);
			clearInterval ( interval );
			return false;
		}
		
		var toPos = parseInt(el.css('top')) - speed;
		el.css('top', toPos);
	}else {
		
	}	
}
		
$(document).ready(function() {
		
		// For use within normal web clients 
		var isiPad = navigator.userAgent.match(/iPad/i) != null;
		if(isiPad) {
			$('#kandidatenDetails .kandidaatDetails .ContentContainer').each(function(index, el) {
				new iScroll($(el).attr('id'), { hScrollbar: false, vScrollbar: true});
			});
			
			$('#kandidatenDetails .kandidaatDetails .ContentContainer .ContentNavigation').css('display','none');
			
			if($('#IpadTestimonial').length) {
				
				$('#ContentNavigation').css('display','none');
				new iScroll('IpadTestimonial', { hScrollbar: false, vScrollbar: true});
			}
		}
		
		if($('#NewsCarousel').length) {
			
			$('#NewsCarousel li').click(function(e) {
				e.preventDefault();
				
				var link = $(this).find('a').attr('href');
				window.location.href = link;
			});
			
			if($('#NewsCarousel li.Current').length) {
				var start = Number($('#NewsCarousel li.Current').attr('id'));
			}else {
				var start = 1;
			}
			
			$('#NewsCarousel').jcarousel({
				'scroll': 2,
				'easing':'easeOutQuad',
				'start':start
			});
		}
		
		if($('#kandidaten').length) {
			
			$('#kandidaten li').click(function(e) {
				e.preventDefault();
			});
			
			if($('#kandidaten li.Current').length) {
				var start = Number($('#kandidaten li.Current').attr('id'));
			}else {
				var start = 1;
			}
			
			$('#kandidaten').jcarousel({
				'scroll': 1,
				'easing':'easeOutQuad',
				'start':start,
				'buttonNextHTML':null,
				'buttonPrevHTML':null
			});
		}
		
		if($('#kandidaten li').length) {
			
			$('#kandidaten li').click(function() {
				var clicked = $(this);
				
				$('.my-jcarousel-prev,.my-jcarousel-next').fadeOut(500,'easeOutExpo', function () {
				
				});
				
				
				$('#kandidaten').animate({
					top: '-165px'
				}, {
					duration: 300,
					specialEasing: {
						width: 'easeInQuad'
				    },
				    complete: function() {
				    	$('.kandidatenwrapper').animate({
							height: '315px'
						}, {
							duration: 200,
							specialEasing: {
								width: 'easeInQuad'
						    },
						    complete: function() {
						    	
						    	var link = '#'+$(clicked).find('a').attr('href');
								$(link).animate({
									top: '0'
								}, {
									duration: 300,
									specialEasing: {
										width: 'easeInQuad'
								    },
								    complete: function() {
								    	var current = this;
								    	var speed = 3;
								    	
								    	$('.jcarousel-container').css('display','none');
								    	
								    	if(!isiPad) {
									    	$(current).find(".NavDown").bind('mouseenter click', function() {
												clearInterval ( ContentInterval );
												ContentInterval = setInterval (moveIt,20,$(current).find(".ContentContainer"), $(current).find(".ContentContainer .Content"), "down", speed, ContentInterval);
												
											}).bind('mouseleave', function() {
												clearInterval ( ContentInterval );
											});
											
											$(current).find(".NavUp").bind('mouseenter click', function() {
												clearInterval ( ContentInterval );
												ContentInterval = setInterval (moveIt,20,$(current).find(".ContentContainer"), $(current).find(".ContentContainer .Content"), "up", speed, ContentInterval);
												
											}).bind('mouseleave', function() {
												clearInterval ( ContentInterval );
											});
										}
								    }
								});
						    }
						});
				    }
				});
								
			});
			
			$('#kandidatenDetails .kandidaatDetails .Close').click(function() {
				var clicked = $(this);
				$('.jcarousel-container').css('display','block');
				
				
				$('.my-jcarousel-prev,.my-jcarousel-next').fadeIn(500,'easeOutExpo', function () {
				
				});
				
				$(clicked).parents('.kandidaatDetails').animate({
					top: '-300px'
				}, {
					duration: 300,
					specialEasing: {
						width: 'easeInQuad'
				    },
				    complete: function() {
				    	
				    	$('.kandidatenwrapper').animate({
							height: '180px'
						}, {
							duration: 200,
							specialEasing: {
								width: 'easeInQuad'
						    },
						    complete: function() {
						    	$('#kandidaten').animate({
									top: '0'
								}, {
									duration: 300,
									specialEasing: {
										width: 'easeInQuad'
								    },
								    complete: function() {
								    	
								    	$('.my-jcarousel-prev,.my-jcarousel-next').fadeIn(500,'easeOutExpo', function () {
				
										});
								    	
								    	clearInterval ( ContentInterval );
								    	$("#kandidatenDetails .kandidaatDetails .ContentContainer .Content").css("marginTop",0);
								    	
								    }
								});
						    }
						});
				    }
				});
								
			});
			
			if(!isiPad) {
			
				$('#kandidaten li').mouseenter(function() {
					
					$(this).find('.Container').stop();
					$(this).find('.Container').animate({
						left: '-161px'
					}, {
						duration: 300,
						specialEasing: {
							width: 'easeInExpo'
					    },
					    complete: function() {
					    	
					    }
					});
					
				}).mouseleave(function() {
					$(this).find('.Container').stop();
					$(this).find('.Container').animate({
						left: '0'
					}, {
						duration: 300,
						specialEasing: {
							width: 'easeOutExpo'
					    },
					    complete: function() {
					    	
					    }
					});
				});
			}
		}
		
		$('#TestimonialContainer').click(function(e) {
			e.preventDefault();
			openTestimonial();
			
		});
		
		$('#Close').click(function(e) {
			e.preventDefault();
			closeTestimonial();
			
		});

		if($('#TestimonialContainer').length) {
		
			$('#TestimonialContainer').css('background-image', 'url('+window.campaign_large_image+')');
			$('#TestimonialContainer').css('background-position', '-60px 0');
			$('#Testimonial').hide();
			
			var speed = 3;
			
			$("#NavDown").bind('mouseenter click', function() {
				clearInterval ( NavInterval );
				NavInterval = setInterval (moveIt,20,$("#Testimonial .Content"), $("#Testimonial .Content li:first"), "down", speed, NavInterval);
				
			}).bind('mouseleave', function() {
				clearInterval ( NavInterval );
			});
			
			$("#NavUp").bind('mouseenter click', function() {
				clearInterval ( NavInterval );
				NavInterval = setInterval (moveIt,20,$("#Testimonial .Content"), $("#Testimonial .Content li:first"), "up", speed, NavInterval);
				
			}).bind('mouseleave', function() {
				clearInterval ( NavInterval );
			});
						
		}
		
		$('.my-jcarousel-prev').click(function(e) {
			e.preventDefault();
			
			var carousel = $('#kandidaten').data('jcarousel');
			jQuery('#kandidaten').jcarousel('prev');
			
		});
		
		$('.my-jcarousel-next').click(function(e) {
			e.preventDefault();
			
			var carousel = $('#kandidaten').data('jcarousel');
			jQuery('#kandidaten').jcarousel('next');
		});
		
		
});

function openTestimonial() {
	
	$('#TestimonialContainer').unbind();
	
	var quotepos = 0 - (30 + $('#Quote').width());
	
	$('#Quote').animate({
        'left': quotepos+'px',
        'opacity':0
	}, 
		500,
		'easeOutExpo'
	);
	
	$('#TestimonialContainer').animate({
		width: '840px'
	}, {
		duration: 500,
		specialEasing: {
			width: 'easeInExpo'
	    },
	    complete: function() {
	    	$('#Testimonial').fadeIn(500,'easeOutExpo');
	    }
	});	
	
	$('#TestimonialContainer').animate({
        backgroundPosition: '0 0'
	}, 
		500, 
		'easeOutExpo'
	);
}

function closeTestimonial() {
	
	$('#Testimonial').fadeOut(500,'easeOutExpo', function () {
	
	});
	$('#TestimonialContainer').animate({
		width: '335px'
	}, {
		duration: 500,
		specialEasing: {
			width: 'easeInExpo'
	    }
	});
	
	$('#Quote').animate({
        'left': '30px',
        'opacity':1
	}, 
		500, 
		'easeOutExpo'
	);
	
	$('#TestimonialContainer').animate({
        	backgroundPosition: '-60px 0'
		}, 
		500, 
		'easeOutExpo', 
		function() {
			clearInterval ( NavInterval );
			$("#Testimonial .Content li:first").css("marginTop",0);
			
			$('#TestimonialContainer').bind('click', function(e) {
				
				e.preventDefault();
				openTestimonial();
				
			});
			
		}
	);
	
}
