$(document).ready(function(){
	//positionner les spots
	var height = window.innerHeight;
	var width = window.innerWidth;
	//alert(document.body.clientHeight+" "+window.innerHeight+" "+$(document).height());
	if(height==0){
		height = window.innerHeight;
	}
	if(width==0){
		width = window.innerWidth;
	}
	$('#spot1').css('left', '200px');
	$('#spot2').css('left', (width/2)+'px');
	$('#spot3').css('left', ((width/2)-600)+'px');
	$('#spot4').css('left', (width-800)+'px');
	$('#lyre').css('left', (width-600)+'px');
	$('#silhouette').css('top', (height-320)+'px');
	$('#silhouette').css('left', ((width/2)-750)+'px');
	$('.bottom-bg').css('left', ((width/2)-822)+'px');
	$('.bottom-bg').css('top', (height-450)+'px');
	
	var color = new Array('#db6f6f', '#db6fc3', '#6f6fdb', '#6fdbdb', '#6fdb6f', '#dbdb6f');
	
	var bgColorPict = new Array('bg-jaune2.png', 'bg-vert2.png', 'bg-bleu2.png', 'bg-violet2.png', 'bg-rouge2.png');
	var bgColorIndex = 0;

	var flashColor = function(color){
		$(document).everyTime(10000, function() {
			$('body').animate({ backgroundColor: color }, 'fast');
			$('body').animate({ backgroundColor: "#000000" }, 'fast');
		}, 0);
	};
	
	
	var dimmer = function(speed, spot){
		if(spot.is(':visible')){
			spot.fadeOut(speed);
		}
		else {
			spot.fadeIn(speed);
		}
	};
	
	var changeBgcolor = function(div){
		div.css("background","url(\"images/"+bgColorPict[bgColorIndex]+"\") no-repeat");
		bgColorIndex++;
		if(bgColorIndex>4){
			bgColorIndex=0;
		}
	}
	
	var switchBackgroundLight = function(speed){
		if($('#bottom-bg1').is(':visible')){
			$('#bottom-bg2').fadeIn(5000);
			$('#bottom-bg1').fadeOut(5000);
			$('#bottom-bg1').css("z-index",1);
			$('#bottom-bg2').css("z-index",2);
			changeBgcolor($('#bottom-bg1'));
		}
		else {
			$('#bottom-bg1').fadeIn(5000);
			$('#bottom-bg2').fadeOut(5000);
			$('#bottom-bg2').css("z-index",1);
			$('#bottom-bg1').css("z-index",2);
			changeBgcolor($('#bottom-bg2'));
		}		
	};

	

	
	//flashColor('#ffffff');
	
	$(document).everyTime(3000, function() {
		dimmer(1000, $('#spot1')); 		
	}, 0);
	
	$(document).everyTime(2000, function() {
		dimmer(500, $('#spot2'));	
	}, 0);
	
	$(document).everyTime(3500, function() {
		dimmer(500, $('#spot3'));
	}, 0);
	
	$(document).everyTime(4000, function() {
		dimmer(500, $('#spot4'));		
	}, 0);
	
	
	$(document).everyTime(10000, function() {
		switchBackgroundLight(5000);	
	}, 0);
	
	
	$(document).everyTime(6000, function() {
		$('#lyre').animate({rotate: '+=30deg'}, 3000);	
		$('#lyre').animate({rotate: '-=30deg'}, 3000);	
	}, 0);
	
	
	$(document).everyTime(1000, function() {
		$('#laser').animate({rotate: '+=30deg'}, 1000);	
	}, 0);
	
	/*
	$(document).everyTime(1000, function() {
		$('body').animate({ backgroundColor: "#db6f6f" }, 2000);
		$('body').animate({ backgroundColor: "#db6fc3" }, 2000);
		$('body').animate({ backgroundColor: "#6f6fdb" }, 2000);
		$('body').animate({ backgroundColor: "#6fdbdb" }, 2000);
		$('body').animate({ backgroundColor: "#6fdb6f" }, 2000);
		$('body').animate({ backgroundColor: "#dbdb6f" }, 2000);
		$('body').animate({ backgroundColor: "#ffffff" }, 2000);
	}, 0);
	*/
	

});

function sendContactMail(){
	var nom = $('#name').attr('value');
	var email = $('#email').attr('value');
	var msg = $('#msg').attr('value');
	
	http_query = "nom="+encodeURIComponent(nom)+"&email="+email+"&msg="+encodeURIComponent(msg);
	jQuery.post('./mail.php',http_query,function (data,status){
		$('#name').attr('value','');
		$('#email').attr('value','');
		$('#msg').attr('value','');
		alert("Votre message a bien été envoyé");
		
	});
	return false;
};