// Mathieu Zwygart - http://redux.ch - Octobre 2011


function scrollWin() {
	$('html,body').animate({scrollTop: $("#last-work-title").offset().top}, 500);
}

function closeDetails(changeWork) {
	
	if (changeWork == null) {
	
		$("#works-details").slideToggle(500, function() {
			$(this).empty();
			$("#last-work-title").fadeOut(0);
			$('html,body').animate({scrollTop: $("#superglobal").offset().top}, 500);
		});
		
	} else {
		$("#last-work-title").fadeOut(0);
	}
	
}

function openDetails(workId) {
	$("#"+workId).fadeIn(0);
}

$(document).ready(function(){
	
	// Display none dans le js
	$('#last-work-title').css('display', 'none');
	$('.work-details').css('display', 'none');
	$('#work-list li span').css('display', 'none');
	
	// Effet sur les thumbnails au passage de la souris
	$('#work-list a').hover(
		function(){
			$(this).children('span').slideDown(100);
			$(this).children('.logo-client').fadeIn(100);
		},
		function () {
			$(this).children('span').slideUp(100);
			$(this).children('.logo-client').fadeOut(100);;
		}
	);
	
	// Fermer les détails
	$('#close-details').click(function(event){
		closeDetails();
	});
	
	// Bouton scroller au thumbails
	$('#back-thumbnails').click(function(event){
		$('html,body').animate({scrollTop: $("#works-list").offset().top}, 500);			  
	});
	
	
	
	// Spécial pour les promos (trop cool WOW !)
	$('.close-promo').click(function(event){
		var id = $(this).attr('id').replace("close-", "promo-");
		$("#"+id).slideToggle(500, function() {
			$(this).empty();
		});
	});
	
	$('.back-thumbnails-promo').click(function(event){
		$('html,body').animate({scrollTop: $("#works-list").offset().top}, 500);			  
	});
	
	// Fix pour Firefox
	/*var ua = $.browser;
	if ( ua.mozilla ) {
		$('body').css('margin-top','-30px');
	}*/
	
	// Rezise #global si il est trop petit
	var globalsize = $('#global').height();
	if ( globalsize < 700 ) {
		$('#global').css('height', 700 + "px");
	}
	
});
