	// ---------------------------------------------
	// Var
	// ---------------------------------------------

	var path = "js/data_.js";
	var dataCase = {};
	var caseSelected = 0;
	var itemSelected = 0;
	var lengthCase = 0;
	var loading = false;
	var _speed = 500;
	var _easing = 'easeInOutCubic';
	var slideShowDisplay = false;
	var firstTime = true;
	
	// ---------------------------------------------
	// Cufon - css
	// ---------------------------------------------

	Cufon.replace("#logo", {hover: true, fontFamily: "gotham"});
	Cufon.replace("#nav li a", {hover: true, fontFamily: "gotham"});
	Cufon.replace("#worksNav li a", {hover: true, fontFamily: "gotham"});
	Cufon.replace("#profilNav li a", {hover: true, fontFamily: "gotham"});
	//Cufon.replace("#titleMenu", {hover: true, fontFamily: "gotham"});
	//Cufon.replace("#biography a, #titleMenu", {hover: true, fontFamily: "gotham"});
	//Cufon.replace("#exhibitions div", {hover: true,  fontFamily: "gotham"});
	//Cufon.replace("#contact div", {hover: true,  fontFamily: "gotham"});
	

$(function () {
	
	// ---------------------------------------------
	// load json
	// ---------------------------------------------
		
			$.ajax({url: path,
	   		contentType: "application/json; charset=utf-8",
			dataType: "json",
			success: function(data) {
			 dataCase = data;
			 lengthCase = dataCase.showcase[caseSelected].items.length;
			 LoadImage();
			// alert("datacase" + dataCase.showcase[0].items.length);
			}
			});	
		
		
	// ---------------------------------------------
	// menu
	// ---------------------------------------------	
		
	$("#worksNav, #profilNav ").hide();

	
	$("#worksNav, #profilNav ").mouseover(function()
	    {
	    	$(this).addClass("over");
	    });
	    
	
	$("#worksNav, #profilNav ").mouseout(function()
	    {
	    	$(this).removeClass("over");
	    });
	    

	$("#worksNav li a").click(function()
	    {	
	    
	   		checkSectionSelected("#worksNav");
	    	itemSelected = 0;
	    	caseSelected = $("#worksNav li a").index(this)+1;
	    	lengthCase = dataCase.showcase[caseSelected].items.length;
	    	
	    	$(current).fadeOut(300, function(){
						$(current).remove();
						LoadImage();
						
					});
	   
	   
	   		
			$("#worksNav li a").each(function(){
			$(this).removeClass('selected');
			});
			$(this).addClass('selected');
	    	Cufon.refresh();
	    	
	    	createThumb();
		 	return false;	
	    });	
	
	$("#profilNav li a").click(function()
	    {	
	    
	   		//var profilSelected = $("#profilNav li a").index(this);
	   		checkSectionSelected("#profilNav")
	   
		
			$("#profilNav li a").each(function(){
			
			$(this).removeClass('selected');
			});
			
			$(this).addClass('selected');
				
	   	 	
	   	 	var mc = $(this).attr('rel');
	 
			$(".displayAboutTxt").empty();
			
			$('#'+mc).clone().appendTo('.displayAboutTxt').show();
			Cufon.refresh();
			$(".lineLeft").height($(window).height());
			$(".lineLeft").height($(document).height());
			
	   	 	
		 	return false;	
	    });	
	

	function checkSectionSelected(selected)
	{	
	
		$(selected).removeClass("over");
		MouseOut(selected);
		
		
		
	
		if(selected == "#profilNav") 
		{
			$("#content").hide();
	   		$(".displayAboutTxt").show();
	   		 $("#worksNav li a").each(function(){
			$(this).removeClass('selected');
			});

	   	
		}
		else
		{	
			$("#content").show();
	    	$(".displayAboutTxt").hide();
	    	$("#profilNav li a").each(function(){
			$(this).removeClass('selected');
			});

		
		}
		
	
	}
		
	$("#works").hover(function() {
				
	    	$("#profilNav ").slideUp(150);
	    	
	    	
		   	 
			$(this).doTimeout('hover',200, function(){
					$("#worksNav").slideDown({duration:200 , easing: 'easeInOutCubic'});
			});
			},function() {
			$(this).doTimeout('hover',500, function(){
					MouseOut("#worksNav");
			});
			
		});		
		
			
		
	$("#profil").hover(function() {
		$("#worksNav ").slideUp(150);
				
			
			$(this).doTimeout('hover',200, function(){
					$("#profilNav").slideDown({duration:200 , easing: 'easeInOutCubic'});
			});
			},function() {
			$(this).doTimeout('hover',500, function(){
					MouseOut("#profilNav");
			});
		});		
		
		
		function MouseOut(_id){

			if ($(_id).hasClass("over"))
			{
     				$(_id).mouseleave(function(){
     				$(_id).slideUp({duration:400 , easing: 'easeInOutCubic'});
     			});
     		}
     		else
     		{
     			$(_id).slideUp({duration:400 , easing: 'easeInOutCubic'});
     		}  
		}
		
		
			
	// ---------------------------------------------
	// gallery
	// ---------------------------------------------	
	
	$("#imgGallery").click(function()
	    {	
	   			
	    	if(lengthCase > 1){
	    	
	    		if (!loading) {

	    		itemSelected = itemSelected + 1;
	    			if (itemSelected >= lengthCase) itemSelected = 0;
	    			LoadImage();
	    		 }
	    	}
	    	
	   	 	return false;	
	    });	


	// ---------------------------------------------
	// CreateThumb
	// ---------------------------------------------	
	
	function createThumb(){
		 
		 $('#thumb').empty();
		 
		 for(var i = 1; i < lengthCase + 1; i++){
		 
			  $('#thumb').append('<a href="#" id='+i+' class="btnThumb">_</a>');
			  
		 }
		 
		 
		 
		 
		 $('#thumb a:first-child').addClass('selected');
		 
		  $('#thumb a').each(function(index) {
		  
		  			  	
			$(this).click(function(){
			
				itemSelected = ($(this).attr('id'))-1;
				LoadImage();	
				return false;
				
				})
				
			});

	
	
	}
		
	function highLightThumb(){
	
		
			$("#thumb a").each(function(){
			
			$(this).removeClass('selected');
			});
			
						
			$('#thumb a[id=' + (itemSelected +1 )+ ']').addClass('selected');
			
	
	
	}
	
		
	// ---------------------------------------------
	// 3. load
	// ---------------------------------------------		

	
	function LoadImage(){
	
		checkColor();
		highLightThumb();
		
		var pathImg = dataCase.showcase[caseSelected].items[itemSelected].img
	
		if (!loading) {
	
			loading = true;
		
			
			$('#imgGalleryLoading').animate({opacity: 1}, 200);
					
			$('<div id="portfolio_'+ itemSelected +'"></div>').appendTo('#imgGallery');	
			current = $("#imgGallery #portfolio_"+ itemSelected);
		
		
			
			var img = new Image();
			$(img).load(function () {
				
				$(current).append(this);
				$('#imgGalleryLoading').animate({opacity: 0}, 100);
				
			
				if(typeof currImage != 'undefined'){
				
				
				$(currImage).fadeOut(500, function(){
				
                	 $(this).remove();
                	 
                });
                
                
                }
                $("#imgGallery").delay(200).animate({height: $(current).height()}, 300, function() {
                                
                    				
				  });
				
			
 				$("#imgGallery #portfolio_"+ itemSelected ).delay(400).hide().fadeIn(500, function(){
						$('#info').empty().html(dataCase.showcase[caseSelected].items[itemSelected].title);
						loading = false;
						
					});
                

              
				currImage = current;
		
				
				
								
			}).error(function () {
				$(current).remove();
			}).attr('src', pathImg);
			
		}
		
	}	
	
	
	// ---------------------------------------------
	// 3. check color
	// ---------------------------------------------	
	
	
	function checkColor()
	{
	

		if (caseSelected == 4){
			$('body').animate({backgroundColor: '#ffffff'});	
			$('#imgGallery').animate({backgroundColor: '#ffffff'});
			$('#logo').removeClass("darkSide");
			$('#worksNav li a').removeClass("darkSide");
			Cufon.refresh();
		}
		
		else if (caseSelected == 5){
		
			$('body').animate({backgroundColor: '#000000'});
			$('#imgGallery').animate({backgroundColor: '#000000'});
			$('#logo').addClass("darkSide");
			$('#info').addClass("darkSide");
			$('#nav li a').addClass("darkSide");
			$("#worksNav li a").each(function(){
			$(this).removeClass('selected');
			});
		
			$($('#worksNav a').get(4)).addClass('darkSide');
			
			Cufon.refresh();
		
		}
		else
		{
			$('body').animate({backgroundColor: '#ffffff'});
			$('#imgGallery').animate({backgroundColor: '#000000'});
			$('#logo').removeClass("darkSide");
			$('#profilNav li a').removeClass("darkSide");
			$('#worksNav li a').removeClass("darkSide");
			Cufon.refresh();

		} 
		
	
	
	}
	
	
	
	
});




	
	
	


