function returnFalse() { return false; };
nbNews = 4; // POUR LES ACTUALITES
$(document).ready(function(){	
	
	 	$(function() { $(".lavaLamp").lavaLamp({ fx: "swing", speed: 400 })});

	
	var versionNav = navigator.appVersion;
	if ((screen.width < 1100) || ((navigator.appName == 'Microsoft Internet Explorer') && (versionNav.search('MSIE 6'))))	
 	{
		$('#menuHome').css('position','absolute');
		$('#menu').css('position','absolute');
		$('#menu ul.lavaLamp li.back, #menuHome ul.lavaLamp li.back ').css('background-position','left 9px');
		$('#catalogueProduits').css('position','absolute');
		$('#catalogueProduitsTransparent').css('position','absolute');
		$('#contenuCatalogueProduits').css('position','absolute');	
	}

	if (screen.width < 1100)	
 	{
		$('#menu ul.lavaLamp li.back, #menuHome ul.lavaLamp li.back ').css('background-position','left 9px');
		
	}
 
	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */
	
	$('#submit .button').bind('click', returnFalse);
	var nom = false;
	var postal = false;
	var emailFrom = 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">* Champ nom et prénom valide </p>');	
			nom = true;
		}		

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


	$('#txtPostal').blur(function(){
		if ($('#txtPostal').val() == '')
		{
			$('#alertPostal').append('<p class="red">* Veuillez indiquer le code postal</p>');	
			postal = false;
		}
		else {
			$('#alertPostal').append('<p class="green">* Champ code postal valide</p>');	
			postal = true;
		}		

		if (emailFrom && nom && postal)
		{
			$('#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 && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

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

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


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

/*---- PARAGRAPHE TO GROW ------ */

	var deroule = false;
	$('#agrandir').bind('click', function() {
		if (deroule == false)
		{
			deroule = true;
			theOffset= $('#footer').offset().top;
			
			$('#paragrapheToGrow').animate({height:'100%'},{queue:false, duration:2000, easing: 'easeInOutQuint'});
			$('html,body').animate({scrollTop:theOffset+'px'},1600);															 
	
		}
		else //if deroule == true
		{
			$('#paragrapheToGrow').animate({height:'140px'},{queue:false, duration:2000, easing: 'easeInOutQuint'});
			deroule = false;
		}
	});

// +-+-+-+-+-+- LIST PAGE

/*			$('.textItem').hide();
			$('#item1').slideDown('slow');
			$('#items h2').click(function() {
				
				if ($(this).next('.textItem:visible').length != 0)
				{
					$('.textItem').stop().slideUp('fast');
					$(this).next('.textItem').stop().slideUp('slow');
				}			
				else 
				{
					$('.textItem').stop().slideUp('fast');
					$(this).next('.textItem').stop().slideDown('slow');
				}
			});

*/
//---- DIVERS

	$('.enSavoirPlus').bind('mouseenter', function() {
		var source = $(this).children('img').attr('src');
		source = source.split("/");
		source = source[1].split(".");
		$(this).stop().children('img').attr('src', 'medias/'+source[0]+'Over.jpg');									  
	});
	
	$('.enSavoirPlus').bind('mouseleave', function() {
		var source = $(this).children('img').attr('src');
		source = source.split("/");
		source = source[1].split("Over");
		$(this).stop().children('img').attr('src', 'medias/'+source[0]+'.jpg');									  
	});
	
	
//------ CATALOGUE PRODUITS
	/* Première fois à l'ouverture de la page 
	$('#catalogueProduitsTransparent').css('width','211px');				
	$('#catalogueProduits').animate({width:'300px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
	$('#contenuCatalogueProduits').animate({right:'0px'}, 1000, function()
	{
		$('#menuCatalogueProduits li').fadeTo('slow',0.7);
		$('#menuCatalogueProduits li.eclairagePublic').fadeTo('slow',1, function() {
			
			$('#catalogueProduits').animate({width:'300px'}, 2000, function(){
				$('#contenuCatalogueProduits').fadeOut(500);
				$('#catalogueProduits').animate({width:'70px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
				$('#catalogueProduitsTransparent').css('width','50px');
			
			});
		});
		$('#contenuCatalogueProduits').css('display','block');
	});														
	*/
	
	var dejaOuvert = false;	var dejaOuvertTwo = false;
	$('#voirtoutlecataloguea').bind('click', returnFalse);
	$('#voirtoutlecataloguea').bind('click', function() {
		if (dejaOuvertTwo == true)
		{
			$('#contenuGamme').animate({height:'0px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
			$('#gamme li').css('display','none');
			dejaOuvertTwo = false;	
		}
		
		if (dejaOuvert == false)
		{
			$('#contenuCatalogueProduits').animate({height:'393px'}, 1000, function()
			{
				$('#menuCatalogueProduits li').css('display','block');
				$('.detailProduit #produits-eclairagePublic').css('display','block');
			});	
			dejaOuvert = true;
		}
		else if (dejaOuvert == true)
		{
			$('#contenuCatalogueProduits').animate({height:'0px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
			$('.detailProduit ul').css('display','none');
			$('#contenuCatalogueProduits').css('display','none');
			$('#menuCatalogueProduits li').css('display','none');
			dejaOuvert = false;	
		}
		
	});

	$('#menuCatalogueProduits a').bind('click',returnFalse);
	$('#menuCatalogueProduits a').bind('click', function() {
		var produit = $(this).attr('class');
		$('.detailProduit ul').fadeOut(0);
		$('#produits-'+produit).fadeIn('slow');
	});
	
	$('ul#menuCatalogueProduits li').bind('mouseenter', function() {
		$(this).stop().fadeTo('slow',0.8);
	});


	$('ul#menuCatalogueProduits li').bind('mouseleave', function() {
		$(this).stop().fadeTo('slow',1);
	});
	
	
	$('#voirtoutelagammea').bind('click', returnFalse);
	$('#voirtoutelagammea').bind('click', function() {
		if (dejaOuvert == true)
		{
			$('#contenuCatalogueProduits').animate({height:'0px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
			$('.detailProduit ul').css('display','none');
			$('#contenuCatalogueProduits').css('display','none');
			$('#menuCatalogueProduits li').css('display','none');
			dejaOuvert = false;	
		}		
		if (dejaOuvertTwo == false)
		{
			$('#contenuGamme').animate({height:'225px'}, 1000, function()
			{
				$('#gamme li').css('display','block');
			});	
			dejaOuvertTwo = true;
		}
		else if (dejaOuvertTwo == true)
		{
			$('#contenuGamme').animate({height:'0px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
			$('#gamme li').css('display','none');
			dejaOuvertTwo = false;	
		}
	});	


// LOAD CONTENU .PHP

/*	$('.tubes a').bind('click', returnFalse);
	$('.tubes a').bind('click',function(){
		$('#items').stop().fadeTo(400, 0, function() {
			$('#items').load('led-tubes.php #items', function(){
				$('#items').fadeTo(400,1);
				$('#menuCatalogueProduits li').fadeTo('slow',0.7);
				$('#menuCatalogueProduits li.tubes').fadeTo('slow',1);		
				$('#contenuCatalogueProduits').fadeOut(500);
				$('#catalogueProduits').animate({width:'70px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
				$('#catalogueProduitsTransparent').css('width','50px');

			});													  
		});
	});

	$('.bulbes a').bind('click', returnFalse);
	$('.bulbes a').bind('click',function(){
		$('#items').stop().fadeTo(400, 0, function() {
			$('#items').load('led-bulbes3.php #items', function(){
				$('#items').fadeTo(400,1);
				$('#menuCatalogueProduits li').fadeTo('slow',0.7);
				$('#menuCatalogueProduits li.bulbes').fadeTo('slow',1);				
				$('#contenuCatalogueProduits').fadeOut(500);
				$('#catalogueProduits').animate({width:'70px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
				$('#catalogueProduitsTransparent').css('width','50px');

			});													  
		});
	});


	$('.eclairagePublic a').bind('click', returnFalse);
	$('.eclairagePublic a').bind('click',function(){
		$('#items').stop().fadeTo(400, 0, function() {
			$('#items').load('led-economique-produits.php #items', function(){
				$('#items').fadeTo(400,1);
				$('#menuCatalogueProduits li').fadeTo('slow',0.7);
				$('#menuCatalogueProduits li.eclairagePublic').fadeTo('slow',1);				
				$('#contenuCatalogueProduits').fadeOut(500);
				$('#catalogueProduits').animate({width:'70px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
				$('#catalogueProduitsTransparent').css('width','50px');

			});													  
		});
	});

	$('.spots a').bind('click', returnFalse);
	$('.spots a').bind('click',function(){
		$('#items').stop().fadeTo(400, 0, function() {
			$('#items').load('led-spots.php #items', function(){
				$('#items').fadeTo(400,1);
				$('#menuCatalogueProduits li').fadeTo('slow',0.7);
				$('#menuCatalogueProduits li.spots').fadeTo('slow',1);				
				$('#contenuCatalogueProduits').fadeOut(500);
				$('#catalogueProduits').animate({width:'70px'},{queue:false, duration:1000, easing: 'easeInOutQuint'});
				$('#catalogueProduitsTransparent').css('width','50px');

			});													  
		});
	});

*/


	$('#gammeProduit li a').bind('mouseenter', function() {	
		$(this).children('img').fadeTo('normal',0.6);
	});
	$('#gammeProduit li a').bind('mouseleave', function() {	
		$(this).children('img').fadeTo('normal',1);
	});

	$('table#presentationProduit td').bind('mouseenter', function() {	
		$(this).fadeTo('normal',0.7);
	});
	$('table#presentationProduit td').bind('mouseleave', function() {	
		$(this).fadeTo('normal',1);
	});


});


