
function deployFunctions() {
	
	/**************************************************
		SLIDER
	**************************************************/
	
	$(".sliderMask, .jScrollPaneContainer").height($(window).height());
	$('.sliderMask').jScrollPane();
	
	/**************************************************
		NAVIGATION - BLOG
	**************************************************/
	
	$(".nav.blog").height($(window).height());
	
	if ($('.nav.blog .navContent').height() < $(window).height()) {
		$('.nav.blog .navContent').css('top', ($(window).height() - $('.nav.blog .navContent').height()) / 2);
	}
	
	/**************************************************
		NAVIGATION - PORTFOLIO
	**************************************************/ 
	
	/*$(".nav.portfolio").height($(window).height() - 200); //rajout 200 pour limiter la hauteur du mask
	*/
	if ($('.nav.portfolio .navContent').height() < $(window).height()) {
		/*console.log($(window).height());
		console.log($('.content').css('top'));
    console.log($('.nav.portfolio .navContent').height());*/
    //$('.nav.portfolio .navContent').css('top', ($(window).height() + $('.content').css('top') - $('.nav.portfolio .navContent').height()) / 2);
	}
	
	/**************************************************
		GOOGLE MAPS
	**************************************************/
	
	if ($.browser.msie && $.browser.version=="6.0") {
		$("#background div.gradient .right, #background div.gradient .left").height($(window).height());
	}
	
}

$(document).ready(function() {

	deployFunctions();
	
	/**************************************************
		SEARCH
	**************************************************/
	
	$('.menu .search').hover(function(){
		$(this).animate({left: '0px'}, {queue:false, duration: 100});
	},
	function(){
		$(this).animate({left: '-150px'}, {queue:false, duration: 100});
	});
	
	/**************************************************
		SLIDER
	**************************************************/
	
	$('.sliderMask .sliderContent img').load(function() {
		$(".sliderMask, .jScrollPaneContainer").height($(window).height());
		$('.sliderMask').jScrollPane();
	});
	
	/**************************************************
		NAVIGATION - BLOG
	**************************************************/
	
	$('.nav.blog .navContent li a').hover(function(){
		$(this).animate({paddingRight: '20px'}, {queue:false, duration: 100});
	},
	function(){
		$(this).animate({paddingRight: '10px'}, {queue:false, duration: 100});
	});
	
	$('.nav.blog .navMask ul.navContent').mousemove(function(e) {
		var _top = parseInt($('.nav.blog').offset().top);
		var _contentH = parseInt($('.nav.blog .navMask').height()) + 5;
		var _H = $('.nav.blog').height() - 20;
		var _scH = _contentH - _H;
		var _ypos = e.pageY - _top;
		
		if(_scH > 0) {
			var _contentY = -(_scH / _H)*_ypos + 10;
			$('.nav.blog .navMask .navContent').animate({top: _contentY}, { queue:false, duration: 500 });
		}
	});
	
	/**************************************************
		NAVIGATION - PORTFOLIO
	**************************************************/
	
	$('.nav.portfolio .navMask ul.navContent li').hover(function(){
		//$(this).children(".details").animate({left: '0px'}, {queue:false, duration: 100});
		$(".details").hide();
		$(this).children(".details").show();
		$(this).children(".details").animate({top: '67px'}, {queue:false, duration: 100});
	},
	function(){
		//$(this).children(".details").animate({left: '147px'}, {queue:false, duration: 100});
		$(".details").show();
    $(this).children(".details").animate({top: '90px'}, {queue:false, duration: 100});
	});
	
	$('.nav.portfolio .navMask ul.navContent li').hover(function(){
		$(this).find(".image img").animate({opacity: '0.5'}, {queue:false, duration: 100});
	},
	function(){
		$(this).find(".image img").animate({opacity: '1'}, {queue:false, duration: 100});
	});
	
	if($('.nav.portfolio  .navMask ul.navContent .item').length > 5) {
    $('.nav.portfolio .navMask ul.navContent').mousemove(function(e) {
    	var _top = parseInt($('.nav.portfolio').offset().top);
    	var _contentH = parseInt($('.nav.portfolio .navMask').height()) + 5;
    	var _H = $('.nav.portfolio').height() - 20;
    	var _scH = _contentH - _H;
    	var _ypos = e.pageY - _top;
    	
    	if(_scH > 0) {
    		var _contentY = -(_scH / _H)*_ypos + 10;
    		$('.nav.portfolio .navMask .navContent').animate({top: _contentY}, { queue:false, duration: 500 });
    	}
    });
  }


/**************************************************
		NAVIGATION - PORTFOLIO MAISON
	**************************************************/
	
	$('.contentPortfolioMaison .nav.portfolio .navMask ul.navContent li').hover(function(){
		//$(this).children(".details").animate({left: '0px'}, {queue:false, duration: 100});
		$(".details").hide();
		$(this).children(".details").show();
		$(this).children(".details").animate({top: '47px'}, {queue:false, duration: 100});
	},
	function(){
		//$(this).children(".details").animate({left: '147px'}, {queue:false, duration: 100});
		$(".details").show();
    $(this).children(".details").animate({top: '70px'}, {queue:false, duration: 100});
	});
	
	$('.contentPortfolioMaison .nav.portfolio .navMask ul.navContent li').hover(function(){
		$(this).find(".image img").animate({opacity: '0.5'}, {queue:false, duration: 100});
	},
	function(){
		$(this).find(".image img").animate({opacity: '1'}, {queue:false, duration: 100});
	});
	
	if($('.contentPortfolioMaison .nav.portfolio  .navMask ul.navContent .item').length > 5) {
    $('.contentPortfolioMaison .nav.portfolio .navMask ul.navContent').mousemove(function(e) {
    	var _top = parseInt($('.nav.portfolio').offset().top);
    	var _contentH = parseInt($('.nav.portfolio .navMask').height()) + 5;
    	var _H = $('.nav.portfolio').height() - 20;
    	var _scH = _contentH - _H;
    	var _ypos = e.pageY - _top;
    	
    	if(_scH > 0) {
    		var _contentY = -(_scH / _H)*_ypos + 10;
    		$('.contentPortfolioMaison .nav.portfolio .navMask .navContent').animate({top: _contentY}, { queue:false, duration: 500 });
    	}
    });
  }


	
	/**************************************************
		BACKGROUND
	**************************************************/
	
    $('#background img').load(function() {
		$(this).css({
			/*top: ($(window).height() - $(this).height()) / 2,*/
			display: 'block'
		});
    });
	
	$('#background img').css({
		/*top: ($(window).height() - $('#background img').height()) / 2,*/
		display: 'block'
	});
	
	/**************************************************
		LIGHTBOX
	**************************************************/
	
	$(function() {
		$('.lightbox').lightBox();
	});
	
});

window.onresize = function() {

	deployFunctions();
	
	/**************************************************
		BACKGROUND
	**************************************************/
	
	//$('#background img').css('top', ($(window).height() - $('#background img').height()) / 2);
}
