(function ($)
{
	// VERTICALLY ALIGN FUNCTION
	$.fn.vAlign = function()
	{
		return this.each(function(i)
		{
			var ah = $(this).height();
			var ph = $(this).parent().height();
			if (ah < ph) {
				var mh = (ph - ah) / 2;
				$(this).css('padding-top', mh);
				$(this).css('padding-bottom', mh);
			}
		}
		);
	};
}
)(jQuery);

$(document).ready(
	function()
	{
		// Used to align vertically the text in the A tag of the thumbnail hover effect
		$(".LinkLogoAHref").vAlign();
	
		$('#menu>li>ul').hide();
		$('#menu>li>ul').parent().hover( function() {
			$('ul',this).show();
		}, function() {
			$('ul',this).hide();
		});
		
		// Validate the order form before sending
//		if($("#frmSendOrder").length > 0) {
//			$("#frmSendOrder").validate();
//		}
	// Validate the user profile before sending
		$("#frmSendOrder").validate({
			errorPlacement: function() {}, 
			rules: {
				frmCourriel: {
					required: function() {
						if($("#frmCourriel").val() == "") {
							return true;
						} else {
							return false;
						}
					},
					email: true
				}
			}
			/*
			submitHandler: function(){
				
				$.post(
					"/envoyez_commande.php",
					$("#frmSendOrder").serialize(),
					function(mydata){
						alert("Merci pour votre commande");
						//window.location.href="/commande_en_ligne.php";
					}, "html"
				);
				return false;
				
				return false;
			}
			*/
		});
		// bogue dans IE 7
		if ($.browser.msie && $.browser.version < 8){
			$("#content").css("overflow", "visible");
		}
		
	}
);
