$(document).ready(
		function() {
			$("#q0").hide();
			$("#q1").hide();
			$("#q2").hide();
			$("#q3").hide();
			$("#q4").hide();
			$("#q5").hide();
			$("#mesaj").hide();
			$("#Afla_cum").hide();
			$("#tipafriend").hide();
			$("#go_green").hide();
			$("#doctor").fadeIn('slow');
			$("#Title").fadeIn('slow');
			$("#Cont_go").fadeIn('slow');
			

   $(".go").click(
		 function() {
			$("#q0").fadeIn('slow');
			$("#q1").hide();
			$("#q2").hide();
			$("#q3").hide();
			$("#q4").hide();
			$("#q5").hide();
			$("#mesaj").hide();
			$("#tipafriend").hide();
			$("#go_green").hide();
			$("#doctor").hide();
			$("#Cont_go").hide();


              
			$(".trimite").click(
					function() {
						var reset_game = false;
						
						var suma = Number($("#rasp2").val()) + Number($("#rasp3").val()) + Number($("#rasp4").val()) + Number($("#rasp5").val()) + Number($("#rasp6").val());
						if ($(this).prev().val() > 24 || suma > 24) {
							alert('Ne pare rau dar o zi are numai 24 de ore');
							$("#q1").hide();
							$("#q2").hide();
							$("#q3").hide();
							$("#q4").hide();
							$("#q5").hide();
							$("#mesaj").hide();
							$("#tipafriend").hide();
							$("#go_green").hide();
							$("#doctor").hide();
							$("#Cont_go").hide();
							$("#rasp2").val('');
							$("#rasp3").val('');
							$("#rasp4").val('');
							$("#rasp5").val('');
							$("#rasp6").val('');
							reset_game = true;
						}
						
						else 
							if ($(this).prev().val() == '') {
								reset_game = true;
								alert('Nu ati raspuns la aceasta intrebare');
							}
							else if (isNaN(Number($(this).prev().val()) ))
							{
							alert('Ne pare rau dar campul introdus nu este un numar');
							}

							else 
								$(this).parent().next().next().fadeIn('slow');
						
						if (reset_game != true) {
							if ($(this).attr('id') == 'a5') {
							
								var d = Number($("#a4").prev().val());
								var e = Number($("#a5").prev().val());
								
								var x = Math.round(231 * (d + e) - 2252.25);
								var msg = '';
								
								var arr = ["3", "4", "5", "6", "Altele"];
								if (jQuery.inArray($("#select_sector").val(), arr) != -1) 
									msg += "Esti un norocos! Doctor Greenfield iti recomanda sa faci o plimbare in padurea Baneasa";
								else 
									if (x <= 0) 
										msg += "Esti un norocos! Doctor Greenfield iti recomanda sa faci o plimbare in padurea Baneasa";
									
									else {
										var y = Math.round(x / 24);
										msg += "Daca ai locui in Greenfield ai castiga in plus <span class='red'>" + x + "</span> ore sau <span class='red'>" + y + "</span> zile de concediu pe an.";
										$("#go_green").fadeIn('slow');
										$("#doctor").hide();
										$("#mesaj").html(msg);
										$("#q0").hide();
										$("#q1").hide();
										$("#q2").hide();
										$("#q3").hide();
										$("#q4").hide();
										$("#q5").hide();
										$("#Title").hide();
										$("#Afla_cum").fadeIn('slow');
										
									}
								$("#mesaj").html(msg);
								$("#tipafriend").fadeIn('slow');
								$("#doctor").fadeIn('slow');
								$("#q0").hide();
								$("#q1").hide();
								$("#q2").hide();
								$("#q3").hide();
								$("#q4").hide();
								$("#q5").hide();
								$("#Title").hide();
								
							}
						}
					});
			});
		});