text: jQuery(document).ready(function($){
  	//toggle 3d navigation
  	$('.cd-3d-nav-trigger').on('click', function(){
  		toggle3dBlock(!$('.cd-header').hasClass('nav-is-visible'));
  	});
  
  	$(window).on('resize', function(){
  		window.requestAnimationFrame(updateSelectedNav);
  	});
  
  	function toggle3dBlock(addOrRemove) {
  		if(typeof(addOrRemove)==='undefined') addOrRemove = true;	
  		$('.cd-header').toggleClass('nav-is-visible', addOrRemove);
  		$('main').toggleClass('nav-is-visible', addOrRemove);
  		$('.cd-3d-nav-container').toggleClass('nav-is-visible', addOrRemove);
  	}
  
  	//this function update the .cd-marker position
  	function updateSelectedNav(type) {
  		var selectedItem = $('.cd-selected'),
  			selectedItemPosition = selectedItem.index() + 1, 
  			leftPosition = selectedItem.offset().left,
  			backgroundColor = selectedItem.data('color');
  
  		$('.cd-marker').removeClassPrefix('color').addClass('color-'+ selectedItemPosition).css({
  			'left': leftPosition,
  		});
  		if( type == 'close') {
  			$('.cd-marker').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
  				toggle3dBlock(false);
  			});
  		}
  	}
  
  	$.fn.removeClassPrefix = function(prefix) {
  	    this.each(function(i, el) {
  	        var classes = el.className.split(" ").filter(function(c) {
  	            return c.lastIndexOf(prefix, 0) !== 0;
  	        });
  	        el.className = $.trim(classes.join(" "));
  	    });
  	    return this;
  	};
  });