(function($) {

	redimImg = function (target) {
		//Taille standard des images
		var bgImageSize = {
			width: 1280,
			height: 800
		}

		//Calcule du ratio de l'image
		var imgAR = bgImageSize.width / bgImageSize.height;
		
		//Largeur de la fenêtre.
        var largeurWindow = $(document).width();
        var hauteurWindow = $(document).height();
		
		//Calcule du ratio de la fenêtre
		var winAR = largeurWindow / hauteurWindow;

		console.log(largeurWindow);
		console.log(hauteurWindow);
		 
		// Determine if we need to show the image and whether it needs to stretch tall or wide
		if (largeurWindow < bgImageSize.width && hauteurWindow < bgImageSize.height) {
			
			$(target).removeClass("wide").removeClass("tall");
		} 
		else if ((largeurWindow < bgImageSize.width && hauteurWindow >= bgImageSize.height) || (winAR < imgAR)) {
			
			$(target).removeClass("wide").addClass("tall");
		} else if (largeurWindow >= bgImageSize.width) {
			
			$(target).addClass("wide").removeClass("tall");
		} 
	}
	focusInput = function () {
        //Lorsque le champ input a le focus.
        $("input[type=text], input[type=password]").live("focusin", function () {
			//On récupère la valeur actuelle
			var  value = $(this).val();
			//Si la valeur actuelle est la valeur par défaut, on vide la valeur.
			if (value == this.defaultValue) $(this).val("");
        });

        //Lorsque le champ input perd le focus
        $("input[type=text], input[type=password]").live("focusout",function () {
			//Si la valeur est vide, on remet la valeur par défaut.
			if ($(this).val() == "") $(this).val(this.defaultValue);
        });
	}
	
	//Choisir un nombre entre 2 nombres
	random = function (nb1,nb2) {
        return Math.floor(Math.random() * nb2)+nb1;
    }

    menu = function () {
    	$(".openSubmenu").live("click", function () {
    		$(this).next(".submenu").slideToggle("normal");
    	});

    	$(".submenu").each(function () {
    		if ($(this).find(".on").length > 0) {
    			$(this).show();
    		}
    	});

    }

})(jQuery);
