$(document).ready(function() {
	var windowHeight = $(window).height();
	var windowWidth = $(window).width();
	$('#bgMain').css('min-width', windowWidth + 'px');
	$('#bgMain').css('height', windowHeight + 'px');
	var marginLeftContent = windowWidth*5/100;
	
	var windowWidthMarge = 1000 - marginLeftContent;
	var contentHeight = $('#content').height();
	var paddingContent = windowHeight - 500;
	
	$('#line').css('margin-top', paddingContent +'px');
	$('#content').css('margin-top', paddingContent +'px');
	$('#hide').css('margin-top', paddingContent +'px');
	var fixedHeight = $('#fixedContent').height();
    var fixedPadding = fixedHeight + 40;
	var logoRight = windowWidth - 164 - windowWidth*5/200;
	var logoTop = windowHeight - 20 - windowHeight*10/100;
		$('#logo').show();

	if(windowWidth>1400){
	var padHide = 1145 + marginLeftContent;
	
	$('#hide').css('left', padHide +'px');
	var paddingNewContent = windowHeight - 500;
	$('#mainContent').css('margin-left', marginLeftContent +'px');

	$('#logo').css('bottom', logoTop +'px');
	$('#logo').css('left', logoRight + 'px');

	}else {
	$('#hide').css('left', '1170px');
	$('#mainContent').css('margin-left', '25px');
	var leftLogo = 25 + 121;
	var topLogo = windowHeight - 550;
	$('#logo').css('bottom', '550px');
	$('#logo').css('left', leftLogo + 'px');
	}
	$(window).resize(function() {
		
	var newfixedHeight = $('#fixedContent').height() + 60;
	var newWindowHeight2 = $(window).height() + newfixedHeight;
	var newpaddingHeight = newWindowHeight2 - newfixedHeight;
	if($('#fixedContent').hasClass('fixed')){
	$('#content').css('height', newpaddingHeight);
	 $('#hide').css('height', '100%');
	}
	var newWindowHeight = $(window).height();
	$('#bgMain').css('height', newWindowHeight + 'px');
	$('#hide').css('left', '1170px');
  	//$('#mainContent').css('margin-left', '25px');
  	var marginLeftfixed = 25 + 335;
   // $('.fixed').css('margin-left', marginLeftfixed +'px');
    var marginLeftfixed2 = 25 + 332;
	var leftLogo = 25 + 121;
	var topLogo = windowHeight - 550;
	
	
	if($(window).width()<1490){
	$('#mainContent').css('margin-left', '25px');
	$('.fixed').css('margin-left', marginLeftfixed +'px');
	$('#logo').animate({'bottom': '550px', 'left': leftLogo + 'px'}, 10);
	
	}
	if($(window).width()>1490){
	var windowWidthl = $(window).width();
	var windowHeightl = $(window).height();
	var logoRight = windowWidthl - 164 - windowWidthl*5/200;
	var logoTop = windowHeightl - 20 - windowHeightl*10/100;
	$('#logo').animate({'bottom': logoTop +'px', 'left': logoRight + 'px'}, 10);
	}
	
	if(homenonselect){
	
	$("#content").jScrollPane();
	}
	
	});

	
	$('#mainNav.animHome').animate({"bottom": "+=500px"}, 1500);
	
	
	$('#content, #hide').not('#content.home').css('display', 'none'); 
	
	
$('#line').animate({
	width:860    
  	}, 600, function(){
  		$(this).hide();
  	  	$('#animEnter').css('margin-top', paddingContent +'px');	   	
		$('#animEnter').animate({
    	width: [860, 'swing'],
    	height: [540, 'swing']
  			}, 400, 'linear', function() {
  			$('#content, #hide').show();	
  			$('#animEnter').hide();
			$('.linktarget').click();
  			$('.showItem').each(function(){
  			var attrIdBlocr = $(this).attr('id');
  			
  			var tailleBlocr = $('#' + attrIdBlocr + ' .bloc').size();
  			for(i = 0; i < tailleBlocr ; i = i+2){ 
				var tailleBloc = $('#' + attrIdBlocr + ' .bloc .desc').eq(i).height();

				var tailleBlocAlt = $('#' + attrIdBlocr + ' .bloc .desc').eq(i+1).height();
				if(parseInt(tailleBloc, 10) > parseInt(tailleBlocAlt, 10)){
					$('#' + attrIdBlocr + ' .bloc .desc').eq(i + 1).css('height', tailleBloc + 'px');
						
				}
				if(parseInt(tailleBloc, 10) < parseInt(tailleBlocAlt, 10)){
					$('#' + attrIdBlocr + ' .bloc .desc').eq(i).css('height', tailleBlocAlt + 'px');	
					
				}
			}
});
     
  		});  
		
		if(homenonselect){
		window.setTimeout(function() {
			
	$('#content').scroll();
	
		
}, 2000);
		

	//$("#content").jScrollPane();
	
	window.setTimeout(function() {
		
		$(window).resize();
		var settings = {
		autoReinitialise: true
	};
	$("#content").jScrollPane();
}, 3000);

}






	
  	});
	

$('#content #headContent ul li a').addClass('first');
	$('#content #headContent ul li a.first').click(function(){
	$('#content').scroll();
	var windowHeightc = $(document).height() +20;
	var fixedHeight = $('#fixedContent').height();
	var documentHeight = windowHeightc - fixedHeight;
	$('#content').css('overflow', 'hidden');
	$('#hide').hide();
	$('#content').animate({
	height: documentHeight,
	marginTop:0
    
  }, 500, function(){
  	$('#fixedContent').addClass('fixed');
	var marginLeftfixed = parseInt(($('#mainContent').css('margin-left')), 10) + 334;
	$('#fixedContent').css('margin-left', marginLeftfixed +'px');
	var fixedHeight = $('#fixedContent').height();
	var fixedPadding = fixedHeight + 40;
	$('#content').css('padding-top',  fixedPadding + 'px');
  });
	$('#hide').animate({
	height: $(document).height()    
  }, 500, function(){
  $(this).show();
  $('#content').css('overflow', 'auto');
$('#content #headContent ul li a').removeClass('first');  
  });
	
	});

	$('#content').not('#content.hasfixed').one('scroll', function() {
	var windowHeighto = $(document).height() +20;
	var fixedHeight = $('#fixedContent').height();
	var documentHeight = windowHeighto - fixedHeight;
	$('#content').css('overflow', 'hidden');
	$('#hide').hide();
	
	$(this).animate({
	height: documentHeight,
	marginTop:0
    
  }, 500, function(){
  	$('#fixedContent').addClass('fixed');
	var marginLeftfixed = parseInt(($('#mainContent').css('margin-left')),10) + 334;
	$('#fixedContent').css('margin-left', marginLeftfixed +'px');
	var fixedHeight = $('#fixedContent').height();
	var fixedPadding = fixedHeight + 40;
	$(this).css('padding-top',  fixedPadding + 'px');
  });
	$('#hide').animate({
	height: $(document).height()    
  }, 500, function(){
  $(this).show();
  $('#content').css('overflow', 'auto');
  $('#content #headContent ul li a').removeClass('first');
  $('#content').css('top', '0');
  });
	});

	$('#content').scroll(function() {
	 var scroll = this.scrollTop;

	$(".showItem").each(function(index, domEle){ 
		var thisDiv = $(this).attr('id');
		var linkToDiv = thisDiv.substr(3);
		var fixedHeight3 = $('#fixedContent').height();
    	var fixedPadding3 = fixedHeight3 + 60; 
  		var targetA = document.getElementById(thisDiv);
  		var target_top3 = targetA.offsetTop - fixedPadding3;
  	
  	if(scroll >= target_top3){
		$('#content #headContent ul li a').removeClass('aktifTitle');  		
		$('#' + linkToDiv).addClass('aktifTitle');  	
		}
	});
});



	$.easing.elasout = function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	};
	$('#content #headContent ul li a').click(function(){
	$('#content #headContent ul li a').removeClass('aktifTitle');
	$(this).addClass('aktifTitle');

	var fixedHeight3 = $('#fixedContent').height();
	
    var fixedPadding3 = fixedHeight3+ 40; 
  	var target_offset3 = $(this.hash).offset();
  	var target_top3 = target_offset3.top - fixedPadding3;
  	
			$('#content').scrollTo($(this).attr('href'), 1300, {easing:'elasout',offset:-fixedPadding3, onAfter:function(){
			//$('#content #headContent ul li a').removeClass('aktifTitle');
			$(this).addClass('aktifTitle');
			}});

			return false;
		
	});
	
var taille = $('#content .blc1').size();
for(i = 1; i < taille ; i = i+2) { 
$('#content .blc1').eq(i).addClass("alt");
};
	
$('#content #headContent ul li a:first').addClass('aktifTitle');	




		

});
$(function() {
  $("a[href$=pdf]").attr("target", "_blank");
});  

$(window).load(function() {
	$('.cycle').cycle();
	//$('#hide').hide();
	
	
	
});
