$(document).ready(function(){

	/* Search form
	***************************/
	var search_form = $('li.search div.search_form');
	var search_form_diplay = false;
	$('li.search a').click(function(){
		if(search_form_diplay == false){
			search_form.show("fast", function(){
				search_form_diplay = true;
			});
		} else{
			search_form.hide("fast", function(){
				search_form_diplay = false;
			});
		}
	});
	
	//if ($.browser.mozilla) {
		var iPhone = false;
	//}
	
	
	
	/* Delete Title of image
	...........................*/
	$('img').removeAttr('title');
	
		
	
	/****** Home Page ******/

	/* Title Animation
	..........................................*/
	$('.element_menu').hover(function(event){
		var speed = 300;
		/*var cube = $(this);
		on_cube(cube, speed);*/
		$(this).animate({backgroundColor: "#333333" }, speed);
		
	}, function(event){
		var speed = 300;
		$(this).animate({backgroundColor: "#111111" }, speed);
		/*var cube = $(this);
		out_cube(cube, speed);*/
	});
	
	function on_cube(cube, speed){
		cube.animate({backgroundColor: "rgba(255, 255, 255, 0.2)" }, speed, function(){
			cube.animate({backgroundColor: "rgba(255, 255, 255, 0)"}, speed, function(){
				on_cube(cube, speed);
			});
		});
	}
	
	function out_cube(cube, speed){
		cube.animate({backgroundColor: "rgba(255, 255, 255, 0)"}, speed);
		cube.stop();
	}
	
	
	/* Square animation
	.........................................*/
	var allColumn = $('#backgroundColumns').find('.oneColumn');
	if(iPhone == false){
		if ( $.browser.msie && $.browser.version < "7" ) {
			alert( $.browser.version );
		}else{
			animAllColumns(allColumn);
		}
    }
	
	function animAllColumns(allColumn){
		allColumn.eachDelay(function(){
			var thisColumn = $(this);
			animOneColumn(thisColumn);
		},50);
	}
	
	function animOneColumn(oneColumn){
		var allBlocks = oneColumn.find('.oneBlock');
		
		allBlocks.eachDelay(function(){
			var thisBlock = $(this);
			animBlock3(thisBlock);
		},50);
	}
	
	function animBlock(block){
		var speed = 500;
		block.animate({backgroundColor: "#D020B3" }, speed, function(){		//rose
			block.animate({ backgroundColor: "#0218A2" }, speed, function(){	//bleu
				block.animate({ backgroundColor: "#13D4E3" }, speed, function(){	//turquoise
					block.animate({ backgroundColor: "#07B347" }, speed, function(){	//vert
						block.animate({ backgroundColor: "#F2F125" }, speed, function(){	//jaune
							block.animate({ backgroundColor: "#E12112" }, speed, function(){	//rouge
								block.animate({ backgroundColor: "#D020B3" }, speed, function(){	//rose
									animBlock(block);
								});
							});
						});
					});
				});
			});
		});				
	}
	
	function animBlock2(block){
		var speed = 1000;
		block.animate({backgroundColor: "#D020B3" }, speed, function(){		//rose
			block.animate({ backgroundColor: "#972b71" }, speed, function(){	//mauve
				block.animate({ backgroundColor: "#75a0cd" }, speed, function(){	//bleu ciel
					block.animate({ backgroundColor: "#ffd70c" }, speed, function(){	//or
						animBlock2(block);
					});
				});
			});
		});				
	}
	
	function animBlock3(block){
		var speed = 1200;
		block.animate({backgroundColor: "#544D5A"}, speed, function(){
			block.animate({backgroundColor: "#0C0215"}, speed, function(){
				animBlock3(block);
			});
		});				
	}
	
	/****** NEWS ******/
	/* Deactivate flash menu on smartphone
	.....................................*/
	if(iPhone == true){
        $("#menu_text").css('display','block');
        $("#menu_flash").css('display','none');
    }
});
