jQuery(document).ready(function() {
	
	// script pour remise à vide du champ login mmot de passe formulaire espace perso
	jQuery("#logperso").focus(function() {
        if(jQuery(this).val() == jQuery(this).attr('title')) {
            jQuery(this).val('');
        }
     //   jQuery(this).css('color','#000000');
    });
    jQuery("#logperso").blur(function() {
        if(jQuery(this).val() == '') {
            jQuery(this).val(jQuery(this).attr('title'));
           // jQuery(this).css('color','#777777');
        }
    });
    
    jQuery("#passperso").focus(function() {
        if(jQuery(this).val() == jQuery(this).attr('title')) {jQuery
            jQuery(this).val('');
        }
      //  jQuery(this).css('color','#000000');
    });
    jQuery("#passperso").blur(function() {
        if(jQuery(this).val() == '') {
            //    jQuery(this).attr('type','text');
            jQuery(this).val(jQuery(this).attr('title'));
           // jQuery(this).css('color','#777777');
        }
    });
    
    jQuery("#logperso").blur();
    jQuery("#passperso").blur();
// fin script pour remise à vide du champ login mot de passe formulaire espace perso

	function megaHoverOver(){
		jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();	

		//Calculate width of all ul's
		(function(jQuery) { 
			/*
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				jQuery(this).find("ul").each(function() {					
					rowWidth += jQuery(this).width(); 
				});	
			};
			*/
		})(jQuery); 
		
		if ( jQuery(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			jQuery(this).find(".row").each(function() {							   
				/*jQuery(this).calcSubWidth();*/
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			jQuery(this).find(".sub").css({'width' :biggestRow});
			jQuery(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			/*jQuery(this).calcSubWidth();*/
			//Set Width
			/*jQuery(this).find(".sub").css({'width' : rowWidth});*/
			
		}
	}
	
	function megaHoverOut(){ 
	  jQuery(this).find(".sub").stop().fadeTo('slow', 0).hide();//, function() {
		//jQuery(this).hide(); 
	  //});
//ici changement du degarder mou ou pas enlever de la parathense incluse apres zero 3 ligne plus haut
	}


	var config = {    
		 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	jQuery("ul#topnav li .sub").css({'opacity':'0'});
	jQuery("ul#topnav li").hoverIntent(config);
});


