$(function(){		
		
	$("#earseCalc").click(function(){
	
		$("#lenght").val('');
		$("#weight").val('');
		
	});
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// przeliczanie
	$("#weightCalc").submit(function(){

		var wpl = $("#wpl").val();
	
		if($(":radio:checked").val() == 1)
		{
		
			if($("#lenght").val() > 0)
			{
				var value = Math.round(($("#lenght").val()*wpl)*100)/100; 
				$("#weight").val(value);
			}
			else
			{
				$("#lenght").val('');
				$("#weight").val('');
			}
		}
		else
		{
		
			if($(":radio:checked").val() == 2)
			{
				
				if($("#weight").val() > 0 )
				{
					var value = Math.round(($("#weight").val()/wpl)*100)/100;
					$("#lenght").val(value);
				}
				else
				{
					$("#lenght").val('');
					$("#weight").val('');
				}
			}
		}
		
		return false;
	});
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// wyswietlanie

	
	if($("select").attr("id")=="")
	{
		var firstId = $("select  option:first").text();
		$("#"+firstId).css("display", "block");		
	}
	else
	{
		var firstG = $("#gselect > option:first").text();
		var firstH = $("#hselect > option:first").text();
		$("#"+firstG+"x"+firstH).css("display", "block");
	}
 			$("select").change(function () {
		  	$("select option:selected").each(function () {
			
			if($(this).parent("select").attr("id") == "")
			{
				if($(this).attr("id") == "")
				{
					var id = $(this).text();
				}
				else
				{
					var id=$(this).attr("id")+"div";
				}
			}
			else
			{
				var id = $("#gselect >option:selected").text()+"x"+$("#hselect >option:selected").text();
			}
			
			$(".hide").css("display", "none");
			$("#"+id).css("display", "block");
				
			var newWpl = $("#"+id+" > .newWpl > span").text();
		
			$("#wpl").val(newWpl);
		});}).change();
		
});
