function returnFalse() { return false; };
$(document).ready(function(){	

var hauteur = screen.height;
	if (hauteur < 650)
	{
		$('#container').css({
			'margin-top':'-136px',
			'top':'auto'
		});	

	}
	
	var versionNav = navigator.appVersion;
	if ((navigator.appName == 'Microsoft Internet Explorer') && (versionNav.search('MSIE 6') > 0))	
 	{
		$('#container').css({
			'position':'absolute',
			'left':'auto',
			'margin-left':'0px'
		});	
		$('#fondPortfolio').css('background','none');
		$('#logo').css('background','url(medias/logo-ifs.gif) no-repeat');
		//$('#mainContent img').css('border','10px solid #ff8400')
		$('#swing').css({
			'height':'0',
			'width':'0',
			'background':'none'
		});
	}
	
  $(function() { $(".lavaLamp").lavaLamp({ fx: "easeOutExpo", speed: 700 })});

	// ***** PROMO BOX 1
	$('#promoOne a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoOne').mouseenter(function(){
		$('#promoOne a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoOne').mouseleave(function(){
		$('#promoOne a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});
	
	// ***** PROMO BOX 3
	$('#promoThree a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoThree').mouseenter(function(){
		$('#promoThree a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoThree').mouseleave(function(){
		$('#promoThree a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});
	
	// ***** PROMO BOX 2
	$('#promoTwo a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoTwo').mouseenter(function(){
		$('#promoTwo a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoTwo').mouseleave(function(){
		$('#promoTwo a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});	

	// ***** PROMO BOX 4
	$('#promoFour a').children('.legende').slideUp(2, 'easeInExpo');
	
	$('#promoFour').mouseenter(function(){
		$('#promoFour a').children('.legende').slideDown('fast', 'easeOutExpo');							  
	});
	
	$('#promoFour').mouseleave(function(){
		$('#promoFour a').children('.legende').slideUp('fast', 'easeInExpo');							  
	});	


	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */
	
	$('#submit .button').bind('click', returnFalse);
	var nom = false;
	var postal = false;
	var emailFrom = false;
	var phone = true;
	var city = false;
	var address = false;
	
	$('#txtName').blur(function(){
		if ($('#txtName').val() == '')
		{
			$('#alertName').append('<p class="red">* Veuillez indiquer vos nom et prénom </p>');
			nom = false;
		}
		else {
			$('#alertName').append('<p class="green">* Nom et prénom renseignés </p>');	
			nom = true;
		}		

		if (emailFrom && nom && address && city && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	var filterTwo=/^\+?[0-9]{5,15}$/;
	$('#txtPhone').blur(function(){
		if ($('#txtPhone').val() == '')
		{
			//$('#alertPhone').append('<p class="red">* Veuillez indiquer votre numéro</p>');	
			phone = true;
		}
		else if (filterTwo.test($('#txtPhone').val())) {
			$('#alertPhone').append('<p class="green">* Téléphone valide</p>');	
			phone = true;
		}		
	
		else {
			$('#alertPhone').append('<p class="orange">* Faux numéro. Uniquement des chiffres et sans espace</p>');	
			phone = false;
		}		

		if (emailFrom && nom)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});


	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailFrom').blur(function(){
		if ($('#txtEmailFrom').val() == '')
		{
			$('#alertEmailFrom').append('<p class="red">* Veuillez indiquer votre email</p>');	
			emailFrom = false;
		}
		else if (filter.test($('#txtEmailFrom').val())) {
			$('#alertEmailFrom').append('<p class="green">*  Champ email complet</p>');	
			emailFrom = true;
		}
		else {
			$('#alertEmailFrom').append('<p class="orange">* Rentrer une adresse email valide svp</p>');	
			emailFrom = false;
		}		
		
		if (emailFrom && nom)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	$('#txtEmailFrom').focus(function(){
		$('#alertEmailFrom').empty();	
	});	
	
	$('#txtName').focus(function(){
		$('#alertName').empty();	
	});		

	$('#txtPhone').focus(function(){
		$('#alertPhone').empty();	
	});	

	$('#txtPostal').focus(function(){
		$('#alertPostal').empty();	
	});	
	

	$('#submit .button').click(function(){
		if (emailFrom && nom)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	 
	});	
	
		
/* FIN CONTACT */

	
	
	/* $('#scrollToTheTop').mouseenter(function(){
			$('#defilantImg').stop().animate({top:'+=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});								 
 			$('#defilantPhotos').stop().animate({top:'+=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});								 

			$(this).stop().fadeTo('1000', 1);
			
	});
	$('#scrollToTheTop').click(function(){
			$('#defilantImg').stop().animate({top:'+=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});
			$('#defilantPhotos').stop().animate({top:'+=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});
			
	});	
	$('#scrollToTheTop').mouseleave(function(){
			$(this).stop().fadeTo('1000', 0.2);
			
	});
	
	
	$('#scrollToTheBottom').mouseenter(function(){
			$('#defilantImg').stop().animate({top:'-=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});								 
			$('#defilantPhotos').stop().animate({top:'-=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});								 
			$(this).stop().fadeTo('1000', 1);
			
	});
	$('#scrollToTheBottom').click(function(){
			$('#defilantImg').stop().animate({top:'-=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});
			$('#defilantPhotos').stop().animate({top:'-=400px'},{queue:false, duration:600, easing: 'easeInOutQuad'});
			
	});	
	$('#scrollToTheBottom').mouseleave(function(){
			$(this).stop().fadeTo('1000', 0.2);
			
	});	
	
	*/
	
	
	$('#defilantImg img').bind('click', function() {
			var whatToLoad = $(this).attr('class');
			$('#mainContent').fadeTo('slow', 0);
			$('#loading').fadeTo('fast', 0.8);
			
			$('#mainContent').load('projects.php #'+whatToLoad, function(){
				$('#mainContent').fadeTo('slow', 1, function(){
					$('#pied-page').show();
				});
				$('#loading').fadeTo('fast',0); 
				
				
				var dejaOuvert = true;
				$('#boutonTPD a').bind('click', function() {
						if (dejaOuvert == false)
						{
							$('#texteParDessus').stop().animate({marginLeft:'0px', width:'250px'},{queue:false, duration:600, easing: 'easeInOutQuad'});	
							$('#boutonTPD a').text('');
							$('#boutonTPD a').append('<img src="medias/times.png" />');
							dejaOuvert = true;
						}
						else if (dejaOuvert == true)
						{
							$('#texteParDessus').stop().animate({marginLeft:'0px', width:'0px'},{queue:false,duration:600, easing: 'easeInOutQuad'});
							$('#boutonTPD a').text('');
							$('#boutonTPD a').append('<img src="medias/gt.png" />');
							dejaOuvert = false;
						}
						return false;
				});
				
			});
			$(this).attr('href','#mosaique-projets');
	});
	



	$('#defilantGalerie img').bind('click', function() {
			var whatToLoad = $(this).attr('class');
			$('#mainContentGalerie').fadeTo('slow', 0);
			$('#loading').fadeTo('fast', 0.8);
			
			$('#mainContentGalerie').load('galerie.php #'+whatToLoad, function(){
				$('#mainContentGalerie').fadeTo('slow', 1, function(){
					$('#pied-page').show();;	
				});
				$('#loading').fadeTo('fast',0); 
				
			});
			$(this).attr('href','#galerie-photos');
	});




				var dejaOuvert = true;
				$('#boutonTPD a').bind('click', function() {
						if (dejaOuvert == false)
						{
							$('#texteParDessus').stop().animate({marginLeft:'0px', width:'250px'},{queue:false, duration:600, easing: 'easeInOutQuad'});	
							$('#boutonTPD a').text('');
							$('#boutonTPD a').append('<img src="medias/times.png" />');
							dejaOuvert = true;
						}
						else if (dejaOuvert == true)
						{
							$('#texteParDessus').stop().animate({marginLeft:'0px', width:'0px'},{queue:false,duration:600, easing: 'easeInOutQuad'});
							$('#boutonTPD a').text('');
							$('#boutonTPD a').append('<img src="medias/gt.png" />');
							dejaOuvert = false;
						}
						return false;
				});


});

