window.fbAsyncInit = function() {
  FB.Canvas.setAutoGrow(91);
}


$(document).ready(function(){
  
  
  	// set standard easing
	jQuery.easing.def = "easeInOutExpo";
  	
	var counter = 0;
	var selectedID = 1;	
  	var headerWidth = $("#accordionNL li header").width();
	var componentWidth = $("#accordionNL").width();
  	var totPages;
	var cycleSpeed = 5000;
	var intervalId;
  
  
  	initAccordeon();
  	updateItems(selectedID);
	
	intervalId = setInterval(next, cycleSpeed);
	
  	
  	$("#accordionNL li header").click(function(){
		
		window.clearInterval(intervalId);
		
		selectedID = parseInt($(this).parent().attr("data-nr"));
		updateItems(selectedID)

	});
	
	
	function initAccordeon(){
		
		totPages = $("#accordionNL").find('li').size();
		
		$("#accordionNL li .content").each(function(i){
				
			$(this).css("min-width",componentWidth-(headerWidth*(totPages)));
		});
	}
	
	
	
	function updateItems(sID){
		
		$("#accordionNL li").each(function (i) {
	   
	   		var id = parseInt($(this).attr("data-nr"));
			
	   
	   	   if( id <= sID){
				//$(this).offset({left:(id-1)* headerWidth});	
				$(this).animate({left:Math.floor((id-1)* headerWidth)-1});
				
		   }else{
			   //$(this).offset({left: componentWidth - (headerWidth*(totPages-id+1))});
			   $(this).animate({left: Math.floor(componentWidth - (headerWidth*(totPages-id+1)))-1});	
		   }
		
		});
		
	}
	
	function next(){
		
		if(selectedID < totPages){
			selectedID++;
		}else{
			selectedID = 1;
		}
		
		updateItems(selectedID);
	}
	
});
$(document).ready(function(){
  
  
  	// set standard easing
	jQuery.easing.def = "easeInOutExpo";
  	
	var counter = 0;
	var selectedID = 1;	
  	var headerWidth = $("#accordionFR li header").width();
	var componentWidth = $("#accordionFR").width();
  	var totPages;
	var cycleSpeed = 5000;
	var intervalId;
  
  
  	initAccordeon();
  	updateItems(selectedID);
	
	intervalId = setInterval(next, cycleSpeed);
	
  	
  	$("#accordionFR li header").click(function(){
		
		window.clearInterval(intervalId);
		
		selectedID = parseInt($(this).parent().attr("data-nr"));
		updateItems(selectedID)

	});
	
	
	function initAccordeon(){
		
		totPages = $("#accordionFR").find('li').size();
		
		$("#accordionFR li .content").each(function(i){
				
			$(this).css("min-width",componentWidth-(headerWidth*(totPages)));
		});
	}
	
	
	
	function updateItems(sID){
		
		$("#accordionFR li").each(function (i) {
	   
	   		var id = parseInt($(this).attr("data-nr"));
			
	   
	   	   if( id <= sID){
				//$(this).offset({left:(id-1)* headerWidth});	
				$(this).animate({left:Math.floor((id-1)* headerWidth)-1});
				
		   }else{
			   //$(this).offset({left: componentWidth - (headerWidth*(totPages-id+1))});
			   $(this).animate({left: Math.floor(componentWidth - (headerWidth*(totPages-id+1)))-1});	
		   }
		
		});
		
	}
	
	function next(){
		
		if(selectedID < totPages){
			selectedID++;
		}else{
			selectedID = 1;
		}
		
		updateItems(selectedID);
	}
	
});
