/*  */


$(document).ready(function() {
	//placeholder fallback

	if(!jQuery('<input placeholder="1" />')[0].placeholder){
		jQuery(':input[placeholder]').each(function(){
			var $this = $(this);
			if(!$this.val()){
				$this.val($this.attr('placeholder'));
				$this.addClass('input-placeholder');
			}
		}).live('focus', function(e){
			var $this = $(this);
			if($this.hasClass('input-placeholder')){
				$this.val('');
				$this.removeClass('input-placeholder')
			}
		}).live('blur', function(e){
			var $this = $(this);
			if(!$this.val()){
				$this.addClass('input-placeholder');
				$this.val($this.attr('placeholder'));
			}
		});
	}
	
	if($("#pes")){
		$("#pes").keyup(calculIMC);
		$("#altura").keyup(calculIMC);
	}
	
	$("#men844").mouseenter(function(){
		$("#sub844").stop(true, false);
		$("#sub844").animate({
			height:  $("#sub844 > .submenuHeight").height(),
			"padding-top": "10px",
			"padding-bottom": "10px",
			opacity: 	1
		})
	})
	
	$("#men844").mouseleave(function(){
		$("#sub844").stop(true, false);
		$("#sub844").animate({
			height: "0px",
			"padding-top": "0px",
			"padding-bottom": "0px",
			opacity: 	0
		})
	})
	
	$("#men845").mouseenter(function(){
		$("#sub845").stop(true, false);
		$("#sub845").animate({
			height:  $("#sub845 > .submenuHeight").height(),
			"padding-top": "10px",
			"padding-bottom": "10px",
			opacity: 	1
		})
	})
	
	$("#men845").mouseleave(function(){
		$("#sub845").stop(true, false);	
		$("#sub845").animate({
			height: "0px",
			"padding-top": "0px",
			"padding-bottom": "0px",
			opacity: 	0
		})
	})
	
	$("#men842").mouseenter(function(){
		$("#sub842").stop(true, false);
		$("#sub842").animate({
			height:  $("#sub842 > .submenuHeight").height(),
			"padding-top": "10px",
			"padding-bottom": "10px",
			opacity: 	1
		})
	})
	
	$("#men842").mouseleave(function(){
		$("#sub842").stop(true, false);	
		$("#sub842").animate({
			height: "0px",
			"padding-top": "0px",
			"padding-bottom": "0px",
			opacity: 	0
		})
	})
	
	
	
	//menu
	$("#sub844").css("opacity", 0);

	
	$("#sub845").css("opacity", 0);
});

function calculIMC(){
	
	var pes = $("#pes").val();
	var altura = $("#altura").val()/100;

	if(pes>40 && altura>0.5){
		
		var imc =  pes / (altura*altura);

		$("#resultat").val(imc);
	} else {
		$("#resultat").val("");
	}
}
