jQuery(document).ready(
	function() {
								
		var vertical_vitesse = 1000;
		var vertical_fade_vitesse = vertical_vitesse/100*80;
		var vertical_easy = 'easeOutElastic';
		
		var horizontal_vitesse = 400;
		var horizontal_fade_vitesse = horizontal_vitesse/100*80;
		var horizontal_easy = 'linear';
		
		jQuery('#homepage #zone_txt').css({"display":"block"});
		
		/* init */
		jQuery('.zone').each(function(i){
			jQuery(this).stop().css({ "top": "-450px", "opacity":"0.0" });
			var a = jQuery( '.tips_images a:not(.innactif)', this );
			var bg_img =  a.eq( Math.floor( Math.random() * a.length ) ).attr( 'href' );
			jQuery('.hp_images *', this).css({ 'display':'none'});
			if(bg_img){
				if(this.id=='hp_myaubel'){
					var hx = 'left';
				}else{
					var hx = 'center';
				}
				var image = "url('"+bg_img+"')";
				
				jQuery('.hp_images', this).css(
					{
						"background-image":image, 
						"background-color":"white", 
						"background-repeat":"no-repeat", 
						"background-position-x":hx, 
						"background-position-y":"center",
						"cursor":"pointer" 
					}
				);
			}
		});
		var largeurBlockOuvert = "413px"
		var largeurBlockFerme = "150px";
		
		jQuery('.zone').css('width',largeurBlockFerme);
		jQuery('#hp_myaubel').css('width',largeurBlockOuvert);
	
		if(jQuery.browser.safari || jQuery.browser.firefox) {}
		jQuery('.hp_images').corner("round 10px");
		var n =0;
		/* animations */
		jQuery(".zone").each(function(i){
			
			var a = jQuery( '.hp_images img:not(.innactif)', this );
			var bg_img =  a.eq( Math.floor( Math.random() * a.length ) ).attr( 'src' );
			jQuery(this).mouseover(
				function(e){
					e.preventDefault();
				}
			);
			$effet_d_entree = 0;
			
			/* apparition des sous éléments */
			jQuery(this).stop().delay(1000+((n++)*100)).animate(
				{ "top": "0px", "opacity":"1" },
				vertical_vitesse, 
				vertical_easy,
				function(){
					
					var href = jQuery( '.hp_images a.lien_hp ', this ).attr( 'href' );
					
					jQuery('.hp_images', this).text('');
					
					/* si pas de message on supprime les div alpha et message */
					hp_message = jQuery('.hp_message', this).text();
					hp_message = hp_message.replace(/[s]/,"");
					
					if(hp_message == ''){
						jQuery('.hp_alpha', this).remove();
						jQuery('.hp_message', this).remove();
					}
					$effet_d_entree++;
		
					jQuery('.hp_message', this).css({opacity:'1'});
					
					/* actions et effets des rollover */
					jQuery(this).hover(
						function(i){
							/* Roll over */
							if($effet_d_entree == jQuery(".zone").length ){
								window.status = href;
								jQuery(this).siblings('.zone').each(
									function(i){
										jQuery(this).stop().animate(
											{ width: largeurBlockFerme }, 
											horizontal_vitesse, 
											horizontal_easy, 
											function(e){/**/
												if(!jQuery.browser.msie && jQuery.browser.version != "6.0"){
													jQuery('.hp_message', this).stop().animate( { opacity:'0' }, "fast");
												}
											}
										);
									}
								);
								jQuery(this).stop().animate(
									{ width: largeurBlockOuvert }, 
									horizontal_vitesse, 
									horizontal_easy, 
									function(e){/**/
										if(!jQuery.browser.msie && jQuery.browser.version != "6.0"){
											jQuery('.hp_message', this).animate( { opacity:'1' }, "slow" );
										}
									}
								);
							}
						},
						function(i){
							/* Roll out */
							window.status = '';
						}
					);
					/* action click */
					jQuery(this).click(
						function(i){
							document.location.href = href;
						}
					);
						
				}//callback
			);//end animate roll
		});//end each
 	}
 );
